@@ -22,6 +22,8 @@ import java.awt.FlowLayout
2222import java.awt.GridBagConstraints
2323import java.awt.GridBagLayout
2424import java.awt.Insets
25+ import java.awt.event.ActionEvent
26+ import java.awt.event.ActionListener
2527import java.awt.event.FocusEvent
2628import java.awt.event.FocusListener
2729import java.text.DecimalFormat
@@ -36,19 +38,27 @@ import javax.swing.JTable
3638import javax.swing.JTextArea
3739import javax.swing.JTextField
3840import javax.swing.SwingConstants
41+ import javax.swing.border.LineBorder
3942import javax.swing.event.ListSelectionEvent
4043import javax.swing.event.ListSelectionListener
4144import javax.swing.plaf.basic.BasicProgressBarUI
4245import javax.swing.table.DefaultTableCellRenderer
46+ import oracle.javatools.ui.table.ToolbarButton
4347import org.utplsql.sqldev.model.LimitedLinkedHashMap
4448import org.utplsql.sqldev.model.runner.Run
4549import org.utplsql.sqldev.resources.UtplsqlResources
50+ import org.utplsql.sqldev.runner.UtplsqlRunner
51+ import org.utplsql.sqldev.runner.UtplsqlWorksheetRunner
4652
47- class RunnerPanel implements FocusListener {
53+ class RunnerPanel implements FocusListener , ActionListener {
4854 static val GREEN = new Color (0 , 153 , 0 )
4955 static val RED = new Color (153 , 0 , 0 )
5056 LimitedLinkedHashMap<String , Run > runs = new LimitedLinkedHashMap<String , Run > (10 )
57+ Run currentRun
5158 JPanel basePanel
59+ ToolbarButton refreshButton
60+ ToolbarButton rerunButton
61+ ToolbarButton rerunWorksheetButton
5262 JLabel statusLabel
5363 JLabel testCounterValueLabel
5464 JLabel errorCounterValueLabel
@@ -80,10 +90,8 @@ class RunnerPanel implements FocusListener {
8090 }
8191 return basePanel
8292 }
83-
84- def setModel (Run run ) {
85- runs. put(run. reporterId, run)
86- testOverviewTableModel. model = run. tests
93+
94+ private def resetDerived () {
8795 testOverviewTable. rowSorter. sortKeys = null
8896 testIdTextArea. text = null
8997 testOwnerTextField. text = null
@@ -99,6 +107,13 @@ class RunnerPanel implements FocusListener {
99107 testWarningsTextArea. text = null
100108 testServerOutputTextArea. text = null
101109 }
110+
111+ def setModel (Run run ) {
112+ runs. put(run. reporterId, run)
113+ currentRun = run
114+ testOverviewTableModel. model = run. tests
115+ resetDerived
116+ }
102117
103118 def update (String reporterId ) {
104119 val run = runs. get(reporterId)
@@ -172,6 +187,20 @@ class RunnerPanel implements FocusListener {
172187 testErrorStackTextArea. caret. visible = false
173188 }
174189 }
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+ }
175204
176205 private static def formatDateTime (String dateTime ) {
177206 if (dateTime == = null ) {
@@ -300,17 +329,47 @@ class RunnerPanel implements FocusListener {
300329 groupPanel. preferredSize = dim
301330 return groupPanel
302331 }
303-
332+
304333 private def initializeGUI () {
305334 // Base panel containing all components
306335 basePanel = new JPanel ()
307336 basePanel. setLayout(new GridBagLayout ())
308337 var GridBagConstraints c = new GridBagConstraints ()
309338
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+
310369 // Status line
311370 statusLabel = new JLabel
312371 c. gridx = 0
313- c. gridy = 0
372+ c. gridy = 1
314373 c. gridwidth = 1
315374 c. gridheight = 1
316375 c. insets = new Insets (10 , 10 , 10 , 10 ) // top, left, bottom, right
@@ -355,7 +414,7 @@ class RunnerPanel implements FocusListener {
355414 counterPanel. add(makeLabelledCounterComponent(infoCounterLabel, infoCounterValueLabel))
356415 // - add everything to basePanel
357416 c. gridx = 0
358- c. gridy = 1
417+ c. gridy = 2
359418 c. gridwidth = 1
360419 c. gridheight = 1
361420 c. insets = new Insets (5 , 0 , 5 , 0 ) // top, left, bottom, right
@@ -374,7 +433,7 @@ class RunnerPanel implements FocusListener {
374433 progressBar. foreground = GREEN
375434 progressBar. UI = new BasicProgressBarUI
376435 c. gridx = 0
377- c. gridy = 2
436+ c. gridy = 3
378437 c. gridwidth = 1
379438 c. gridheight = 1
380439 c. insets = new Insets (10 , 10 , 10 , 10 ) // top, left, bottom, right
@@ -775,7 +834,7 @@ class RunnerPanel implements FocusListener {
775834 val horizontalSplitPane = new JSplitPane (SwingConstants . HORIZONTAL , testOverviewScrollPane, testDetailTabbedPane)
776835 horizontalSplitPane. resizeWeight = 0.5
777836 c. gridx = 0
778- c. gridy = 3
837+ c. gridy = 4
779838 c. gridwidth = 1
780839 c. gridheight = 1
781840 c. insets = new Insets (10 , 10 , 10 , 10 ) // top, left, bottom, right
@@ -784,6 +843,5 @@ class RunnerPanel implements FocusListener {
784843 c. weightx = 1
785844 c. weighty = 1
786845 basePanel. add(horizontalSplitPane, c)
787- }
788-
846+ }
789847}
0 commit comments