Skip to content

Commit 0ca9c45

Browse files
apply preferences for showNumberOfRunsInHistory and showTestDescription
1 parent 8afeb66 commit 0ca9c45

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
9898
JTable testOverviewTable
9999
JMenuItem testOverviewRunMenuItem
100100
JMenuItem testOverviewRunWorksheetMenuItem
101+
JCheckBoxMenuItem showTestDescriptionCheckBoxMenuItem
101102
JCheckBoxMenuItem showWarningIndicatorCheckBoxMenuItem
102103
JCheckBoxMenuItem showInfoIndicatorCheckBoxMenuItem
103104
JCheckBoxMenuItem syncDetailTabCheckBoxMenuItem
@@ -157,6 +158,16 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
157158
}
158159
}
159160

161+
private def applyShowNumberOfRunsInHistory(int maxRuns) {
162+
if (maxRuns != runs.maxEntries) {
163+
val newRuns = new LimitedLinkedHashMap<String, Run>(maxRuns)
164+
for (entry : runs.entrySet) {
165+
newRuns.put(entry.key, entry.value)
166+
}
167+
runs = newRuns
168+
}
169+
}
170+
160171
private def applyShowDisabledCounter(boolean show) {
161172
disabledCounterValueLabel.parent.visible = showDisabledCounterCheckBoxMenuItem.selected
162173
}
@@ -168,6 +179,13 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
168179
private def applyShowInfoCounter(boolean show) {
169180
infoCounterValueLabel.parent.visible = showInfoCounterCheckBoxMenuItem.selected
170181
}
182+
183+
private def applyShowTestDescription(boolean show) {
184+
testOverviewTableModel.updateModel(showTestDescriptionCheckBoxMenuItem.selected)
185+
val idColumn = testOverviewTable.columnModel.getColumn(3)
186+
idColumn.headerValue = testOverviewTableModel.testIdColumnName
187+
testOverviewTable.tableHeader.repaint
188+
}
171189

