Changeset 12845 in josm for trunk/src


Ignore:
Timestamp:
2017-09-13T23:21:09+02:00 (7 years ago)
Author:
bastiK
Message:

new class Config to hold a global IPreferences singleton, replacing calls to Main.pref as far as the interface supports it

makes it possible to easily replace org.openstreetmap.josm.data.Preferences by
another preferences handler (implementation of IPreferences)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 added
1 edited

Legend:

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

    r12841 r12845  
    145145import org.openstreetmap.josm.plugins.PluginHandler;
    146146import org.openstreetmap.josm.plugins.PluginInformation;
     147import org.openstreetmap.josm.spi.preferences.Config;
    147148import org.openstreetmap.josm.tools.FontsManager;
    148149import org.openstreetmap.josm.tools.GBC;
     
    914915
    915916        Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));
     917        Config.setPreferencesInstance(Main.pref);
    916918
    917919        args.getPreferencesToSet().forEach(Main.pref::put);
    918920
    919921        if (!language.isPresent()) {
    920             I18n.set(Main.pref.get("language", null));
     922            I18n.set(Config.getPref().get("language", null));
    921923        }
    922924        Main.pref.updateSystemProperties();
     
    938940        WindowGeometry geometry = WindowGeometry.mainWindow("gui.geometry",
    939941                args.getSingle(Option.GEOMETRY).orElse(null),
    940                 !args.hasOption(Option.NO_MAXIMIZE) && Main.pref.getBoolean("gui.maximized", false));
     942                !args.hasOption(Option.NO_MAXIMIZE) && Config.getPref().getBoolean("gui.maximized", false));
    941943        final MainFrame mainFrame = new MainFrame(geometry);
    942944        final Container contentPane = mainFrame.getContentPane();
     
    975977        final SplashScreen.SplashProgressMonitor monitor = splash.getProgressMonitor();
    976978        monitor.beginTask(tr("Initializing"));
    977         GuiHelper.runInEDT(() -> splash.setVisible(Main.pref.getBoolean("draw.splashscreen", true)));
     979        GuiHelper.runInEDT(() -> splash.setVisible(Config.getPref().getBoolean("draw.splashscreen", true)));
    978980        Main.setInitStatusListener(new InitStatusListener() {
    979981
     
    10221024        });
    10231025
    1024         boolean maximized = Main.pref.getBoolean("gui.maximized", false);
     1026        boolean maximized = Config.getPref().getBoolean("gui.maximized", false);
    10251027        if ((!args.hasOption(Option.NO_MAXIMIZE) && maximized) || args.hasOption(Option.MAXIMIZE)) {
    10261028            mainFrame.setMaximized(true);
     
    10511053        }
    10521054
    1053         if (Main.pref.getBoolean("debug.edt-checker.enable", Version.getInstance().isLocalBuild())) {
     1055        if (Config.getPref().getBoolean("debug.edt-checker.enable", Version.getInstance().isLocalBuild())) {
    10541056            // Repaint manager is registered so late for a reason - there is lots of violation during startup process
    10551057            // but they don't seem to break anything and are difficult to fix
     
    12201222     */
    12211223    private static void checkIPv6() {
    1222         if ("auto".equals(Main.pref.get("prefer.ipv6", "auto"))) {
     1224        if ("auto".equals(Config.getPref().get("prefer.ipv6", "auto"))) {
    12231225            new Thread((Runnable) () -> { /* this may take some time (DNS, Connect) */
    12241226                boolean hasv6 = false;
    1225                 boolean wasv6 = Main.pref.getBoolean("validated.ipv6", false);
     1227                boolean wasv6 = Config.getPref().getBoolean("validated.ipv6", false);
    12261228                try {
    12271229                    /* Use the check result from last run of the software, as after the test, value
     
    12521254                if (wasv6 && !hasv6) {
    12531255                    Logging.info(tr("Detected no useable IPv6 network, prefering IPv4 over IPv6 after next restart."));
    1254                     Main.pref.putBoolean("validated.ipv6", hasv6); // be sure it is stored before the restart!
     1256                    Config.getPref().putBoolean("validated.ipv6", hasv6); // be sure it is stored before the restart!
    12551257                    try {
    12561258                        RestartAction.restartJOSM();
     
    12591261                    }
    12601262                }
    1261                 Main.pref.putBoolean("validated.ipv6", hasv6);
     1263                Config.getPref().putBoolean("validated.ipv6", hasv6);
    12621264            }, "IPv6-checker").start();
    12631265        }
Note: See TracChangeset for help on using the changeset viewer.