@@ -22,6 +22,8 @@ import java.awt.FlowLayout
22
22
import java.awt.GridBagConstraints
23
23
import java.awt.GridBagLayout
24
24
import java.awt.Insets
25
+ import java.awt.event.ActionEvent
26
+ import java.awt.event.ActionListener
25
27
import java.awt.event.FocusEvent
26
28
import java.awt.event.FocusListener
27
29
import java.text.DecimalFormat
@@ -36,19 +38,27 @@ import javax.swing.JTable
36
38
import javax.swing.JTextArea
37
39
import javax.swing.JTextField
38
40
import javax.swing.SwingConstants
41
+ import javax.swing.border.LineBorder
39
42
import javax.swing.event.ListSelectionEvent
40
43
import javax.swing.event.ListSelectionListener
41
44
import javax.swing.plaf.basic.BasicProgressBarUI
42
45
import javax.swing.table.DefaultTableCellRenderer
46
+ import oracle.javatools.ui.table.ToolbarButton
43
47
import org.utplsql.sqldev.model.LimitedLinkedHashMap
44
48
import org.utplsql.sqldev.model.runner.Run
45
49
import org.utplsql.sqldev.resources.UtplsqlResources
50
+ import org.utplsql.sqldev.runner.UtplsqlRunner
51
+ import org.utplsql.sqldev.runner.UtplsqlWorksheetRunner
46
52
47
- class RunnerPanel implements FocusListener {
53
+ class RunnerPanel implements FocusListener , ActionListener {
48
54
static val GREEN = new Color (0 , 153 , 0 )
49
55
static val RED = new Color (153 , 0 , 0 )
50
56
LimitedLinkedHashMap<String , Run > runs = new LimitedLinkedHashMap<String , Run > (10 )
57
+ Run currentRun
51
58
JPanel basePanel
59
+ ToolbarButton refreshButton
60
+ ToolbarButton rerunButton
61
+ ToolbarButton rerunWorksheetButton
52
62
JLabel statusLabel
53
63
JLabel testCounterValueLabel
54
64
JLabel errorCounterValueLabel
@@ -80,10 +90,8 @@ class RunnerPanel implements FocusListener {
80
90
}
81
91
return basePanel
82
92
}
83
-
84
- def setModel (Run run ) {
85
- runs. put(run. reporterId, run)
86
- testOverviewTableModel. model = run. tests
93
+
94
+ private def resetDerived () {
87
95
testOverviewTable. rowSorter. sortKeys = null
88
96
testIdTextArea. text = null
89
97
testOwnerTextField. text = null
@@ -99,6 +107,13 @@ class RunnerPanel implements FocusListener {
99
107
testWarningsTextArea. text = null
100
108
testServerOutputTextArea. text = null
101
109
}
110
+
111
+ def setModel (Run run ) {
112
+ runs. put(run. reporterId, run)
113
+ currentRun = run
114
+ testOverviewTableModel. model = run. tests
115
+ resetDerived
116
+ }
102
117
103
118
def update (String reporterId ) {
104
119
val run = runs. get(reporterId)
@@ -172,6 +187,20 @@ class RunnerPanel implements FocusListener {
172
187
testErrorStackTextArea. caret. visible = false
173
188
}
174
189
}
190
+
191
+ override actionPerformed (ActionEvent e ) {
192
+ if (e. source == refreshButton) {
193
+ resetDerived
194
+ testDetailTabbedPane. selectedIndex = 0
195
+ testOverviewTableModel. fireTableDataChanged
196
+ } else if (e. source == rerunButton) {
197
+ val runner = new UtplsqlRunner (currentRun. pathList, currentRun. connectionName)
198
+ runner. runTestAsync
199
+ } else if (e. source == rerunWorksheetButton) {
200
+ val worksheet = new UtplsqlWorksheetRunner (currentRun. pathList, currentRun. connectionName)
201
+ worksheet. runTestAsync
202
+ }
203
+ }
175
204
176
205
private static def formatDateTime (String dateTime ) {
177
206
if (dateTime == = null ) {
@@ -300,17 +329,47 @@ class RunnerPanel implements FocusListener {
300
329
groupPanel. preferredSize = dim
301
330
return groupPanel
302
331
}
303
-
332
+
304
333
private def initializeGUI () {
305
334
// Base panel containing all components
306
335
basePanel = new JPanel ()
307
336
basePanel. setLayout(new GridBagLayout ())
308
337
var GridBagConstraints c = new GridBagConstraints ()
309
338
339
+ // Toolbar
340
+ var toolbar = new GradientToolbar
341
+ toolbar. floatable = false
342
+ toolbar. border = new LineBorder (Color . LIGHT_GRAY , 1 )
343
+ toolbar. margin = new Insets (2 , 2 , 2 , 2 )
344
+ refreshButton = new ToolbarButton (UtplsqlResources . getIcon(" REFRESH_ICON" ))
345
+ refreshButton. toolTipText = " Reset ordering and refresh"
346
+ refreshButton. addActionListener(this )
347
+ toolbar. add(refreshButton)
348
+ rerunButton = new ToolbarButton (UtplsqlResources . getIcon(" RUN_ICON" ))
349
+ rerunButton. toolTipText = " Rerun all tests"
350
+ rerunButton. addActionListener(this )
351
+ toolbar. add(rerunButton)
352
+ rerunWorksheetButton = new ToolbarButton (UtplsqlResources . getIcon(" RUN_WORKSHEET_ICON" ))
353
+ rerunWorksheetButton. toolTipText = " Rerun all tests in a new worksheet"
354
+ rerunWorksheetButton. addActionListener(this )
355
+ toolbar. add(rerunWorksheetButton)
356
+
357
+
358
+ c. gridx = 0
359
+ c. gridy = 0
360
+ c. gridwidth = 1
361
+ c. gridheight = 1
362
+ c. insets = new Insets (0 , 0 , 0 , 0 ) // top, left, bottom, right
363
+ c. anchor = GridBagConstraints :: NORTH
364
+ c. fill = GridBagConstraints :: HORIZONTAL
365
+ c. weightx = 1
366
+ c. weighty = 0
367
+ basePanel. add(toolbar, c)
368
+
310
369
// Status line
311
370
statusLabel = new JLabel
312
371
c. gridx = 0
313
- c. gridy = 0
372
+ c. gridy = 1
314
373
c. gridwidth = 1
315
374
c. gridheight = 1
316
375
c. insets = new Insets (10 , 10 , 10 , 10 ) // top, left, bottom, right
@@ -355,7 +414,7 @@ class RunnerPanel implements FocusListener {
355
414
counterPanel. add(makeLabelledCounterComponent(infoCounterLabel, infoCounterValueLabel))
356
415
// - add everything to basePanel
357
416
c. gridx = 0
358
- c. gridy = 1
417
+ c. gridy = 2
359
418
c. gridwidth = 1
360
419
c. gridheight = 1
361
420
c. insets = new Insets (5 , 0 , 5 , 0 ) // top, left, bottom, right
@@ -374,7 +433,7 @@ class RunnerPanel implements FocusListener {
374
433
progressBar. foreground = GREEN
375
434
progressBar. UI = new BasicProgressBarUI
376
435
c. gridx = 0
377
- c. gridy = 2
436
+ c. gridy = 3
378
437
c. gridwidth = 1
379
438
c. gridheight = 1
380
439
c. insets = new Insets (10 , 10 , 10 , 10 ) // top, left, bottom, right
@@ -775,7 +834,7 @@ class RunnerPanel implements FocusListener {
775
834
val horizontalSplitPane = new JSplitPane (SwingConstants . HORIZONTAL , testOverviewScrollPane, testDetailTabbedPane)
776
835
horizontalSplitPane. resizeWeight = 0.5
777
836
c. gridx = 0
778
- c. gridy = 3
837
+ c. gridy = 4
779
838
c. gridwidth = 1
780
839
c. gridheight = 1
781
840
c. insets = new Insets (10 , 10 , 10 , 10 ) // top, left, bottom, right
@@ -784,6 +843,5 @@ class RunnerPanel implements FocusListener {
784
843
c. weightx = 1
785
844
c. weighty = 1
786
845
basePanel. add(horizontalSplitPane, c)
787
- }
788
-
846
+ }
789
847
}
0 commit comments