172190
private def applyShowWarningIndicator(boolean show) {
173191
val col = testOverviewTable.columnModel.getColumn(1)
@@ -300,6 +318,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
300318

301319
private def applyPreferences() {
302320
val PreferenceModel preferences = preferenceModel
321+
applyShowNumberOfRunsInHistory(preferences.numberOfRunsInHistory)
303322
showDisabledCounterCheckBoxMenuItem.selected = preferences.showDisabledCounter
304323
applyShowDisabledCounter(showDisabledCounterCheckBoxMenuItem.selected)
305324
fixCheckBoxMenuItem(showDisabledCounterCheckBoxMenuItem)
@@ -309,6 +328,9 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
309328
showInfoCounterCheckBoxMenuItem.selected = preferences.showInfoCounter
310329
applyShowInfoCounter(showInfoCounterCheckBoxMenuItem.selected)
311330
fixCheckBoxMenuItem(showInfoCounterCheckBoxMenuItem)
331+
showTestDescriptionCheckBoxMenuItem.selected = preferences.showTestDescription
332+
applyShowTestDescription(showTestDescriptionCheckBoxMenuItem.selected)
333+
fixCheckBoxMenuItem(showTestDescriptionCheckBoxMenuItem)
312334
showWarningIndicatorCheckBoxMenuItem.selected = preferences.showWarningIndicator
313335
applyShowWarningIndicator(showWarningIndicatorCheckBoxMenuItem.selected)
314336
fixCheckBoxMenuItem(showWarningIndicatorCheckBoxMenuItem)
@@ -328,7 +350,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
328350
private def setCurrentRun(Run run) {
329351
if (run !== currentRun) {
330352
currentRun = run
331-
testOverviewTableModel.model = run.tests
353+
testOverviewTableModel.setModel(run.tests, showTestDescriptionCheckBoxMenuItem.selected)
332354
resetDerived
333355
val item = new ComboBoxItem<String, String>(currentRun.reporterId, currentRun.name)
334356
runComboBox.selectedItem = item
@@ -451,6 +473,9 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
451473
} else if (e.source == showInfoCounterCheckBoxMenuItem) {
452474
applyShowInfoCounter(showInfoCounterCheckBoxMenuItem.selected)
453475
fixCheckBoxMenuItem(showInfoCounterCheckBoxMenuItem)
476+
} else if (e.source == showTestDescriptionCheckBoxMenuItem) {
477+
applyShowTestDescription(showTestDescriptionCheckBoxMenuItem.selected)
478+
fixCheckBoxMenuItem(showTestDescriptionCheckBoxMenuItem)
454479
} else if (e.source == showWarningIndicatorCheckBoxMenuItem) {
455480
applyShowWarningIndicator(showWarningIndicatorCheckBoxMenuItem.selected)
456481
fixCheckBoxMenuItem(showWarningIndicatorCheckBoxMenuItem)
@@ -870,6 +895,9 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
870895
testOverviewRunWorksheetMenuItem.addActionListener(this)
871896
testOverviewPopupMenu.add(testOverviewRunWorksheetMenuItem)
872897
testOverviewPopupMenu.add(new JSeparator)
898+
showTestDescriptionCheckBoxMenuItem = new JCheckBoxMenuItem(UtplsqlResources.getString("PREF_SHOW_TEST_DESCRIPTION_LABEL").replace("?",""), true)
899+
showTestDescriptionCheckBoxMenuItem.addActionListener(this)
900+
testOverviewPopupMenu.add(showTestDescriptionCheckBoxMenuItem)
873901
showWarningIndicatorCheckBoxMenuItem = new JCheckBoxMenuItem(UtplsqlResources.getString("PREF_SHOW_WARNING_INDICATOR_LABEL").replace("?",""), true)
874902
showWarningIndicatorCheckBoxMenuItem.addActionListener(this)
875903
testOverviewPopupMenu.add(showWarningIndicatorCheckBoxMenuItem)

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,47 @@ class TestOverviewTableModel extends DefaultTableModel {
2626
LinkedHashMap<String, Test> tests
2727
String commonPrefix
2828
boolean commonPrefixCalculated
29+
boolean showDescription
2930

3031
new() {
3132
super()
3233
}
3334

3435
private def calcCommonPrefix() {
35-
if (!commonPrefixCalculated && tests.size > 0) {
36+
if (!commonPrefixCalculated && tests !== null && tests.size > 0) {
3637
this.commonPrefix = PrefixTools.commonPrefix(tests.keySet.toList)
3738
fireTableDataChanged()
3839
commonPrefixCalculated = true
3940
}
4041
}
4142

42-
def setModel(LinkedHashMap<String, Test> tests) {
43+
def setModel(LinkedHashMap<String, Test> tests, boolean showDescription) {
4344
commonPrefixCalculated = false
4445
this.tests = tests
46+
this.showDescription = showDescription
4547
calcCommonPrefix
4648
fireTableDataChanged()
4749
}
4850

51+
def updateModel(boolean showDescription) {
52+
this.showDescription = showDescription
53+
fireTableDataChanged()
54+
}
55+
4956
def getTestIdColumnName() {
5057
calcCommonPrefix
5158
if (commonPrefix === null || commonPrefix == "") {
52-
return UtplsqlResources.getString("RUNNER_TEST_ID_COLUMN")
59+
if (showDescription) {
60+
UtplsqlResources.getString("RUNNER_DESCRIPTION_LABEL")
61+
} else {
62+
UtplsqlResources.getString("RUNNER_TEST_ID_COLUMN")
63+
}
5364
} else {
54-
commonPrefix
65+
if (showDescription) {
66+
'''«UtplsqlResources.getString("RUNNER_DESCRIPTION_LABEL")» («commonPrefix»)'''
67+
} else {
68+
commonPrefix
69+
}
5570
}
5671
}
5772

@@ -88,7 +103,11 @@ class TestOverviewTableModel extends DefaultTableModel {
88103
return test.infoIcon
89104
}
90105
case 3: {
91-
return test.id.substring(if(commonPrefix === null) {0} else {commonPrefix.length})
106+
return if(showDescription && test.description !== null) {
107+
test.description
108+
} else {
109+
test.id.substring(if(commonPrefix === null) {0} else {commonPrefix.length})
110+
}
92111
}
93112
case 4: {
94113
return test.executionTime
@@ -100,7 +119,7 @@ class TestOverviewTableModel extends DefaultTableModel {
100119
}
101120

102121
override getColumnName(int col) {
103-
return #["", "", "", UtplsqlResources.getString("RUNNER_TEST_ID_COLUMN"),
122+
return #["", "", "", UtplsqlResources.getString(if (showDescription) {"RUNNER_DESCRIPTION_LABEL"} else {"RUNNER_TEST_ID_COLUMN"}),
104123
UtplsqlResources.getString("RUNNER_TEST_EXECUTION_TIME_COLUMN")].get(col)
105124
}
106125

0 commit comments

Comments
 (0)