Skip to content

Commit 1d51401

Browse files
change update interface and progressBar properties
1 parent c8a8101 commit 1d51401

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package org.utplsql.sqldev.ui.runner
1717

1818
import java.awt.Color
1919
import java.awt.Component
20+
import java.awt.Dimension
2021
import java.awt.GridBagConstraints
2122
import java.awt.GridBagLayout
2223
import java.awt.Insets
@@ -29,6 +30,8 @@ import org.utplsql.sqldev.model.runner.Run
2930
import org.utplsql.sqldev.resources.UtplsqlResources
3031

3132
class RunnerPanel {
33+
static val GREEN = new Color(0, 153, 0)
34+
static val RED = new Color(153, 0, 0)
3235
LimitedLinkedHashMap<String, Run> runs = new LimitedLinkedHashMap<String, Run>(10)
3336
JPanel basePanel
3437
JLabel statusLabel
@@ -44,35 +47,28 @@ class RunnerPanel {
4447
return basePanel
4548
}
4649

47-
def setStatus(String text) {
48-
statusLabel.text = text
49-
}
50-
5150
def setModel(Run run) {
5251
runs.put(run.reporterId, run)
5352
}
5453

55-
def updateCounter() {
56-
val run = currentRun
54+
def update(String reporterId) {
55+
val run = runs.get(reporterId)
56+
statusLabel.text = run.status
5757
testCounterValueLabel.text = '''«run.totalNumberOfCompletedTests»/«run.totalNumberOfTests»'''
5858
errorCounterValueLabel.text = '''«run.counter.error»'''
5959
failureCounterValueLabel.text = '''«run.counter.failure»'''
6060
if (run.totalNumberOfTests == 0) {
6161
progressBar.value = 100
6262
} else {
63-
progressBar.value = 100 * run.totalNumberOfCompletedTests / run.totalNumberOfTests
63+
progressBar.value = Math.round(100 * run.totalNumberOfCompletedTests / run.totalNumberOfTests)
6464
}
6565
if (run.counter.error > 0 || run.counter.failure > 0) {
66-
progressBar.foreground = Color.RED
66+
progressBar.foreground = RED
6767
} else {
68-
progressBar.foreground = Color.GREEN
68+
progressBar.foreground = GREEN
6969
}
7070
}
71-
72-
private def getCurrentRun() {
73-
return runs.values.get(runs.values.length - 1)
74-
}
75-
71+
7672
private def initializeGUI() {
7773
// Base panel containing all components
7874
basePanel = new JPanel()
@@ -169,8 +165,11 @@ class RunnerPanel {
169165

170166
// Progress bar
171167
progressBar = new JProgressBar
168+
val progressBarDim = new Dimension(10, 20)
169+
progressBar.preferredSize = progressBarDim
170+
progressBar.minimumSize = progressBarDim
172171
progressBar.stringPainted = false
173-
progressBar.foreground = Color.GREEN
172+
progressBar.foreground = GREEN
174173
progressBar.UI = new BasicProgressBarUI
175174
c.gridx = 0
176175
c.gridy = 2

0 commit comments

Comments
 (0)