Ticket #16010: v2-0022-plugin-preferences-small-additions-to-ease-testin.patch

File v2-0022-plugin-preferences-small-additions-to-ease-testin.patch, 4.3 KB (added by ris, 15 months ago)
  • src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    From 6639dd3d599535fa0e82591251171048ef21323b Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Sat, 12 May 2018 11:20:26 +0100
    Subject: [PATCH v2 22/28] plugin preferences: small additions to ease testing
    
    ---
     .../josm/gui/preferences/PreferenceTabbedPane.java     |  8 +++++---
     .../josm/gui/preferences/plugin/PluginPreference.java  | 18 ++++++++++++++----
     2 files changed, 19 insertions(+), 7 deletions(-)
    
    diff --git a/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java b/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
    index a1a340a89..2b9272610 100644
    a b import javax.swing.JOptionPane; 
    2525import javax.swing.JPanel;
    2626import javax.swing.JScrollPane;
    2727import javax.swing.JTabbedPane;
    28 import javax.swing.SwingUtilities;
    2928import javax.swing.event.ChangeEvent;
    3029import javax.swing.event.ChangeListener;
    3130
    import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference; 
    5958import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference;
    6059import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference;
    6160import org.openstreetmap.josm.gui.preferences.validator.ValidatorTestsPreference;
     61import org.openstreetmap.josm.gui.util.GuiHelper;
    6262import org.openstreetmap.josm.plugins.PluginDownloadTask;
    6363import org.openstreetmap.josm.plugins.PluginHandler;
    6464import org.openstreetmap.josm.plugins.PluginInformation;
    public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 
    174174                }
    175175            }
    176176
    177             Main.parent.repaint();
     177            if (Main.parent != null) {
     178                Main.parent.repaint();
     179            }
    178180        }
    179181    }
    180182
    public final class PreferenceTabbedPane extends JTabbedPane implements MouseWhee 
    420422                // if we have to launch a plugin download task we do it asynchronously, followed
    421423                // by the remaining "save preferences" activites run on the Swing EDT.
    422424                MainApplication.worker.submit(task);
    423                 MainApplication.worker.submit(() -> SwingUtilities.invokeLater(continuation));
     425                MainApplication.worker.submit(() -> GuiHelper.runInEDT(continuation));
    424426            } else {
    425427                // no need for asynchronous activities. Simply run the remaining "save preference"
    426428                // activities on this thread (we are already on the Swing EDT
  • 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 9d4b3ed20..d884878a6 100644
    a b public final class PluginPreference extends DefaultTabPreferenceSetting { 
    211211    private JPanel buildActionPanel() {
    212212        JPanel pnl = new JPanel(new GridLayout(1, 4));
    213213
    214         pnl.add(new JButton(new DownloadAvailablePluginsAction()));
    215         pnl.add(new JButton(new UpdateSelectedPluginsAction()));
    216         ExpertToggleAction.addVisibilitySwitcher(pnl.add(new JButton(new SelectByListAction())));
    217         ExpertToggleAction.addVisibilitySwitcher(pnl.add(new JButton(new ConfigureSitesAction())));
     214        // assign some component names to these as we go to aid testing
     215        final JButton downloadListButton = new JButton(new DownloadAvailablePluginsAction());
     216        downloadListButton.setName("downloadListButton");
     217        final JButton updatePluginsButton = new JButton(new UpdateSelectedPluginsAction());
     218        updatePluginsButton.setName("updatePluginsButton");
     219        final JButton loadFromListButton = new JButton(new SelectByListAction());
     220        loadFromListButton.setName("loadFromListButton");
     221        final JButton configureSitesButton = new JButton(new ConfigureSitesAction());
     222        configureSitesButton.setName("configureSitesButton");
     223
     224        pnl.add(downloadListButton);
     225        pnl.add(updatePluginsButton);
     226        ExpertToggleAction.addVisibilitySwitcher(pnl.add(loadFromListButton));
     227        ExpertToggleAction.addVisibilitySwitcher(pnl.add(configureSitesButton));
    218228        return pnl;
    219229    }
    220230