24
24
public class StepSequence
25
25
{
26
26
private String title ;
27
+ private boolean isExecuting ; //Ew. Let's fix this later. Temp fix for shortcuts.
27
28
private VariableManager globalVariablesManager ;
28
29
private Vector <Step > steps ;
29
30
private final ArrayList <StepListener > stepListeners ;
@@ -42,50 +43,56 @@ public StepSequence(){
42
43
}
43
44
44
45
public void executeBlocking (){
45
- synchronized (StepSequence .this ) {
46
- StepSequenceTab tabUI = Stepper .getUI ().getTabForStepManager (this );
47
- SequenceContainer sequenceContainer = tabUI .getStepsContainer ();
48
-
49
- for (SequenceExecutionListener stepListener : this .sequenceExecutionListeners ) {
50
- stepListener .beforeSequenceStart (this .steps );
51
- }
52
- for (Step step : this .steps ) {
53
- //Since we can't add a listener to the messageEditors, we must update
54
- //Our request content before executing instead :(
55
- StepPanel panel = sequenceContainer .getPanelForStep (step );
56
- step .setRequestBody (panel .getRequestEditor ().getMessage ());
57
-
58
- if (!step .isReadyToExecute ()){
59
- JOptionPane .showMessageDialog (null , "One or more steps are incomplete." );
60
- for (SequenceExecutionListener stepExecutionListener : this .sequenceExecutionListeners ) {
61
- stepExecutionListener .afterSequenceEnd (false );
62
- }
63
- return ;
46
+ if (this .isExecuting ) return ; //Sequence already being executed.
47
+ this .isExecuting = true ;
48
+ try {
49
+ synchronized (StepSequence .this ) {
50
+ StepSequenceTab tabUI = Stepper .getUI ().getTabForStepManager (this );
51
+ SequenceContainer sequenceContainer = tabUI .getStepsContainer ();
52
+
53
+ for (SequenceExecutionListener stepListener : this .sequenceExecutionListeners ) {
54
+ stepListener .beforeSequenceStart (this .steps );
64
55
}
65
- }
66
-
67
- boolean sequenceSuccess = false ;
68
- try {
69
56
for (Step step : this .steps ) {
70
- //Set step panel as selected panel
57
+ //Since we can't add a listener to the messageEditors, we must update
58
+ //Our request content before executing instead :(
71
59
StepPanel panel = sequenceContainer .getPanelForStep (step );
72
- sequenceContainer .setActivePanel (panel );
73
- List <StepVariable > rollingReplacements = this .getRollingVariablesUpToStep (step );
60
+ step .setRequestBody (panel .getRequestEditor ().getMessage ());
61
+
62
+ if (!step .isReadyToExecute ()) {
63
+ JOptionPane .showMessageDialog (null , "One or more steps are incomplete." );
64
+ for (SequenceExecutionListener stepExecutionListener : this .sequenceExecutionListeners ) {
65
+ stepExecutionListener .afterSequenceEnd (false );
66
+ }
67
+ return ;
68
+ }
69
+ }
74
70
75
- //Execute the step
76
- StepExecutionInfo stepExecutionInfo = step .executeStep (rollingReplacements );
77
- this .sequenceExecutionListeners .forEach (listener -> listener .sequenceStepExecuted (stepExecutionInfo ));
71
+ boolean sequenceSuccess = false ;
72
+ try {
73
+ for (Step step : this .steps ) {
74
+ //Set step panel as selected panel
75
+ StepPanel panel = sequenceContainer .getPanelForStep (step );
76
+ sequenceContainer .setActivePanel (panel );
77
+ List <StepVariable > rollingReplacements = this .getRollingVariablesUpToStep (step );
78
+
79
+ //Execute the step
80
+ StepExecutionInfo stepExecutionInfo = step .executeStep (rollingReplacements );
81
+ this .sequenceExecutionListeners .forEach (listener -> listener .sequenceStepExecuted (stepExecutionInfo ));
82
+ }
83
+ sequenceSuccess = true ;
84
+ } catch (SequenceCancelledException e ) {
85
+ //User cancelled. Ignore it.
86
+ } catch (SequenceExecutionException e ) {
87
+ JOptionPane .showMessageDialog (Stepper .getUI ().getUiComponent (), e .getMessage (),
88
+ "Sequence Stopped" , JOptionPane .ERROR_MESSAGE );
89
+ }
90
+ for (SequenceExecutionListener stepLExecutionistener : sequenceExecutionListeners ) {
91
+ stepLExecutionistener .afterSequenceEnd (sequenceSuccess );
78
92
}
79
- sequenceSuccess = true ;
80
- }catch (SequenceCancelledException e ){
81
- //User cancelled. Ignore it.
82
- }catch (SequenceExecutionException e ){
83
- JOptionPane .showMessageDialog (Stepper .getUI ().getUiComponent (), e .getMessage (),
84
- "Sequence Stopped" , JOptionPane .ERROR_MESSAGE );
85
- }
86
- for (SequenceExecutionListener stepLExecutionistener : sequenceExecutionListeners ) {
87
- stepLExecutionistener .afterSequenceEnd (sequenceSuccess );
88
93
}
94
+ }finally {
95
+ this .isExecuting = false ;
89
96
}
90
97
}
91
98
0 commit comments