mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 06:35:28 +02:00
[251806] Applied additional changes based on review feedback.
This commit is contained in:
parent
a3e5c5fbd5
commit
3fcf9b5042
2 changed files with 31 additions and 25 deletions
|
@ -71,7 +71,7 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
|
|||
public Sequence getSequence() { return fSequence; }
|
||||
|
||||
/**
|
||||
* Executes the next step. Overriding classes should perform the
|
||||
* Executes the step. Overriding classes should perform the
|
||||
* work in this method.
|
||||
* @param rm Result token to submit to executor when step is finished.
|
||||
*/
|
||||
|
@ -112,8 +112,8 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
|
|||
* A step that will report execution progress by itself on the progress
|
||||
* monitor of the owner sequence.<br>
|
||||
* <br>
|
||||
* Note we don't offer a rollBack(rm, pm) as we don't want end user to be
|
||||
* able to cancel the rollback.
|
||||
* Note we don't offer a rollBack(RequestMonitor, IProgressMonitor) as we
|
||||
* don't want end user to be able to cancel the rollback.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
|
@ -210,7 +210,7 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
|
|||
* @since 1.1
|
||||
*/
|
||||
public Sequence(DsfExecutor executor, IProgressMonitor pm, String taskName, String rollbackTaskName) {
|
||||
this(executor, pm, "", "", null); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
this(executor, pm, taskName, rollbackTaskName, new RequestMonitorWithProgress(ImmediateExecutor.getInstance(), pm));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,6 +251,7 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
|
|||
* @deprecated This constructor should not be used because it creates a
|
||||
* potential ambiguity when one of the two monitors is canceled.
|
||||
*/
|
||||
@Deprecated
|
||||
public Sequence(DsfExecutor executor, IProgressMonitor pm, String taskName, String rollbackTaskName, RequestMonitor rm) {
|
||||
fExecutor = executor;
|
||||
fProgressMonitor = pm;
|
||||
|
@ -405,7 +406,6 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
|
|||
fProgressMonitor.worked(getSteps()[fStepIdx].getTicks());
|
||||
}
|
||||
executeStep(fStepIdx + 1);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,11 +62,9 @@ public class DsfSequenceProgressTests {
|
|||
|
||||
class SleepStep extends Sequence.Step {
|
||||
|
||||
final int STEP_TIME = 5; // seconds
|
||||
|
||||
@Override
|
||||
public int getTicks() {
|
||||
return STEP_TIME;
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override public void execute(RequestMonitor requestMonitor) {
|
||||
|
@ -89,22 +87,21 @@ public class DsfSequenceProgressTests {
|
|||
|
||||
class SleepStepWithProgress extends Sequence.StepWithProgress {
|
||||
|
||||
final int STEP_TIME = 5; // seconds
|
||||
|
||||
@Override
|
||||
public int getTicks() {
|
||||
return STEP_TIME;
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(RequestMonitor rm, IProgressMonitor pm) {
|
||||
stepCounter.fInteger++;
|
||||
|
||||
pm.beginTask("", getTicks());
|
||||
|
||||
sleep(getTicks(), rm, pm);
|
||||
// step has its own sub-progress ticks.
|
||||
pm.beginTask(getTaskName() + ": ", 6);
|
||||
sleep(6, rm, pm);
|
||||
|
||||
rm.done();
|
||||
pm.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,16 +116,22 @@ public class DsfSequenceProgressTests {
|
|||
|
||||
@Test
|
||||
/**
|
||||
* Run this as a JUnit plugin test.
|
||||
* In the test workbench, watch the progress bar in the Progress View.
|
||||
* During execution of a StepWithProgress, you should see the progress bar
|
||||
* is growing and you can have more responsive cancel. Meanwhile, during execution
|
||||
* of a step without progress, you should see that progress bar does not
|
||||
* grow and cancel does not work until end of the step. <br>
|
||||
* <br>
|
||||
* Also watch that when you cancel the progress bar during the execution of the
|
||||
* sequence, you should see that "rollback" starts to happen.
|
||||
*/
|
||||
* It's better to run this as a manual interactive test. Run this as a JUnit
|
||||
* plugin test.<br>
|
||||
* <br>
|
||||
* In the test workbench, watch the progress bar in the Progress View.<br>
|
||||
* <br>
|
||||
* During execution of a StepWithProgress, you should see the progress bar
|
||||
* is growing and you can have more responsive cancel.<br>
|
||||
* <br>
|
||||
* Meanwhile, during execution of a step without progress, you should see
|
||||
* that progress bar does not grow and cancel does not work until end of the
|
||||
* step.<br>
|
||||
* <br>
|
||||
* Also watch that when you cancel the progress bar during the execution of
|
||||
* the sequence, you should see that "Rollback.." appears in the progress bar
|
||||
* label.<br>
|
||||
*/
|
||||
public void sequenceProgressTest() throws InterruptedException, ExecutionException {
|
||||
|
||||
final Sequence.Step[] steps = new Sequence.Step[] {
|
||||
|
@ -219,7 +222,10 @@ public class DsfSequenceProgressTests {
|
|||
private static void sleep(int seconds, RequestMonitor rm, IProgressMonitor pm) {
|
||||
try {
|
||||
for (int i = 0; i < seconds; i++) {
|
||||
Thread.sleep(1000);
|
||||
if (pm != null)
|
||||
pm.subTask("subStep - " + (i+1));
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
if (pm != null) {
|
||||
pm.worked(1);
|
||||
|
|
Loading…
Add table
Reference in a new issue