1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 10:25:32 +02:00

[251806] Applied additional changes based on review feedback.

This commit is contained in:
Pawel Piech 2008-11-13 21:29:42 +00:00
parent a3e5c5fbd5
commit 3fcf9b5042
2 changed files with 31 additions and 25 deletions

View file

@ -71,7 +71,7 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
public Sequence getSequence() { return fSequence; } 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. * work in this method.
* @param rm Result token to submit to executor when step is finished. * @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 * A step that will report execution progress by itself on the progress
* monitor of the owner sequence.<br> * monitor of the owner sequence.<br>
* <br> * <br>
* Note we don't offer a rollBack(rm, pm) as we don't want end user to be * Note we don't offer a rollBack(RequestMonitor, IProgressMonitor) as we
* able to cancel the rollback. * don't want end user to be able to cancel the rollback.
* *
* @since 1.1 * @since 1.1
*/ */
@ -210,7 +210,7 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
* @since 1.1 * @since 1.1
*/ */
public Sequence(DsfExecutor executor, IProgressMonitor pm, String taskName, String rollbackTaskName) { 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 * @deprecated This constructor should not be used because it creates a
* potential ambiguity when one of the two monitors is canceled. * potential ambiguity when one of the two monitors is canceled.
*/ */
@Deprecated
public Sequence(DsfExecutor executor, IProgressMonitor pm, String taskName, String rollbackTaskName, RequestMonitor rm) { public Sequence(DsfExecutor executor, IProgressMonitor pm, String taskName, String rollbackTaskName, RequestMonitor rm) {
fExecutor = executor; fExecutor = executor;
fProgressMonitor = pm; fProgressMonitor = pm;
@ -405,7 +406,6 @@ abstract public class Sequence extends DsfRunnable implements Future<Object> {
fProgressMonitor.worked(getSteps()[fStepIdx].getTicks()); fProgressMonitor.worked(getSteps()[fStepIdx].getTicks());
} }
executeStep(fStepIdx + 1); executeStep(fStepIdx + 1);
} }
@Override @Override

View file

@ -62,11 +62,9 @@ public class DsfSequenceProgressTests {
class SleepStep extends Sequence.Step { class SleepStep extends Sequence.Step {
final int STEP_TIME = 5; // seconds
@Override @Override
public int getTicks() { public int getTicks() {
return STEP_TIME; return 3;
} }
@Override public void execute(RequestMonitor requestMonitor) { @Override public void execute(RequestMonitor requestMonitor) {
@ -89,22 +87,21 @@ public class DsfSequenceProgressTests {
class SleepStepWithProgress extends Sequence.StepWithProgress { class SleepStepWithProgress extends Sequence.StepWithProgress {
final int STEP_TIME = 5; // seconds
@Override @Override
public int getTicks() { public int getTicks() {
return STEP_TIME; return 12;
} }
@Override @Override
public void execute(RequestMonitor rm, IProgressMonitor pm) { public void execute(RequestMonitor rm, IProgressMonitor pm) {
stepCounter.fInteger++; stepCounter.fInteger++;
pm.beginTask("", getTicks()); // step has its own sub-progress ticks.
pm.beginTask(getTaskName() + ": ", 6);
sleep(getTicks(), rm, pm); sleep(6, rm, pm);
rm.done(); rm.done();
pm.done();
} }
@Override @Override
@ -119,16 +116,22 @@ public class DsfSequenceProgressTests {
@Test @Test
/** /**
* Run this as a JUnit plugin test. * It's better to run this as a manual interactive test. Run this as a JUnit
* In the test workbench, watch the progress bar in the Progress View. * plugin test.<br>
* During execution of a StepWithProgress, you should see the progress bar * <br>
* is growing and you can have more responsive cancel. Meanwhile, during execution * In the test workbench, watch the progress bar in the Progress View.<br>
* of a step without progress, you should see that progress bar does not * <br>
* grow and cancel does not work until end of the step. <br> * During execution of a StepWithProgress, you should see the progress bar
* <br> * is growing and you can have more responsive cancel.<br>
* Also watch that when you cancel the progress bar during the execution of the * <br>
* sequence, you should see that "rollback" starts to happen. * 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 { public void sequenceProgressTest() throws InterruptedException, ExecutionException {
final Sequence.Step[] steps = new Sequence.Step[] { final Sequence.Step[] steps = new Sequence.Step[] {
@ -219,7 +222,10 @@ public class DsfSequenceProgressTests {
private static void sleep(int seconds, RequestMonitor rm, IProgressMonitor pm) { private static void sleep(int seconds, RequestMonitor rm, IProgressMonitor pm) {
try { try {
for (int i = 0; i < seconds; i++) { for (int i = 0; i < seconds; i++) {
Thread.sleep(1000); if (pm != null)
pm.subTask("subStep - " + (i+1));
Thread.sleep(1000);
if (pm != null) { if (pm != null) {
pm.worked(1); pm.worked(1);