@@ -99,6 +99,7 @@ public class RunnerPanel {
99
99
private Run currentRun ;
100
100
private JPanel basePanel ;
101
101
private DefaultComboBoxModel <ComboBoxItem <String , String >> runComboBoxModel ;
102
+ private ToolbarButton stopButton ;
102
103
private JComboBox <ComboBoxItem <String , String >> runComboBox ;
103
104
private JLabel statusLabel ;
104
105
private Timer elapsedTimeTimer ;
@@ -168,7 +169,7 @@ public Component getTableCellRendererComponent(final JTable table, final Object
168
169
}
169
170
}
170
171
171
- // used in mulitple components, therefore an inner class
172
+ // used in multiple components, therefore an inner class
172
173
private static class FailuresTableHeaderRenderer extends DefaultTableCellRenderer {
173
174
private static final long serialVersionUID = 5059401447983514596L ;
174
175
@@ -215,6 +216,7 @@ private void resetDerived() {
215
216
testErrorStackTextPane .setText (null );
216
217
testWarningsTextPane .setText (null );
217
218
testServerOutputTextPane .setText (null );
219
+ enableOrDisableStopButton ();
218
220
}
219
221
220
222
private void refreshRunsComboBox () {
@@ -487,8 +489,13 @@ private void showDockable() {
487
489
}
488
490
}
489
491
492
+ private void enableOrDisableStopButton () {
493
+ stopButton .setEnabled (currentRun .getEndTime () == null );
494
+ }
495
+
490
496
public synchronized void update (final String reporterId ) {
491
497
showDockable ();
498
+ enableOrDisableStopButton ();
492
499
setCurrentRun (runs .get (reporterId ));
493
500
final int row = currentRun .getCurrentTestNumber () - 1 ;
494
501
final CharSequence header = testOverviewTableModel .getTestIdColumnName ();
@@ -753,6 +760,56 @@ private void initializeGUI() {
753
760
codeCoverageButton .setBorder (buttonBorder );
754
761
codeCoverageButton .addActionListener (event -> runCodeCoverage (false ));
755
762
toolbar .add (codeCoverageButton );
763
+ stopButton = new ToolbarButton (UtplsqlResources .getIcon ("STOP_ICON" ));
764
+ stopButton .setToolTipText (UtplsqlResources .getString ("RUNNER_STOP_TOOLTIP" ));
765
+ stopButton .setBorder (buttonBorder );
766
+ stopButton .addActionListener (event -> {
767
+ if (currentRun .getConsumerConn () != null ) {
768
+ // Aborts JDBC Connection. Connection might still run in the background. That's expected.
769
+ DatabaseTools .abortConnection (currentRun .getConsumerConn ());
770
+ for (Test test : currentRun .getTests ().values ()) {
771
+ if (test .getEndTime () == null && !test .isDisabled ()) {
772
+ test .setDisabled (true );
773
+ test .getCounter ().setDisabled (1 );
774
+ test .getCounter ().setWarning (1 );
775
+ test .setWarnings (UtplsqlResources .getString ("RUNNER_STOP_TEST_MESSAGE" ));
776
+ test .setStartTime (null );
777
+ }
778
+ }
779
+ // recalculate counters and fix inconsistencies
780
+ currentRun .getCounter ().setSuccess (0 );
781
+ currentRun .getCounter ().setFailure (0 );
782
+ currentRun .getCounter ().setError (0 );
783
+ currentRun .getCounter ().setDisabled (0 );
784
+ currentRun .getCounter ().setWarning (0 );
785
+ for (Test test : currentRun .getTests ().values ()) {
786
+ if (test .isDisabled () && test .getCounter ().getDisabled () == 0 ) {
787
+ test .getCounter ().setDisabled (1 );
788
+ }
789
+ if (test .getFailedExpectations () != null && !test .getFailedExpectations ().isEmpty () && test .getCounter ().getFailure () == 0 ) {
790
+ test .getCounter ().setFailure (1 );
791
+ }
792
+ if (test .getErrorStack () != null && test .getCounter ().getError () == 0 ) {
793
+ test .getCounter ().setError (1 );
794
+ }
795
+ currentRun .getCounter ().setSuccess (currentRun .getCounter ().getSuccess () + test .getCounter ().getSuccess ());
796
+ currentRun .getCounter ().setFailure (currentRun .getCounter ().getFailure () + test .getCounter ().getFailure ());
797
+ currentRun .getCounter ().setError (currentRun .getCounter ().getError () + test .getCounter ().getError ());
798
+ currentRun .getCounter ().setDisabled (currentRun .getCounter ().getDisabled () + test .getCounter ().getDisabled ());
799
+ currentRun .getCounter ().setWarning (currentRun .getCounter ().getWarning () + test .getCounter ().getWarning ());
800
+ }
801
+ // terminate run
802
+ currentRun .setEndTime (UtplsqlRunner .getSysdate ());
803
+ double now = (double ) System .currentTimeMillis ();
804
+ currentRun .setExecutionTime ((now - currentRun .getStart ()) / 1000 );
805
+ currentRun .setCurrentTestNumber (0 );
806
+ currentRun .setStatus (UtplsqlResources .getString ("RUNNER_STOP_RUN_MESSAGE" ));
807
+ // update run in GUI
808
+ update (currentRun .getReporterId ());
809
+ }
810
+ });
811
+ stopButton .setEnabled (false );
812
+ toolbar .add (stopButton );
756
813
toolbar .add (Box .createHorizontalGlue ());
757
814
runComboBoxModel = new DefaultComboBoxModel <>();
758
815
runComboBox = new JComboBox <>(runComboBoxModel );
0 commit comments