Changeset 12637 in josm for trunk


Ignore:
Timestamp:
2017-08-24T23:29:01+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate Main.toolbar. Replacement: gui.MainApplication.getToolbar()

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r12636 r12637  
    1111import java.text.MessageFormat;
    1212import java.util.ArrayList;
    13 import java.util.Arrays;
    1413import java.util.Collection;
    1514import java.util.Collections;
     
    3231import javax.swing.JComponent;
    3332import javax.swing.KeyStroke;
    34 import javax.swing.LookAndFeel;
    35 import javax.swing.UIManager;
    36 import javax.swing.UnsupportedLookAndFeelException;
    3733
    3834import org.openstreetmap.josm.actions.JosmAction;
     
    5450import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
    5551import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
    56 import org.openstreetmap.josm.gui.preferences.display.LafPreference;
    5752import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    5853import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
     
    6055import org.openstreetmap.josm.io.OnlineResource;
    6156import org.openstreetmap.josm.io.OsmApi;
    62 import org.openstreetmap.josm.plugins.PluginHandler;
    6357import org.openstreetmap.josm.tools.CheckParameterUtil;
    6458import org.openstreetmap.josm.tools.I18n;
     
    132126     * The MapFrame.
    133127     * <p>
    134      * There should be no need to access this to access any map data. Use {@link #layerManager} instead.
     128     * There should be no need to access this to access any map data. Use {@link MainApplication#getLayerManager} instead.
    135129     *
    136      * @deprecated Use {@link org.openstreetmap.josm.gui.MainApplication#getMap()} instead
     130     * @deprecated Use {@link MainApplication#getMap()} instead
    137131     * @see MainPanel
    138132     */
     
    142136    /**
    143137     * The toolbar preference control to register new actions.
    144      */
     138     * @deprecated Use {@link MainApplication#getToolbar} instead
     139     */
     140    @Deprecated
    145141    public static volatile ToolbarPreferences toolbar;
    146142
     
    744740    public static void preConstructorInit() {
    745741        ProjectionPreference.setProjection();
    746 
    747         String defaultlaf = platform.getDefaultStyle();
    748         String laf = LafPreference.LAF.get();
    749         try {
    750             UIManager.setLookAndFeel(laf);
    751         } catch (final NoClassDefFoundError | ClassNotFoundException e) {
    752             // Try to find look and feel in plugin classloaders
    753             Logging.trace(e);
    754             Class<?> klass = null;
    755             for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) {
    756                 try {
    757                     klass = cl.loadClass(laf);
    758                     break;
    759                 } catch (ClassNotFoundException ex) {
    760                     Logging.trace(ex);
    761                 }
    762             }
    763             if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) {
    764                 try {
    765                     UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance());
    766                 } catch (ReflectiveOperationException ex) {
    767                     Logging.log(Logging.LEVEL_WARN, "Cannot set Look and Feel: " + laf + ": "+ex.getMessage(), ex);
    768                 } catch (UnsupportedLookAndFeelException ex) {
    769                     Logging.info("Look and Feel not supported: " + laf);
    770                     LafPreference.LAF.put(defaultlaf);
    771                     Logging.trace(ex);
    772                 }
    773             } else {
    774                 Logging.info("Look and Feel not found: " + laf);
    775                 LafPreference.LAF.put(defaultlaf);
    776             }
    777         } catch (UnsupportedLookAndFeelException e) {
    778             Logging.info("Look and Feel not supported: " + laf);
    779             LafPreference.LAF.put(defaultlaf);
    780             Logging.trace(e);
    781         } catch (InstantiationException | IllegalAccessException e) {
    782             Logging.error(e);
    783         }
    784         toolbar = new ToolbarPreferences();
    785 
    786         UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));
    787         UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon"));
    788         UIManager.put("OptionPane.cancelIcon", ImageProvider.get("cancel"));
    789         UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));
    790         // Ensures caret color is the same than text foreground color, see #12257
    791         // See http://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html
    792         for (String p : Arrays.asList(
    793                 "EditorPane", "FormattedTextField", "PasswordField", "TextArea", "TextField", "TextPane")) {
    794             UIManager.put(p+".caretForeground", UIManager.getColor(p+".foreground"));
    795         }
    796 
    797742        I18n.translateJavaInternalMessages();
    798743
    799744        // init default coordinate format
    800         //
    801745        try {
    802746            CoordinateFormat.setCoordinateFormat(CoordinateFormat.valueOf(Main.pref.get("coordinates")));
  • trunk/src/org/openstreetmap/josm/actions/ExpertToggleAction.java

    r12542 r12637  
    77import java.awt.event.ActionEvent;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.preferences.BooleanProperty;
     10import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.tools.ListenerList;
    1212
     
    100100        );
    101101        putValue("toolbar", "expertmode");
    102         if (Main.toolbar != null) {
    103             Main.toolbar.register(this);
     102        if (MainApplication.getToolbar() != null) {
     103            MainApplication.getToolbar().register(this);
    104104        }
    105105        setSelected(PREF_EXPERT.get());
  • trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java

    r11278 r12637  
    2020
    2121import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.gui.MainApplication;
    2223import org.openstreetmap.josm.gui.util.GuiHelper;
    2324import org.openstreetmap.josm.tools.Shortcut;
     
    4344        putValue("help", ht("/Action/FullscreenView"));
    4445        putValue("toolbar", "fullscreen");
    45         Main.toolbar.register(this);
     46        MainApplication.getToolbar().register(this);
    4647        gd = GraphicsEnvironment.isHeadless() ? null : GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    4748        setSelected(Main.pref.getBoolean("draw.fullscreen", false));
  • trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java

    r12279 r12637  
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.data.osm.DataSet;
     12import org.openstreetmap.josm.gui.MainApplication;
    1213import org.openstreetmap.josm.gui.dialogs.OsmIdSelectionDialog;
    1314import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager;
     
    3132        putValue("help", ht("/Action/ObjectHistory"));
    3233        putValue("toolbar", "action/historyinfo");
    33         Main.toolbar.register(this);
     34        MainApplication.getToolbar().register(this);
    3435        setEnabled(true);
    3536    }
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r12636 r12637  
    8585            putValue("toolbar", toolbarId);
    8686        }
    87         if (registerInToolbar && Main.toolbar != null) {
    88             Main.toolbar.register(this);
     87        if (registerInToolbar && MainApplication.getToolbar() != null) {
     88            MainApplication.getToolbar().register(this);
    8989        }
    9090        if (installAdapters) {
  • trunk/src/org/openstreetmap/josm/actions/MoveAction.java

    r12630 r12637  
    9797            putValue("toolbar", "action/move/right");
    9898        }
    99         Main.toolbar.register(this);
     99        MainApplication.getToolbar().register(this);
    100100    }
    101101
  • trunk/src/org/openstreetmap/josm/actions/RestartAction.java

    r12636 r12637  
    4949        putValue("help", ht("/Action/Restart"));
    5050        putValue("toolbar", "action/restart");
    51         if (Main.toolbar != null) {
    52             Main.toolbar.register(this);
     51        if (MainApplication.getToolbar() != null) {
     52            MainApplication.getToolbar().register(this);
    5353        }
    5454        setEnabled(isRestartSupported());
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r12636 r12637  
    6565        putValue("help", ht("/Action/ShowStatusReport"));
    6666        putValue("toolbar", "help/showstatusreport");
    67         Main.toolbar.register(this);
     67        MainApplication.getToolbar().register(this);
    6868    }
    6969
  • trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java

    r12636 r12637  
    77import java.awt.event.KeyEvent;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory;
    1110import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    1211import org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer;
     12import org.openstreetmap.josm.gui.MainApplication;
    1313import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1414import org.openstreetmap.josm.tools.Shortcut;
     
    3131        );
    3232        putValue("toolbar", "wireframe");
    33         Main.toolbar.register(this);
     33        MainApplication.getToolbar().register(this);
    3434        setSelected(MapRendererFactory.getInstance().isWireframeMapRendererActive());
    3535        notifySelectedState();
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r12636 r12637  
    465465
    466466            // add custom search button to toolbar preferences
    467             Main.toolbar.addCustomButton(res, -1, false);
     467            MainApplication.getToolbar().addCustomButton(res, -1, false);
    468468        }
    469469
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r12636 r12637  
    5353            super(tr("Imagery offset"), "mapmode/adjustimg", tr("Adjust imagery offset"), null, false, false);
    5454            putValue("toolbar", "imagery-offset");
    55             Main.toolbar.register(this);
     55            MainApplication.getToolbar().register(this);
    5656        }
    5757
     
    271271        for (Object item : dynamicItems) {
    272272            if (item instanceof JMenuItem) {
    273                 Optional.ofNullable(((JMenuItem) item).getAction()).ifPresent(Main.toolbar::unregister);
     273                Optional.ofNullable(((JMenuItem) item).getAction()).ifPresent(MainApplication.getToolbar()::unregister);
    274274                remove((JMenuItem) item);
    275275            } else if (item instanceof MenuComponent) {
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12636 r12637  
    4646import javax.swing.JComponent;
    4747import javax.swing.JOptionPane;
     48import javax.swing.LookAndFeel;
    4849import javax.swing.RepaintManager;
    4950import javax.swing.SwingUtilities;
     51import javax.swing.UIManager;
     52import javax.swing.UnsupportedLookAndFeelException;
    5053
    5154import org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager;
     
    7477import org.openstreetmap.josm.gui.layer.MainLayerManager;
    7578import org.openstreetmap.josm.gui.layer.TMSLayer;
     79import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     80import org.openstreetmap.josm.gui.preferences.display.LafPreference;
    7681import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference;
    7782import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference;
     
    98103import org.openstreetmap.josm.tools.HttpClient;
    99104import org.openstreetmap.josm.tools.I18n;
     105import org.openstreetmap.josm.tools.ImageProvider;
    100106import org.openstreetmap.josm.tools.Logging;
    101107import org.openstreetmap.josm.tools.OpenBrowser;
     
    127133     */
    128134    static MapFrame map;
     135
     136    /**
     137     * The toolbar preference control to register new actions.
     138     */
     139    static volatile ToolbarPreferences toolbar;
    129140
    130141    private final MainFrame mainFrame;
     
    237248        } else {
    238249            // required for running some tests.
    239             panel = new MainPanel(MainApplication.getLayerManager());
     250            panel = new MainPanel(layerManager);
    240251            menu = new MainMenu();
    241252        }
     
    256267        }
    257268        // Remove all layers because somebody may rely on layerRemoved events (like AutosaveTask)
    258         getLayerManager().resetState();
     269        layerManager.resetState();
    259270        super.shutdown();
    260271        if (!GraphicsEnvironment.isHeadless()) {
     
    289300            return ((DrawAction) map.mapMode).getInProgressSelection();
    290301        } else {
    291             DataSet ds = getLayerManager().getEditDataSet();
     302            DataSet ds = layerManager.getEditDataSet();
    292303            if (ds == null) return null;
    293304            return ds.getSelected();
     
    307318     * Returns the main layer manager that is used by the map view.
    308319     * @return The layer manager. The value returned will never change.
    309      * @since 12636 (as a replacement to {@code MainApplication.getLayerManager()})
     320     * @since 12636 (as a replacement to {@code Main.getLayerManager()})
    310321     */
    311322    @SuppressWarnings("deprecation")
     
    324335    public static MapFrame getMap() {
    325336        return map;
     337    }
     338
     339    /**
     340     * Returns the toolbar preference control to register new actions.
     341     * @return the toolbar preference control
     342     * @since 12637 (as a replacement to {@code Main.toolbar})
     343     */
     344    public static ToolbarPreferences getToolbar() {
     345        return toolbar;
    326346    }
    327347
     
    351371    public static boolean exitJosm(boolean exit, int exitCode, SaveLayersDialog.Reason reason) {
    352372        final boolean proceed = Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() ->
    353                 SaveLayersDialog.saveUnsavedModifications(MainApplication.getLayerManager().getLayers(),
     373                SaveLayersDialog.saveUnsavedModifications(layerManager.getLayers(),
    354374                        reason != null ? reason : SaveLayersDialog.Reason.EXIT)));
    355375        if (proceed) {
     
    430450     * @param argArray Command-line arguments
    431451     */
     452    @SuppressWarnings("deprecation")
    432453    public static void main(final String[] argArray) {
    433454        I18n.init();
     
    576597
    577598        monitor.indeterminateSubTask(tr("Setting defaults"));
     599        setupUIManager();
     600        toolbar = new ToolbarPreferences();
     601        Main.toolbar = toolbar;
    578602        preConstructorInit();
    579603
     
    627651            Logging.info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console");
    628652            RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
     653        }
     654    }
     655
     656    static void setupUIManager() {
     657        String defaultlaf = platform.getDefaultStyle();
     658        String laf = LafPreference.LAF.get();
     659        try {
     660            UIManager.setLookAndFeel(laf);
     661        } catch (final NoClassDefFoundError | ClassNotFoundException e) {
     662            // Try to find look and feel in plugin classloaders
     663            Logging.trace(e);
     664            Class<?> klass = null;
     665            for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) {
     666                try {
     667                    klass = cl.loadClass(laf);
     668                    break;
     669                } catch (ClassNotFoundException ex) {
     670                    Logging.trace(ex);
     671                }
     672            }
     673            if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) {
     674                try {
     675                    UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance());
     676                } catch (ReflectiveOperationException ex) {
     677                    Logging.log(Logging.LEVEL_WARN, "Cannot set Look and Feel: " + laf + ": "+ex.getMessage(), ex);
     678                } catch (UnsupportedLookAndFeelException ex) {
     679                    Logging.info("Look and Feel not supported: " + laf);
     680                    LafPreference.LAF.put(defaultlaf);
     681                    Logging.trace(ex);
     682                }
     683            } else {
     684                Logging.info("Look and Feel not found: " + laf);
     685                LafPreference.LAF.put(defaultlaf);
     686            }
     687        } catch (UnsupportedLookAndFeelException e) {
     688            Logging.info("Look and Feel not supported: " + laf);
     689            LafPreference.LAF.put(defaultlaf);
     690            Logging.trace(e);
     691        } catch (InstantiationException | IllegalAccessException e) {
     692            Logging.error(e);
     693        }
     694
     695        UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));
     696        UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon"));
     697        UIManager.put("OptionPane.cancelIcon", ImageProvider.get("cancel"));
     698        UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));
     699        // Ensures caret color is the same than text foreground color, see #12257
     700        // See http://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html
     701        for (String p : Arrays.asList(
     702                "EditorPane", "FormattedTextField", "PasswordField", "TextArea", "TextField", "TextPane")) {
     703            UIManager.put(p+".caretForeground", UIManager.getColor(p+".foreground"));
    629704        }
    630705    }
  • trunk/src/org/openstreetmap/josm/gui/NotificationManager.java

    r12630 r12637  
    122122                } else {
    123123                    x = margin;
    124                     y = parentWindow.getHeight() - Main.toolbar.control.getSize().height - size.height - margin;
     124                    y = parentWindow.getHeight() - MainApplication.getToolbar().control.getSize().height - size.height - margin;
    125125                }
    126126                parentWindow.getLayeredPane().add(currentNotificationPanel, JLayeredPane.POPUP_LAYER, 0);
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r12634 r12637  
    548548        SETTINGS_FACTORIES.add(new BackupPreference.Factory());
    549549        SETTINGS_FACTORIES.add(new PluginPreference.Factory());
    550         SETTINGS_FACTORIES.add(Main.toolbar);
     550        SETTINGS_FACTORIES.add(MainApplication.getToolbar());
    551551        SETTINGS_FACTORIES.add(new AudioPreference.Factory());
    552552        SETTINGS_FACTORIES.add(new ShortcutPreference.Factory());
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r12620 r12637  
    6868import org.openstreetmap.josm.data.imagery.ImageryInfo;
    6969import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     70import org.openstreetmap.josm.gui.MainApplication;
    7071import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    7172import org.openstreetmap.josm.gui.util.GuiHelper;
     
    502503                t.remove(res);
    503504                Main.pref.putCollection("toolbar", t);
    504                 Main.toolbar.refreshToolbarControl();
     505                MainApplication.getToolbar().refreshToolbarControl();
    505506            }
    506507        });
     
    523524                p.setVisible(true);
    524525                // refresh toolbar to try using changed shortcuts without restart
    525                 Main.toolbar.refreshToolbarControl();
     526                MainApplication.getToolbar().refreshToolbarControl();
    526527            }
    527528        });
     
    987988            }
    988989            Main.pref.putCollection("toolbar", t);
    989             Main.toolbar.refreshToolbarControl();
     990            MainApplication.getToolbar().refreshToolbarControl();
    990991            return false;
    991992        }
     
    12141215        }
    12151216        Main.pref.putCollection("toolbar", t);
    1216         Main.toolbar.refreshToolbarControl();
     1217        MainApplication.getToolbar().refreshToolbarControl();
    12171218    }
    12181219
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r12636 r12637  
    625625        public void actionPerformed(ActionEvent ae) {
    626626            String res = getToolbarString();
    627             Main.toolbar.addCustomButton(res, toolbarIndex, true);
     627            MainApplication.getToolbar().addCustomButton(res, toolbarIndex, true);
    628628        }
    629629    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchAction.java

    r12636 r12637  
    77import java.awt.event.KeyEvent;
    88
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.JosmAction;
    1110import org.openstreetmap.josm.gui.MainApplication;
     
    2524                Shortcut.registerShortcut("preset:search", tr("Search presets"), KeyEvent.VK_F3, Shortcut.DIRECT), false);
    2625        putValue("toolbar", "presets/search");
    27         Main.toolbar.register(this);
     26        MainApplication.getToolbar().register(this);
    2827    }
    2928
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java

    r12636 r12637  
    3939                    false);
    4040            putValue("toolbar", "presets/search-objects");
    41             Main.toolbar.register(this);
     41            MainApplication.getToolbar().register(this);
    4242        }
    4343
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java

    r12636 r12637  
    219219                final TaggingPreset preset = getSelectedPreset();
    220220                if (preset != null) {
    221                     Main.toolbar.addCustomButton(preset.getToolbarString(), -1, false);
     221                    MainApplication.getToolbar().addCustomButton(preset.getToolbarString(), -1, false);
    222222                }
    223223            }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java

    r12620 r12637  
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.data.osm.OsmPrimitive;
     18import org.openstreetmap.josm.gui.MainApplication;
    1819import org.openstreetmap.josm.gui.MenuScroller;
    1920import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup;
     
    6263        for (TaggingPreset tp: taggingPresets) {
    6364            if (!(tp instanceof TaggingPresetSeparator)) {
    64                 Main.toolbar.register(tp);
     65                MainApplication.getToolbar().register(tp);
    6566            }
    6667        }
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r12636 r12637  
    1919import org.openstreetmap.josm.data.projection.Projections;
    2020import org.openstreetmap.josm.gui.MainApplication;
     21import org.openstreetmap.josm.gui.MainApplicationTest;
    2122import org.openstreetmap.josm.gui.MainPanel;
    2223import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
    23 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
    2424import org.openstreetmap.josm.gui.util.GuiHelper;
    2525import org.openstreetmap.josm.io.CertificateAmendment;
     
    201201     * Make sure {@code Main.toolbar} is initialized.
    202202     */
     203    @SuppressWarnings("deprecation")
    203204    public static void initToolbar() {
     205        MainApplicationTest.initToolbar();
    204206        if (Main.toolbar == null) {
    205             Main.toolbar = new ToolbarPreferences();
     207            Main.toolbar = MainApplication.getToolbar();
    206208        }
    207209    }
  • trunk/test/unit/org/openstreetmap/josm/MainTest.java

    r12634 r12637  
    1313import java.util.Collection;
    1414import java.util.Map;
    15 
    16 import javax.swing.UIManager;
    1715
    1816import org.junit.Rule;
     
    8179        Main.preConstructorInit();
    8280        assertNotNull(Main.getProjection());
    83         assertEquals(Main.pref.get("laf", Main.platform.getDefaultStyle()), UIManager.getLookAndFeel().getClass().getCanonicalName());
    84         assertNotNull(Main.toolbar);
    8581    }
    8682
  • trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    r12636 r12637  
    1919import java.util.concurrent.Future;
    2020
     21import javax.swing.UIManager;
     22
    2123import org.junit.Rule;
    2224import org.junit.Test;
     25import org.openstreetmap.josm.Main;
    2326import org.openstreetmap.josm.TestUtils;
    2427import org.openstreetmap.josm.data.Version;
     
    2629import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor;
    2730import org.openstreetmap.josm.gui.layer.GpxLayer;
     31import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
    2832import org.openstreetmap.josm.plugins.PluginHandler;
    2933import org.openstreetmap.josm.plugins.PluginHandlerTestIT;
     
    4751    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4852    public JOSMTestRules test = new JOSMTestRules().main().https().devAPI().timeout(20000);
     53
     54    /**
     55     * Make sure {@link MainApplication#toolbar} is initialized.
     56     */
     57    public static void initToolbar() {
     58        if (MainApplication.toolbar == null) {
     59            MainApplication.toolbar = new ToolbarPreferences();
     60        }
     61    }
    4962
    5063    @SuppressFBWarnings(value = "DM_DEFAULT_ENCODING")
     
    132145    }
    133146
     147    /**
     148     * Unit test of {@link MainApplication#setupUIManager}.
     149     */
     150    @Test
     151    public void testSetupUIManager() {
     152        MainApplication.setupUIManager();
     153        assertEquals(Main.pref.get("laf", Main.platform.getDefaultStyle()), UIManager.getLookAndFeel().getClass().getCanonicalName());
     154    }
     155
    134156    private static PluginInformation newPluginInformation(String plugin) throws PluginListParseException {
    135157        return PluginListParser.createInfo(plugin+".jar", "https://svn.openstreetmap.org/applications/editors/josm/dist/"+plugin+".jar",
Note: See TracChangeset for help on using the changeset viewer.