1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-17 22:15:23 +02:00

Added ability to cancell DsfSequence using the progress monitor (bug# 159048).

This commit is contained in:
Pawel Piech 2006-10-16 07:58:52 +00:00
parent 3f86dad9d5
commit cfeb1e5d31

View file

@ -233,10 +233,36 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
* submit the next step.
*/
private void executeStep(int nextStepIndex) {
/*
* At end of each step check progress monitor to see if it's cancelled.
* If progress monitor is cancelled, mark the whole sequence as
* cancelled.
*/
if (fProgressMonitor.isCanceled()) {
cancel(false);
}
/*
* If sequence was cencelled during last step (or before the sequence
* was ever executed), start rolling back the execution.
*/
if (isCancelled()) {
cancelExecution();
} else {
if (nextStepIndex < getSteps().length) {
return;
}
/*
* Check if we've reached the last step. Note that if execution was
* cancelled during the last step (and thus the sequence is
* technically finished, since it was cancelled it will be rolled
* back.
*/
if (nextStepIndex >= getSteps().length) {
finish();
return;
}
// Proceed with executing next step.
fCurrentStepIdx = nextStepIndex;
getSteps()[fCurrentStepIdx].execute(new Done() {
final private int fStepIdx = fCurrentStepIdx;
@ -256,10 +282,6 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
return "DsfSequence \"" + fTaskName + "\", result for executing step #" + fStepIdx + " = " + getStatus();
}
});
} else {
finish();
}
}
}
/**
@ -267,7 +289,13 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
* roll back next step.
*/
private void rollBackStep(int stepIdx) {
if (stepIdx >= 0) {
// If we reach before step 0, finish roll back.
if (stepIdx < 0) {
finish();
return;
}
// Proceed with rolling back given step.
fCurrentStepIdx = stepIdx;
getSteps()[fCurrentStepIdx].rollBack(new Done() {
final private int fStepIdx = fCurrentStepIdx;
@ -288,9 +316,6 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
return "DsfSequence \"" + fTaskName + "\", result for rolling back step #" + fStepIdx + " = " + getStatus();
}
});
} else {
finish();
}
}
/**