Ignore:
Timestamp:
2018-08-12T17:24:32+02:00 (6 years ago)
Author:
Don-vip
Message:

see #15229 - deprecate Main.pref

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
6 edited

Legend:

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

    r14146 r14149  
    8383import org.openstreetmap.josm.command.SplitWayCommand;
    8484import org.openstreetmap.josm.data.Bounds;
     85import org.openstreetmap.josm.data.Preferences;
    8586import org.openstreetmap.josm.data.UndoRedoHandler;
    8687import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener;
     
    819820        PlatformManager.getPlatform().preStartupHook();
    820821
    821         Config.setPreferencesInstance(Main.pref);
     822        Preferences prefs = Preferences.main();
     823        Config.setPreferencesInstance(prefs);
    822824        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
    823825        Config.setUrlsProvider(JosmUrls.getInstance());
     
    843845
    844846        try {
    845             Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));
     847            Preferences.main().init(args.hasOption(Option.RESET_PREFERENCES));
    846848        } catch (SecurityException e) {
    847849            Logging.log(Logging.LEVEL_ERROR, "Unable to initialize preferences", e);
    848850        }
    849851
    850         args.getPreferencesToSet().forEach(Main.pref::put);
     852        args.getPreferencesToSet().forEach(prefs::put);
    851853
    852854        if (!language.isPresent()) {
     
    854856        }
    855857        updateSystemProperties();
    856         Main.pref.addPreferenceChangeListener(new PreferenceChangedListener() {
     858        Preferences.main().addPreferenceChangeListener(new PreferenceChangedListener() {
    857859            @Override
    858860            public void preferenceChanged(PreferenceChangeEvent e) {
     
    887889
    888890        if (args.hasOption(Option.LOAD_PREFERENCES)) {
    889             XMLCommandProcessor config = new XMLCommandProcessor(Main.pref);
     891            XMLCommandProcessor config = new XMLCommandProcessor(prefs);
    890892            for (String i : args.get(Option.LOAD_PREFERENCES)) {
    891893                try {
  • trunk/src/org/openstreetmap/josm/gui/MainTermination.java

    r14140 r14149  
    88import java.util.Objects;
    99
    10 import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.data.Preferences;
    1111import org.openstreetmap.josm.data.cache.JCSCacheManager;
    1212import org.openstreetmap.josm.tools.ImageProvider;
     
    4848        ImageProvider.shutdown(false);
    4949        try {
    50             Main.pref.saveDefaults();
     50            Preferences.main().saveDefaults();
    5151        } catch (IOException | InvalidPathException ex) {
    5252            Logging.log(Logging.LEVEL_WARN, tr("Failed to save default preferences."), ex);
  • trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java

    r13901 r14149  
    100100     */
    101101    public static void readXML(File file) {
    102         readXML(file, Main.pref);
     102        readXML(file, Preferences.main());
    103103    }
    104104
     
    206206    public static void exportPreferencesKeysByPatternToFile(String fileName, boolean append, String pattern) {
    207207        List<String> keySet = new ArrayList<>();
    208         Map<String, Setting<?>> allSettings = Main.pref.getAllSettings();
     208        Map<String, Setting<?>> allSettings = Preferences.main().getAllSettings();
    209209        for (String key: allSettings.keySet()) {
    210210            if (key.matches(pattern))
     
    227227
    228228        try {
    229             String toXML = Main.pref.toXML(true);
     229            String toXML = Preferences.main().toXML(true);
    230230            DocumentBuilder builder = XmlUtils.newSafeDOMBuilder();
    231231            document = builder.parse(new ByteArrayInputStream(toXML.getBytes(StandardCharsets.UTF_8)));
     
    358358                    for (PluginInformation pi4: toDeletePlugins) {
    359359                        pls.remove(pi4.name);
    360                         new File(Main.pref.getPluginsDirectory(), pi4.name+".jar").deleteOnExit();
     360                        new File(Preferences.main().getPluginsDirectory(), pi4.name+".jar").deleteOnExit();
    361361                    }
    362362                    Config.getPref().putList("plugins", pls);
     
    375375            dir = Config.getDirs().getCacheDirectory(false).getAbsolutePath();
    376376        } else if ("plugins".equals(base)) {
    377             dir = Main.pref.getPluginsDirectory().getAbsolutePath();
     377            dir = Preferences.main().getPluginsDirectory().getAbsolutePath();
    378378        } else {
    379379            dir = null;
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java

    r13838 r14149  
    130130            }
    131131        });
    132         readPreferences(Main.pref);
     132        readPreferences(Preferences.main());
    133133
    134134        applyFilter();
     
    181181    private void readPreferences(Preferences tmpPrefs) {
    182182        Map<String, Setting<?>> loaded;
    183         Map<String, Setting<?>> orig = Main.pref.getAllSettings();
     183        Map<String, Setting<?>> orig = Preferences.main().getAllSettings();
    184184        Map<String, Setting<?>> defaults = tmpPrefs.getAllDefaults();
    185185        orig.remove("osm-server.password");
    186186        defaults.remove("osm-server.password");
    187         if (tmpPrefs != Main.pref) {
     187        if (tmpPrefs != Preferences.main()) {
    188188            loaded = tmpPrefs.getAllSettings();
    189189            // plugins preference keys may be changed directly later, after plugins are downloaded
     
    262262            return;
    263263
    264         Preferences tmpPrefs = new Preferences(Main.pref);
     264        Preferences tmpPrefs = new Preferences(Preferences.main());
    265265
    266266        StringBuilder log = new StringBuilder();
     
    324324
    325325        for (Entry<String, String> e: profileTypes.entrySet()) {
    326             menu.add(new ExportProfileAction(Main.pref, e.getKey(), e.getValue()));
     326            menu.add(new ExportProfileAction(Preferences.main(), e.getKey(), e.getValue()));
    327327        }
    328328
     
    339339                        "Are you sure you want to continue?")
    340340                        +"</html>", null, "")) {
    341                     Main.pref.resetToDefault();
     341                    Preferences.main().resetToDefault();
    342342                    try {
    343                         Main.pref.save();
     343                        Preferences.main().save();
    344344                    } catch (IOException | InvalidPathException e) {
    345345                        Logging.log(Logging.LEVEL_WARN, "Exception while saving preferences:", e);
    346346                    }
    347                     readPreferences(Main.pref);
     347                    readPreferences(Preferences.main());
    348348                    applyFilter();
    349349                }
     
    412412        @Override
    413413        public void actionPerformed(ActionEvent ae) {
    414             Preferences tmpPrefs = new Preferences(Main.pref);
     414            Preferences tmpPrefs = new Preferences(Preferences.main());
    415415            CustomConfigurator.readXML(file, tmpPrefs);
    416416            readPreferences(tmpPrefs);
     
    460460        for (PrefEntry e : allData) {
    461461            if (e.isChanged()) {
    462                 Main.pref.putSetting(e.getKey(), e.getValue().getValue() == null ? null : e.getValue());
     462                Preferences.main().putSetting(e.getKey(), e.getValue().getValue() == null ? null : e.getValue());
    463463            }
    464464        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    r13986 r14149  
    3636import javax.swing.table.DefaultTableCellRenderer;
    3737
    38 import org.openstreetmap.josm.Main;
     38import org.openstreetmap.josm.data.Preferences;
    3939import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    4040import org.openstreetmap.josm.data.preferences.ColorInfo;
     
    269269    public void addGui(final PreferenceTabbedPane gui) {
    270270        fixColorPrefixes();
    271         setColors(Main.pref.getAllNamedColors());
     271        setColors(Preferences.main().getAllNamedColors());
    272272
    273273        colorEdit = new JButton(tr("Choose"));
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r14052 r14149  
    4545import org.openstreetmap.josm.Main;
    4646import org.openstreetmap.josm.actions.ExpertToggleAction;
     47import org.openstreetmap.josm.data.Preferences;
    4748import org.openstreetmap.josm.data.Version;
    4849import org.openstreetmap.josm.gui.HelpAwareOptionPane;
     
    300301        if (answer != 0 /* OK */)
    301302            return;
    302         Main.pref.setPluginSites(pnl.getUpdateSites());
     303        Preferences.main().setPluginSites(pnl.getUpdateSites());
    303304    }
    304305
     
    376377        @Override
    377378        public void actionPerformed(ActionEvent e) {
    378             Collection<String> pluginSites = Main.pref.getOnlinePluginSites();
     379            Collection<String> pluginSites = Preferences.main().getOnlinePluginSites();
    379380            if (pluginSites.isEmpty()) {
    380381                return;
     
    430431            // the async task for downloading plugin information
    431432            final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(
    432                     Main.pref.getOnlinePluginSites());
     433                    Preferences.main().getOnlinePluginSites());
    433434
    434435            // to be run asynchronously after the plugin download
     
    601602            super(new GridBagLayout());
    602603            add(new JLabel(tr("Add JOSM Plugin description URL.")), GBC.eol());
    603             for (String s : Main.pref.getPluginSites()) {
     604            for (String s : Preferences.main().getPluginSites()) {
    604605                model.addElement(s);
    605606            }
Note: See TracChangeset for help on using the changeset viewer.