Skip to content

Commit 5e49843

Browse files
add pathList to Run, required to handle reruns
1 parent e802329 commit 5e49843

File tree

3 files changed

+74
-14
lines changed

3 files changed

+74
-14
lines changed

sqldev/src/main/java/org/utplsql/sqldev/model/runner/Run.xtend

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.utplsql.sqldev.model.AbstractModel
2424
class Run extends AbstractModel {
2525
String reporterId
2626
String connectionName
27+
List<String> pathList
2728
Integer totalNumberOfTests
2829
String startTime
2930
String endTime
@@ -35,9 +36,10 @@ class Run extends AbstractModel {
3536
LinkedHashMap<String, Test> tests
3637
String status
3738

38-
new(String reporterId, String connectionName) {
39+
new(String reporterId, String connectionName, List<String> pathList) {
3940
this.reporterId = reporterId
4041
this.connectionName = connectionName
42+
this.pathList = pathList
4143
this.counter = new Counter
4244
this.tests = new LinkedHashMap<String, Test>
4345
}

sqldev/src/main/java/org/utplsql/sqldev/ui/runner/RunnerPanel.xtend

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import java.awt.FlowLayout
2222
import java.awt.GridBagConstraints
2323
import java.awt.GridBagLayout
2424
import java.awt.Insets
25+
import java.awt.event.ActionEvent
26+
import java.awt.event.ActionListener
2527
import java.awt.event.FocusEvent
2628
import java.awt.event.FocusListener
2729
import java.text.DecimalFormat
@@ -36,19 +38,27 @@ import javax.swing.JTable
3638
import javax.swing.JTextArea
3739
import javax.swing.JTextField
3840
import javax.swing.SwingConstants
41+
import javax.swing.border.LineBorder
3942
import javax.swing.event.ListSelectionEvent
4043
import javax.swing.event.ListSelectionListener
4144
import javax.swing.plaf.basic.BasicProgressBarUI
4245
import javax.swing.table.DefaultTableCellRenderer
46+
import oracle.javatools.ui.table.ToolbarButton
4347
import org.utplsql.sqldev.model.LimitedLinkedHashMap
4448
import org.utplsql.sqldev.model.runner.Run
4549
import 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
}

sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerPanelTest.xtend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class UtplsqlRunnerPanelTest {
3131
@Before
3232
def void setup() {
3333
val reporterId = UUID.randomUUID().toString.replace("-", "")
34-
run = new Run(null, reporterId)
34+
run = new Run(null, reporterId, #[])
3535
run.startTime = "2019-06-09T13:42:42.123456"
3636
run.counter.disabled = 0
3737
run.counter.success = 0

0 commit comments

Comments
 (0)