From 3fcf9b50427a83c0af7094e276b282123e59b9e8 Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Thu, 13 Nov 2008 21:29:42 +0000 Subject: [PATCH] [251806] Applied additional changes based on review feedback. --- .../eclipse/dd/dsf/concurrent/Sequence.java | 10 ++-- .../concurrent/DsfSequenceProgressTests.java | 46 +++++++++++-------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Sequence.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Sequence.java index ffde09d60e5..7c3b991badd 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Sequence.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Sequence.java @@ -71,7 +71,7 @@ abstract public class Sequence extends DsfRunnable implements Future { 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 { * A step that will report execution progress by itself on the progress * monitor of the owner sequence.
*
- * 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 { * @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 { * @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 { fProgressMonitor.worked(getSteps()[fStepIdx].getTicks()); } executeStep(fStepIdx + 1); - } @Override diff --git a/plugins/org.eclipse.dd.tests.dsf/src/org/eclipse/dd/tests/dsf/concurrent/DsfSequenceProgressTests.java b/plugins/org.eclipse.dd.tests.dsf/src/org/eclipse/dd/tests/dsf/concurrent/DsfSequenceProgressTests.java index c0cdcb4d309..2d1d1ece7e5 100644 --- a/plugins/org.eclipse.dd.tests.dsf/src/org/eclipse/dd/tests/dsf/concurrent/DsfSequenceProgressTests.java +++ b/plugins/org.eclipse.dd.tests.dsf/src/org/eclipse/dd/tests/dsf/concurrent/DsfSequenceProgressTests.java @@ -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.
- *
- * 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.
+ *
+ * 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.
+ *
+ * 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.
+ */ 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);