Skip to content

Commit fc7883b

Browse files
put counters in wrap layout panel and add disabled counter
1 parent e8bacef commit fc7883b

File tree

1 file changed

+57
-64
lines changed

1 file changed

+57
-64
lines changed

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

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ package org.utplsql.sqldev.ui.runner
1818
import java.awt.Color
1919
import java.awt.Component
2020
import java.awt.Dimension
21+
import java.awt.FlowLayout
2122
import java.awt.GridBagConstraints
2223
import java.awt.GridBagLayout
2324
import java.awt.Insets
2425
import java.awt.event.FocusEvent
2526
import java.awt.event.FocusListener
2627
import java.text.DecimalFormat
28+
import javax.swing.JComponent
2729
import javax.swing.JLabel
2830
import javax.swing.JPanel
2931
import javax.swing.JProgressBar
@@ -51,6 +53,7 @@ class RunnerPanel implements FocusListener {
5153
JLabel testCounterValueLabel
5254
JLabel errorCounterValueLabel
5355
JLabel failureCounterValueLabel
56+
JLabel disabledCounterValueLabel
5457
JProgressBar progressBar;
5558
TestOverviewTableModel testOverviewTableModel
5659
JTable testOverviewTable
@@ -114,6 +117,7 @@ class RunnerPanel implements FocusListener {
114117
testCounterValueLabel.text = '''«run.totalNumberOfCompletedTests»/«run.totalNumberOfTests»'''
115118
errorCounterValueLabel.text = '''«run.counter.error»'''
116119
failureCounterValueLabel.text = '''«run.counter.failure»'''
120+
disabledCounterValueLabel.text = '''«run.counter.disabled»'''
117121
if (run.totalNumberOfTests == 0) {
118122
progressBar.value = 100
119123
} else {
@@ -227,7 +231,36 @@ class RunnerPanel implements FocusListener {
227231
label.horizontalAlignment = if (col === 2) {JLabel.RIGHT} else {JLabel.LEFT}
228232
return label
229233
}
230-
}
234+
}
235+
236+
private def makeLabelledComponent (JLabel label, JComponent comp) {
237+
val groupPanel = new JPanel
238+
groupPanel.layout = new GridBagLayout
239+
var GridBagConstraints c = new GridBagConstraints
240+
// label
241+
c.gridx = 0
242+
c.gridy = 0
243+
c.gridwidth = 1
244+
c.gridheight = 1
245+
c.insets = new Insets(5, 10, 5, 0) // top, left, bottom, right
246+
c.anchor = GridBagConstraints::WEST
247+
c.fill = GridBagConstraints::NONE
248+
c.weightx = 0
249+
c.weighty = 0
250+
groupPanel.add(label, c)
251+
// component
252+
c.gridx = 1
253+
c.gridy = 0
254+
c.gridwidth = 1
255+
c.gridheight = 1
256+
c.insets = new Insets(5, 5, 5, 10) // top, left, bottom, right
257+
c.anchor = GridBagConstraints::WEST
258+
c.fill = GridBagConstraints::NONE
259+
c.weightx = 0
260+
c.weighty = 0
261+
groupPanel.add(comp, c)
262+
return groupPanel
263+
}
231264

232265
private def initializeGUI() {
233266
// Base panel containing all components
@@ -239,7 +272,7 @@ class RunnerPanel implements FocusListener {
239272
statusLabel = new JLabel
240273
c.gridx = 0
241274
c.gridy = 0
242-
c.gridwidth = 6
275+
c.gridwidth = 1
243276
c.gridheight = 1
244277
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
245278
c.anchor = GridBagConstraints::WEST
@@ -248,80 +281,40 @@ class RunnerPanel implements FocusListener {
248281
c.weighty = 0
249282
basePanel.add(statusLabel, c)
250283

251-
// Test counter
284+
// Counters
285+
// - Test counter
286+
val counterPanel = new JPanel
287+
counterPanel.layout = new WrapLayout(FlowLayout.LEFT, 0, 0)
252288
val testCounterLabel = new JLabel(UtplsqlResources.getString("RUNNER_TESTS_LABEL") + ":",
253289
UtplsqlResources.getIcon("UTPLSQL_ICON"), JLabel::LEADING)
254-
c.gridx = 0
255-
c.gridy = 1
256-
c.gridwidth = 1
257-
c.gridheight = 1
258-
c.insets = new Insets(10, 10, 10, 5) // top, left, bottom, right
259-
c.anchor = GridBagConstraints::WEST
260-
c.fill = GridBagConstraints::NONE
261-
c.weightx = 0
262-
c.weighty = 0
263-
basePanel.add(testCounterLabel, c)
264290
testCounterValueLabel = new JLabel
265-
c.gridx = 1
266-
c.gridy = 1
267-
c.gridwidth = 1
268-
c.gridheight = 1
269-
c.insets = new Insets(10, 0, 10, 10) // top, left, bottom, right
270-
c.anchor = GridBagConstraints::WEST
271-
c.fill = GridBagConstraints::NONE
272-
c.weightx = 0
273-
c.weighty = 0
274-
basePanel.add(testCounterValueLabel, c)
275-
276-
// Failure counter
291+
counterPanel.add(makeLabelledComponent(testCounterLabel, testCounterValueLabel))
292+
// - Failure counter
277293
val failureCounterLabel = new JLabel(UtplsqlResources.getString("RUNNER_FAILURES_LABEL") + ":",
278294
UtplsqlResources.getIcon("FAILURE_ICON"), JLabel::LEADING)
279-
c.gridx = 2
280-
c.gridy = 1
281-
c.gridwidth = 1
282-
c.gridheight = 1
283-
c.insets = new Insets(10, 10, 10, 5) // top, left, bottom, right
284-
c.anchor = GridBagConstraints::WEST
285-
c.fill = GridBagConstraints::NONE
286-
c.weightx = 0
287-
c.weighty = 0
288-
basePanel.add(failureCounterLabel, c)
289295
failureCounterValueLabel = new JLabel
290-
c.gridx = 3
291-
c.gridy = 1
292-
c.gridwidth = 1
293-
c.gridheight = 1
294-
c.insets = new Insets(10, 0, 10, 10) // top, left, bottom, right
295-
c.anchor = GridBagConstraints::WEST
296-
c.fill = GridBagConstraints::NONE
297-
c.weightx = 0
298-
c.weighty = 0
299-
basePanel.add(failureCounterValueLabel, c)
300-
301-
// Error counter
296+
counterPanel.add(makeLabelledComponent(failureCounterLabel,failureCounterValueLabel))
297+
// - Error counter
302298
val errorCounterLabel = new JLabel(UtplsqlResources.getString("RUNNER_ERRORS_LABEL") + ":",
303299
UtplsqlResources.getIcon("ERROR_ICON"), JLabel::LEADING)
304-
c.gridx = 4
305-
c.gridy = 1
306-
c.gridwidth = 1
307-
c.gridheight = 1
308-
c.insets = new Insets(10, 10, 10, 5) // top, left, bottom, right
309-
c.anchor = GridBagConstraints::WEST
310-
c.fill = GridBagConstraints::NONE
311-
c.weightx = 0
312-
c.weighty = 0
313-
basePanel.add(errorCounterLabel, c)
314300
errorCounterValueLabel = new JLabel
315-
c.gridx = 5
301+
counterPanel.add(makeLabelledComponent(errorCounterLabel, errorCounterValueLabel))
302+
// - Disabled counter
303+
val disabledCounterLabel = new JLabel(UtplsqlResources.getString("RUNNER_DISABLED_LABEL") + ":",
304+
UtplsqlResources.getIcon("DISABLED_ICON"), JLabel::LEADING)
305+
disabledCounterValueLabel = new JLabel
306+
counterPanel.add(makeLabelledComponent(disabledCounterLabel, disabledCounterValueLabel))
307+
// - add everything to basePanel
308+
c.gridx = 0
316309
c.gridy = 1
317310
c.gridwidth = 1
318311
c.gridheight = 1
319-
c.insets = new Insets(10, 0, 10, 10) // top, left, bottom, right
312+
c.insets = new Insets(5, 0, 5, 0) // top, left, bottom, right
320313
c.anchor = GridBagConstraints::WEST
321-
c.fill = GridBagConstraints::NONE
322-
c.weightx = 0
314+
c.fill = GridBagConstraints::HORIZONTAL
315+
c.weightx = 1
323316
c.weighty = 0
324-
basePanel.add(errorCounterValueLabel, c)
317+
basePanel.add(counterPanel,c)
325318

326319
// Progress bar
327320
progressBar = new JProgressBar
@@ -333,7 +326,7 @@ class RunnerPanel implements FocusListener {
333326
progressBar.UI = new BasicProgressBarUI
334327
c.gridx = 0
335328
c.gridy = 2
336-
c.gridwidth = 6
329+
c.gridwidth = 1
337330
c.gridheight = 1
338331
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
339332
c.anchor = GridBagConstraints::WEST
@@ -701,7 +694,7 @@ class RunnerPanel implements FocusListener {
701694
horizontalSplitPane.resizeWeight = 0.5
702695
c.gridx = 0
703696
c.gridy = 3
704-
c.gridwidth = 6
697+
c.gridwidth = 1
705698
c.gridheight = 1
706699
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
707700
c.anchor = GridBagConstraints::WEST

0 commit comments

Comments
 (0)