Ticket #16010: v2-0014-remove-some-isHeadless-checks-which-were-preventi.patch

File v2-0014-remove-some-isHeadless-checks-which-were-preventi.patch, 7.7 KB (added by ris, 15 months ago)
  • src/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTask.java

    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; 
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.GraphicsEnvironment;
    76import java.util.Optional;
    87
    98import javax.swing.JOptionPane;
    public final class AsynchronousUploadPrimitivesTask extends UploadPrimitivesTask 
    8584             OsmDataLayer dataLayer, APIDataSet apiDataSet, Changeset changeset) {
    8685        synchronized (AsynchronousUploadPrimitivesTask.class) {
    8786            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")));
    9491                return Optional.empty();
    9592            } else {
    9693                // Create an asynchronous upload task
  • src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java

    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 { 
    5555            }
    5656        }
    5757        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);
    6260            return;
    6361        }
    6462        File f = askUserForCustomSettingsFile();
  • src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    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; 
    77import java.awt.Color;
    88import java.awt.Component;
    99import java.awt.Font;
    10 import java.awt.GraphicsEnvironment;
    1110import java.awt.GridBagLayout;
    1211import java.awt.event.MouseAdapter;
    1312import java.awt.event.MouseEvent;
    public class PreferencesTable extends JTable { 
    9594     */
    9695    public boolean editPreference(final JComponent gui) {
    9796        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                    );
    106103            return false;
    107104        }
    108105        final PrefEntry e = (PrefEntry) model.getValueAt(getSelectedRow(), 1);
    public class PreferencesTable extends JTable { 
    196193
    197194        PrefEntry pe = null;
    198195        boolean ok = false;
    199         if (!GraphicsEnvironment.isHeadless() && askAddSetting(gui, p)) {
     196        if (askAddSetting(gui, p)) {
    200197            if (rbString.isSelected()) {
    201198                StringSetting sSetting = new StringSetting(null);
    202199                pe = new PrefEntry(tkey.getText(), sSetting, sSetting, false);
    public class PreferencesTable extends JTable { 
    281278     */
    282279    public void resetPreferences(final JComponent gui) {
    283280        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                    );
    292287            return;
    293288        }
    294289        for (int row : getSelectedRows()) {
  • src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    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; 
    66
    77import java.awt.BorderLayout;
    88import java.awt.Component;
    9 import java.awt.GraphicsEnvironment;
    109import java.awt.GridBagConstraints;
    1110import java.awt.GridBagLayout;
    1211import java.awt.GridLayout;
    public final class PluginPreference extends DefaultTabPreferenceSetting { 
    158157            sb.append(tr("Please restart JOSM to activate the downloaded plugins."));
    159158        }
    160159        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                ));
    170167    }
    171168
    172169    private JPanel buildSearchFieldPanel() {