From aff5fcf5d3bd944c435dc5800a625c29be284ed5 Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Fri, 30 Mar 2018 14:24:13 +0100
Subject: [PATCH v2 14/28] remove some isHeadless checks which were preventing
large amounts of code being run in some tests
---
.../gui/io/AsynchronousUploadPrimitivesTask.java | 11 +++-----
.../preferences/advanced/ExportProfileAction.java | 6 ++---
.../gui/preferences/advanced/PreferencesTable.java | 31 +++++++++-------------
.../gui/preferences/plugin/PluginPreference.java | 17 +++++-------
4 files changed, 26 insertions(+), 39 deletions(-)
diff --git a/src/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTask.java b/src/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTask.java
index 319037b53..09ab221aa 100644
a
|
b
|
package org.openstreetmap.josm.gui.io;
|
3 | 3 | |
4 | 4 | import static org.openstreetmap.josm.tools.I18n.tr; |
5 | 5 | |
6 | | import java.awt.GraphicsEnvironment; |
7 | 6 | import java.util.Optional; |
8 | 7 | |
9 | 8 | import javax.swing.JOptionPane; |
… |
… |
public final class AsynchronousUploadPrimitivesTask extends UploadPrimitivesTask
|
85 | 84 | OsmDataLayer dataLayer, APIDataSet apiDataSet, Changeset changeset) { |
86 | 85 | synchronized (AsynchronousUploadPrimitivesTask.class) { |
87 | 86 | if (asynchronousUploadPrimitivesTask != null) { |
88 | | if (!GraphicsEnvironment.isHeadless()) { |
89 | | GuiHelper.runInEDTAndWait(() -> |
90 | | JOptionPane.showMessageDialog(MainApplication.parent, |
91 | | tr("A background upload is already in progress. " + |
92 | | "Kindly wait for it to finish before uploading new changes"))); |
93 | | } |
| 87 | GuiHelper.runInEDTAndWait(() -> |
| 88 | JOptionPane.showMessageDialog(MainApplication.parent, |
| 89 | tr("A background upload is already in progress. " + |
| 90 | "Kindly wait for it to finish before uploading new changes"))); |
94 | 91 | return Optional.empty(); |
95 | 92 | } else { |
96 | 93 | // Create an asynchronous upload task |
diff --git a/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java b/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java
index 84cb9694f..36fd57cc6 100644
a
|
b
|
public class ExportProfileAction extends AbstractAction {
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | if (keys.isEmpty()) { |
58 | | if (!GraphicsEnvironment.isHeadless()) { |
59 | | JOptionPane.showMessageDialog(Main.parent, |
60 | | tr("All the preferences of this group are default, nothing to save"), tr("Warning"), JOptionPane.WARNING_MESSAGE); |
61 | | } |
| 58 | JOptionPane.showMessageDialog(Main.parent, |
| 59 | tr("All the preferences of this group are default, nothing to save"), tr("Warning"), JOptionPane.WARNING_MESSAGE); |
62 | 60 | return; |
63 | 61 | } |
64 | 62 | File f = askUserForCustomSettingsFile(); |
diff --git a/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java b/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java
index 8f63f0ef4..1abd118e1 100644
a
|
b
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
7 | 7 | import java.awt.Color; |
8 | 8 | import java.awt.Component; |
9 | 9 | import java.awt.Font; |
10 | | import java.awt.GraphicsEnvironment; |
11 | 10 | import java.awt.GridBagLayout; |
12 | 11 | import java.awt.event.MouseAdapter; |
13 | 12 | import java.awt.event.MouseEvent; |
… |
… |
public class PreferencesTable extends JTable {
|
95 | 94 | */ |
96 | 95 | public boolean editPreference(final JComponent gui) { |
97 | 96 | if (getSelectedRowCount() != 1) { |
98 | | if (!GraphicsEnvironment.isHeadless()) { |
99 | | JOptionPane.showMessageDialog( |
100 | | gui, |
101 | | tr("Please select the row to edit."), |
102 | | tr("Warning"), |
103 | | JOptionPane.WARNING_MESSAGE |
104 | | ); |
105 | | } |
| 97 | JOptionPane.showMessageDialog( |
| 98 | gui, |
| 99 | tr("Please select the row to edit."), |
| 100 | tr("Warning"), |
| 101 | JOptionPane.WARNING_MESSAGE |
| 102 | ); |
106 | 103 | return false; |
107 | 104 | } |
108 | 105 | final PrefEntry e = (PrefEntry) model.getValueAt(getSelectedRow(), 1); |
… |
… |
public class PreferencesTable extends JTable {
|
196 | 193 | |
197 | 194 | PrefEntry pe = null; |
198 | 195 | boolean ok = false; |
199 | | if (!GraphicsEnvironment.isHeadless() && askAddSetting(gui, p)) { |
| 196 | if (askAddSetting(gui, p)) { |
200 | 197 | if (rbString.isSelected()) { |
201 | 198 | StringSetting sSetting = new StringSetting(null); |
202 | 199 | pe = new PrefEntry(tkey.getText(), sSetting, sSetting, false); |
… |
… |
public class PreferencesTable extends JTable {
|
281 | 278 | */ |
282 | 279 | public void resetPreferences(final JComponent gui) { |
283 | 280 | if (getSelectedRowCount() == 0) { |
284 | | if (!GraphicsEnvironment.isHeadless()) { |
285 | | JOptionPane.showMessageDialog( |
286 | | gui, |
287 | | tr("Please select the row to delete."), |
288 | | tr("Warning"), |
289 | | JOptionPane.WARNING_MESSAGE |
290 | | ); |
291 | | } |
| 281 | JOptionPane.showMessageDialog( |
| 282 | gui, |
| 283 | tr("Please select the row to delete."), |
| 284 | tr("Warning"), |
| 285 | JOptionPane.WARNING_MESSAGE |
| 286 | ); |
292 | 287 | return; |
293 | 288 | } |
294 | 289 | for (int row : getSelectedRows()) { |
diff --git a/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java b/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
index 3392bad3c..9d4b3ed20 100644
a
|
b
|
import static org.openstreetmap.josm.tools.I18n.trn;
|
6 | 6 | |
7 | 7 | import java.awt.BorderLayout; |
8 | 8 | import java.awt.Component; |
9 | | import java.awt.GraphicsEnvironment; |
10 | 9 | import java.awt.GridBagConstraints; |
11 | 10 | import java.awt.GridBagLayout; |
12 | 11 | import java.awt.GridLayout; |
… |
… |
public final class PluginPreference extends DefaultTabPreferenceSetting {
|
158 | 157 | sb.append(tr("Please restart JOSM to activate the downloaded plugins.")); |
159 | 158 | } |
160 | 159 | sb.append("</html>"); |
161 | | if (!GraphicsEnvironment.isHeadless()) { |
162 | | GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog( |
163 | | parent, |
164 | | sb.toString(), |
165 | | tr("Update plugins"), |
166 | | !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, |
167 | | HelpUtil.ht("/Preferences/Plugins") |
168 | | )); |
169 | | } |
| 160 | GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog( |
| 161 | parent, |
| 162 | sb.toString(), |
| 163 | tr("Update plugins"), |
| 164 | !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, |
| 165 | HelpUtil.ht("/Preferences/Plugins") |
| 166 | )); |
170 | 167 | } |
171 | 168 | |
172 | 169 | private JPanel buildSearchFieldPanel() { |