8000 refactor, simplify · utPLSQL/utPLSQL-SQLDeveloper@4734c40 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4734c40

Browse files
refactor, simplify
1 parent 5006b7c commit 4734c40

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

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

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import javax.swing.LookAndFeel;
5555
import javax.swing.RepaintManager;
5656
import javax.swing.RowFilter;
57-
import javax.swing.SwingConstants;
5857
import javax.swing.Timer;
5958
import javax.swing.UIManager;
6059
import javax.swing.border.Border;
@@ -139,7 +138,7 @@ public class RunnerPanel {
139138
private JTabbedPane testDetailTabbedPane;
140139

141140
// used in multiple components, therefore an inner class
142-
private class TestTableHeaderRenderer extends DefaultTableCellRenderer {
141+
private static class TestTableHeaderRenderer extends DefaultTableCellRenderer {
143142
private static final long serialVersionUID = 6295858563570577027L;
144143

145144
@Override
@@ -169,7 +168,7 @@ public Component getTableCellRendererComponent(final JTable table, final Object
169168
}
170169

171170
// used in mulitple components, therefore an inner class
172-
private class FailuresTableHeaderRenderer extends DefaultTableCellRenderer {
171+
private static class FailuresTableHeaderRenderer extends DefaultTableCellRenderer {
173172
private static final long serialVersionUID = 5059401447983514596L;
174173

175174
@Override
@@ -262,8 +261,7 @@ private void applyShowTestDescription() {
262261
testOverviewTable.getTableHeader().repaint();
263262
}
264263

265-
private void applyShowWarningIndicator(final boolean show) {
266-
final TableColumn col = testOverviewTable.getColumnModel().getColumn(1);
264+
private void showColumn(final boolean show, TableColumn col) {
267265
if (show) {
268266
col.setWidth(INDICATOR_WIDTH);
269267
col.setMinWidth(INDICATOR_WIDTH);
@@ -277,25 +275,19 @@ private void applyShowWarningIndicator(final boolean show) {
277275
}
278276
}
279277

278+
private void applyShowWarningIndicator(final boolean show) {
279+
showColumn(show, testOverviewTable.getColumnModel().getColumn(1));
280+
}
281+
280282
private void applyShowInfoIndicator(final boolean show) {
281-
final TableColumn col = testOverviewTable.getColumnModel().getColumn(2);
282-
if (show) {
283-
col.setWidth(INDICATOR_WIDTH);
284-
col.setMinWidth(INDICATOR_WIDTH);
285-
col.setMaxWidth(INDICATOR_WIDTH);
286-
col.setPreferredWidth(INDICATOR_WIDTH);
287-
} else {
288-
col.setWidth(0);
289-
col.setMinWidth(0);
290-
col.setMaxWidth(0);
291-
col.setPreferredWidth(0);
292-
}
283+
showColumn(show, testOverviewTable.getColumnModel().getColumn(2));
293284
}
294285

295286
private void applyFilter(final boolean showSuccessfulTests, final boolean showDisabledTests) {
296287
@SuppressWarnings("unchecked")
297288
final TableRowSorter<TestOverviewTableModel> sorter = ((TableRowSorter<TestOverviewTableModel>) testOverviewTable.getRowSorter());
298289
final RowFilter<TestOverviewTableModel, Integer> filter = new RowFilter<TestOverviewTableModel, Integer>() {
290+
@SuppressWarnings("RedundantIfStatement")
299291
@Override
300292
public boolean include(final RowFilter.Entry<? extends TestOverviewTableModel, ? extends Integer> entry) {
301293
final Test test = entry.getModel().getTest((entry.getIdentifier()).intValue());
@@ -348,6 +340,7 @@ private void openSelectedFailure() {
348340
}
349341
}
350342

343+
@SuppressWarnings("StringBufferReplaceableByString")
351344
private String getHtml(final String text) {
352345
StringBuilder sb = new StringBuilder();
353346
sb.append("<html>\n");
@@ -384,6 +377,7 @@ private void openLink(final String link) {
384377
openEditor(ownerName, objectType, objectName.toUpperCase(), line, 1);
385378
}
386379

380+
@SuppressWarnings("SameParameterValue")
387381
private void openEditor(final String owner, final String type, final String name, final int line, final int col) {
388382
DefaultDrillLink drillLink = new DefaultDrillLink();
389383
drillLink.setConnName(currentRun.getConnectionName());
@@ -417,14 +411,12 @@ private void syncDetailTab() {
417411
}
418412

419413
private PreferenceModel getPreferenceModel() {
420-
PreferenceModel preferences = null;
421414
try {
422-
preferences = PreferenceModel.getInstance(Preferences.getPreferences());
415+
return PreferenceModel.getInstance(Preferences.getPreferences());
423416
} catch (NoClassDefFoundError e) {
424417
// running outside of SQL Developer
425-
preferences = PreferenceModel.getInstance(null);
418+
return PreferenceModel.getInstance(null);
426419
}
427-
return preferences;
428420
}
429421

430422
private void applyPreferences() {
@@ -579,9 +571,11 @@ private void comboBoxAction() {
579571
@SuppressWarnings("unchecked")
580572
final ComboBoxItem<String, String> comboBoxItem = (ComboBoxItem<String, String>) runComboBox
581573
.getSelectedItem();
582-
if (currentRun.getReporterId() != null && !currentRun.getReporterId().equals(comboBoxItem.getKey())) {
583-
update(comboBoxItem.getKey());
584-
testDetailTabbedPane.setSelectedIndex(0);
574+
if (currentRun.getReporterId() != null && comboBoxItem != null) {
575+
if (!currentRun.getReporterId().equals(comboBoxItem.getKey())) {
576+
update(comboBoxItem.getKey());
577+
testDetailTabbedPane.setSelectedIndex(0);
578+
}
585579
}
586580
}
587581
}
@@ -706,6 +700,7 @@ private void runCodeCoverage(boolean selectedOnly) {
706700
reporter.showParameterWindow();
< 9E88 /code>
707701
}
708702

703+
@SuppressWarnings("DuplicatedCode")
709704
private void initializeGUI() {
710705
// Base panel containing all components
711706
basePanel = new JPanel();
@@ -809,8 +804,8 @@ private void initializeGUI() {
809804
time.setSeconds(currentRun.getExecutionTime());
810805
elapsedTimeTimer.stop();
811806
} else {
812-
final Double now = Double.valueOf(System.currentTimeMillis());
813-
time.setSeconds(Double.valueOf(now - currentRun.getStart()) / 1000);
807+
final Double now = (double) System.currentTimeMillis();
808+
time.setSeconds((now - currentRun.getStart()) / 1000);
814809
}
815810
elapsedTimeLabel.setText(time.toString() + (!useSmartTimes ? " s" : ""));
816811
} else {
@@ -1273,7 +1268,7 @@ public void mouseClicked(final MouseEvent e) {
12731268
c.weighty = 6;
12741269

12751270
// - split pane
1276-
final JSplitPane failuresSplitPane = new JSplitPane(SwingConstants.HORIZONTAL, failuresTableScrollPane,
1271+
final JSplitPane failuresSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, failuresTableScrollPane,
12771272
testFailureMessageScrollPane);
12781273
failuresSplitPane.setResizeWeight(0.2);
12791274

@@ -1355,7 +1350,7 @@ public void mouseClicked(final MouseEvent e) {
13551350
testDetailTabbedPane.add(UtplsqlResources.getString("RUNNER_ERRORS_TAB_LABEL"), testErrorStackPanel);
13561351
testDetailTabbedPane.add(UtplsqlResources.getString("RUNNER_WARNINGS_TAB_LABEL"), testWarningsPanel);
13571352
testDetailTabbedPane.add(UtplsqlResources.getString("RUNNER_INFO_TAB_LABEL"), testServerOutputPanel);
1358-
final JSplitPane horizontalSplitPane = new JSplitPane(SwingConstants.HORIZONTAL, testOverviewScrollPane,
1353+
final JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, testOverviewScrollPane,
13591354
testDetailTabbedPane);
13601355
horizontalSplitPane.setResizeWeight(0.5);
13611356
c.gridx = 0;

0 commit comments

Comments
 (0)
0