Changeset 14149 in josm for trunk


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

see #15229 - deprecate Main.pref

Location:
trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorLayerIndex.groovy

    r14020 r14149  
    2525import javax.json.JsonValue
    2626
    27 import org.openstreetmap.josm.Main
    2827import org.openstreetmap.josm.data.Preferences
    2928import org.openstreetmap.josm.data.imagery.ImageryInfo
     
    6160        Locale.setDefault(Locale.ROOT)
    6261        parse_command_line_arguments(args)
    63         Main.determinePlatformHook()
    6462        def pref = new Preferences(JosmBaseDirectories.getInstance())
    6563        Config.setPreferencesInstance(pref)
  • trunk/scripts/TagInfoExtract.groovy

    r14120 r14149  
    2121import javax.json.stream.JsonGenerator
    2222
    23 import org.openstreetmap.josm.Main
    2423import org.openstreetmap.josm.actions.DeleteAction
    2524import org.openstreetmap.josm.command.DeleteCommand
     25import org.openstreetmap.josm.data.Preferences
    2626import org.openstreetmap.josm.data.Version
    2727import org.openstreetmap.josm.data.coor.LatLon
     
    413413     */
    414414    def init() {
    415         Main.determinePlatformHook()
    416415        Logging.setLogLevel(Logging.LEVEL_INFO)
    417         Main.pref.enableSaveOnPut(false)
    418         Config.setPreferencesInstance(Main.pref)
     416        Preferences.main().enableSaveOnPut(false)
     417        Config.setPreferencesInstance(Preferences.main())
    419418        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance())
    420419        Config.setUrlsProvider(JosmUrls.getInstance())
  • trunk/src/org/openstreetmap/josm/Main.java

    r14143 r14149  
    4343    /**
    4444     * Global application preferences
    45      */
     45     * @deprecated Use {@link Config#getPref()} or {@link Preferences#main()}
     46     */
     47    @Deprecated
    4648    public static final Preferences pref = new Preferences(JosmBaseDirectories.getInstance());
    4749
  • trunk/src/org/openstreetmap/josm/actions/PreferenceToggleAction.java

    r14134 r14149  
    66import javax.swing.JCheckBoxMenuItem;
    77
    8 import org.openstreetmap.josm.Main;
     8import org.openstreetmap.josm.data.Preferences;
    99import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1010import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
     
    3535        checkbox = new JCheckBoxMenuItem(this);
    3636        checkbox.setSelected(pref.get());
    37         Main.pref.addWeakKeyPreferenceChangeListener(prefKey, this);
     37        Preferences.main().addWeakKeyPreferenceChangeListener(prefKey, this);
    3838    }
    3939
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r14143 r14149  
    2626
    2727import org.openstreetmap.josm.Main;
     28import org.openstreetmap.josm.data.Preferences;
    2829import org.openstreetmap.josm.data.Version;
    2930import org.openstreetmap.josm.data.osm.DataSet;
     
    277278        String reportHeader = getReportHeader();
    278279        text.append(reportHeader);
    279         Map<String, Setting<?>> settings = Main.pref.getAllSettings();
     280        Map<String, Setting<?>> settings = Preferences.main().getAllSettings();
    280281        Set<String> keys = new HashSet<>(settings.keySet());
    281282        for (String key : keys) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java

    r13434 r14149  
    1818import javax.swing.JPopupMenu;
    1919
    20 import org.openstreetmap.josm.Main;
     20import org.openstreetmap.josm.data.Preferences;
    2121import org.openstreetmap.josm.data.coor.EastNorth;
    2222import org.openstreetmap.josm.data.coor.LatLon;
     
    234234
    235235        computeSnapAngles();
    236         Main.pref.addWeakKeyPreferenceChangeListener(DRAW_ANGLESNAP_ANGLES, e -> this.computeSnapAngles());
     236        Preferences.main().addWeakKeyPreferenceChangeListener(DRAW_ANGLESNAP_ANGLES, e -> this.computeSnapAngles());
    237237    }
    238238
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r14148 r14149  
    3636import org.openstreetmap.josm.Main;
    3737import org.openstreetmap.josm.data.preferences.ColorInfo;
     38import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    3839import org.openstreetmap.josm.data.preferences.NamedColorProperty;
    3940import org.openstreetmap.josm.data.preferences.PreferencesReader;
     
    116117    private final HashMap<String, ListenerList<org.openstreetmap.josm.spi.preferences.PreferenceChangedListener>> keyListeners = new HashMap<>();
    117118
     119    private static final Preferences defaultInstance = new Preferences(JosmBaseDirectories.getInstance());
     120
    118121    /**
    119122     * Constructs a new {@code Preferences}.
     
    141144        settingsMap.putAll(pref.settingsMap);
    142145        defaultsMap.putAll(pref.defaultsMap);
     146    }
     147
     148    /**
     149     * Returns the main (default) preferences instance.
     150     * @return the main (default) preferences instance
     151     * @since 14149
     152     */
     153    public static Preferences main() {
     154        return defaultInstance;
    143155    }
    144156
     
    274286    public static Collection<String> getAllPossiblePreferenceDirs() {
    275287        Set<String> locations = new HashSet<>();
    276         addPossibleResourceDir(locations, Config.getDirs().getPreferencesDirectory(false).getPath());
    277         addPossibleResourceDir(locations, Config.getDirs().getUserDataDirectory(false).getPath());
     288        addPossibleResourceDir(locations, defaultInstance.dirs.getPreferencesDirectory(false).getPath());
     289        addPossibleResourceDir(locations, defaultInstance.dirs.getUserDataDirectory(false).getPath());
    278290        addPossibleResourceDir(locations, getSystemEnv("JOSM_RESOURCES"));
    279291        addPossibleResourceDir(locations, getSystemProperty("josm.resources"));
  • 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            }
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r14138 r14149  
    2929import java.util.zip.ZipFile;
    3030
    31 import org.openstreetmap.josm.Main;
     31import org.openstreetmap.josm.data.Preferences;
    3232import org.openstreetmap.josm.spi.preferences.Config;
    3333import org.openstreetmap.josm.tools.HttpClient;
     
    298298                cacheFile = new File(Config.getDirs().getUserDataDirectory(false), name.substring("josmdir://".length()));
    299299            } else if (name.startsWith("josmplugindir://")) {
    300                 cacheFile = new File(Main.pref.getPluginsDirectory(), name.substring("josmplugindir://".length()));
     300                cacheFile = new File(Preferences.main().getPluginsDirectory(), name.substring("josmplugindir://".length()));
    301301            } else {
    302302                cacheFile = new File(name);
  • trunk/src/org/openstreetmap/josm/plugins/Plugin.java

    r14005 r14149  
    1111import java.util.List;
    1212
    13 import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.data.Preferences;
    1414import org.openstreetmap.josm.gui.MapFrame;
    1515import org.openstreetmap.josm.gui.MapFrameListener;
     
    167167     */
    168168    public ClassLoader getPluginResourceClassLoader() {
    169         File pluginDir = Main.pref.getPluginsDirectory();
     169        File pluginDir = Preferences.main().getPluginsDirectory();
    170170        File pluginJar = new File(pluginDir, info.name + ".jar");
    171171        final URL pluginJarUrl = Utils.fileToURL(pluginJar);
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java

    r13761 r14149  
    1515import java.util.LinkedList;
    1616
    17 import org.openstreetmap.josm.Main;
     17import org.openstreetmap.josm.data.Preferences;
    1818import org.openstreetmap.josm.data.Version;
    1919import org.openstreetmap.josm.gui.ExtendedDialog;
     
    155155    @Override
    156156    protected void realRun() throws SAXException, IOException {
    157         File pluginDir = Main.pref.getPluginsDirectory();
     157        File pluginDir = Preferences.main().getPluginsDirectory();
    158158        if (!pluginDir.exists() && !pluginDir.mkdirs()) {
    159159            String message = tr("Failed to create plugin directory ''{0}''", pluginDir.toString());
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r14121 r14149  
    5555import org.openstreetmap.josm.Main;
    5656import org.openstreetmap.josm.actions.RestartAction;
     57import org.openstreetmap.josm.data.Preferences;
    5758import org.openstreetmap.josm.data.PreferencesUtils;
    5859import org.openstreetmap.josm.data.Version;
     
    535536        }
    536537        if (NetworkManager.isOffline(OnlineResource.JOSM_WEBSITE)) {
    537             for (String updateSite : Main.pref.getPluginSites()) {
     538            for (String updateSite : Preferences.main().getPluginSites()) {
    538539                try {
    539540                    OnlineResource.JOSM_WEBSITE.checkOfflineAccess(updateSite, Config.getUrls().getJOSMWebsite());
     
    598599        // Update plugin list
    599600        final ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(
    600                 Main.pref.getOnlinePluginSites());
     601                Preferences.main().getOnlinePluginSites());
    601602        MainApplication.worker.submit(pluginInfoDownloadTask);
    602603
     
    743744    private static void extendJoinedPluginResourceCL(Collection<PluginInformation> plugins) {
    744745        // iterate all plugins and collect all libraries of all plugins:
    745         File pluginDir = Main.pref.getPluginsDirectory();
     746        File pluginDir = Preferences.main().getPluginsDirectory();
    746747        DynamicURLClassLoader cl = getJoinedPluginResourceCL();
    747748
     
    10761077            ReadRemotePluginInformationTask task1 = new ReadRemotePluginInformationTask(
    10771078                    monitor.createSubTaskMonitor(1, false),
    1078                     Main.pref.getOnlinePluginSites(), displayErrMsg
     1079                    Preferences.main().getOnlinePluginSites(), displayErrMsg
    10791080            );
    10801081            task1.run();
     
    12481249     */
    12491250    public static void installDownloadedPlugins(Collection<PluginInformation> pluginsToLoad, boolean dowarn) {
    1250         File pluginDir = Main.pref.getPluginsDirectory();
     1251        File pluginDir = Preferences.main().getPluginsDirectory();
    12511252        if (!pluginDir.exists() || !pluginDir.isDirectory() || !pluginDir.canWrite())
    12521253            return;
     
    13261327     */
    13271328    public static File findUpdatedJar(String name) {
    1328         File pluginDir = Main.pref.getPluginsDirectory();
     1329        File pluginDir = Preferences.main().getPluginsDirectory();
    13291330        // Find the downloaded file. We have tried to install the downloaded plugins
    13301331        // (PluginHandler.installDownloadedPlugins). This succeeds depending on the platform.
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r12846 r14149  
    3131import javax.swing.JScrollPane;
    3232
    33 import org.openstreetmap.josm.Main;
     33import org.openstreetmap.josm.data.Preferences;
    3434import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    3535import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    245245     */
    246246    protected void cachePluginList(String site, String list) {
    247         File pluginDir = Main.pref.getPluginsDirectory();
     247        File pluginDir = Preferences.main().getPluginsDirectory();
    248248        if (!pluginDir.exists() && !pluginDir.mkdirs()) {
    249249            Logging.warn(tr("Failed to create plugin directory ''{0}''. Cannot cache plugin list from plugin site ''{1}''.",
     
    318318        }
    319319
    320         File pluginDir = Main.pref.getPluginsDirectory();
     320        File pluginDir = Preferences.main().getPluginsDirectory();
    321321        for (String site: sites) {
    322322            String printsite = site.replaceAll("%<(.*)>", "");
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r14138 r14149  
    2222import javax.swing.text.JTextComponent;
    2323
    24 import org.openstreetmap.josm.Main;
     24import org.openstreetmap.josm.data.Preferences;
    2525import org.openstreetmap.josm.spi.preferences.Config;
    2626
     
    386386        PlatformManager.getPlatform().initSystemShortcuts();
    387387        // (2) User defined shortcuts
    388         Main.pref.getAllPrefixCollectionKeys("shortcut.entry.").stream()
     388        Preferences.main().getAllPrefixCollectionKeys("shortcut.entry.").stream()
    389389                .map(Shortcut::new)
    390390                .filter(sc -> !findShortcut(sc.getAssignedKey(), sc.getAssignedModifier()).isPresent())
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r14143 r14149  
    1616import org.openstreetmap.josm.actions.DeleteAction;
    1717import org.openstreetmap.josm.command.DeleteCommand;
     18import org.openstreetmap.josm.data.Preferences;
    1819import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    1920import org.openstreetmap.josm.data.preferences.JosmUrls;
     
    104105        System.setProperty("josm.home", josmHome);
    105106        TimeZone.setDefault(DateUtils.UTC);
    106         Config.setPreferencesInstance(Main.pref);
     107        Preferences pref = Preferences.main();
     108        Config.setPreferencesInstance(pref);
    107109        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
    108110        Config.setUrlsProvider(JosmUrls.getInstance());
    109         Main.pref.resetToInitialState();
    110         Main.pref.enableSaveOnPut(false);
     111        pref.resetToInitialState();
     112        pref.enableSaveOnPut(false);
    111113        I18n.init();
    112114        // initialize the plaform hook, and
     
    115117
    116118        Logging.setLogLevel(Logging.LEVEL_INFO);
    117         Main.pref.init(false);
     119        pref.init(false);
    118120        String url = Config.getPref().get("osm-server.url");
    119121        if (url == null || url.isEmpty() || isProductionApiUrl(url)) {
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java

    r14052 r14149  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.TestUtils;
     16import org.openstreetmap.josm.data.Preferences;
    1717import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1818import org.openstreetmap.josm.plugins.PluginDownloadTask;
     
    6262            new File(TestUtils.getTestDataRoot()), "__files/" + this.pluginPath
    6363        );
    64         final File pluginDir = Main.pref.getPluginsDirectory();
     64        final File pluginDir = Preferences.main().getPluginsDirectory();
    6565        final File pluginFile = new File(pluginDir, "dummy_plugin.jar");
    6666        final File pluginFileNew = new File(pluginDir, "dummy_plugin.jar.new");
     
    104104            new File(TestUtils.getTestDataRoot()), "__files/" + this.pluginPath
    105105        );
    106         final File pluginDir = Main.pref.getPluginsDirectory();
     106        final File pluginDir = Preferences.main().getPluginsDirectory();
    107107        final File pluginFile = new File(pluginDir, "corrupted_plugin.jar");
    108108        final File pluginFileNew = new File(pluginDir, "corrupted_plugin.jar.new");
  • trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.java

    r14138 r14149  
    66import org.junit.Rule;
    77import org.junit.Test;
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.testutils.JOSMTestRules;
    109
     
    3332            "  <tag key='osm-server.url' value='http://fake.xxx/api'/>%n" +
    3433            "</preferences>%n", Version.getInstance().getVersion()),
    35                 Main.pref.toXML(true));
     34                Preferences.main().toXML(true));
    3635    }
    3736}
  • trunk/test/unit/org/openstreetmap/josm/data/preferences/NamedColorPropertyTest.java

    r12989 r14149  
    1111import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.data.Preferences;
    1414import org.openstreetmap.josm.spi.preferences.Config;
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1818
    1919/**
    20  * Test {@link ColorProperty}
     20 * Test {@link NamedColorProperty}
    2121 * @author Michael Zangl
    2222 */
     
    3939
    4040    /**
    41      * Test {@link ColorProperty#get()}
     41     * Test {@link NamedColorProperty#get()}
    4242     */
    4343    @Test
     
    4747
    4848    /**
    49      * Test {@link ColorProperty#put}
     49     * Test {@link NamedColorProperty#put}
    5050     */
    5151    @Test
     
    6767    public void testColorAlpha() {
    6868        assertEquals(0x12, new NamedColorProperty("foo", new Color(0x12345678, true)).get().getAlpha());
    69         assertTrue(Main.pref.putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar")));
     69        assertTrue(Preferences.main().putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar")));
    7070        assertEquals(0x12, new NamedColorProperty("bar", Color.RED).get().getAlpha());
    7171    }
     
    8080
    8181    /**
    82      * Test {@link ColorProperty#getChildColor(String)}
     82     * Test {@link NamedColorProperty#getChildColor(String)}
    8383     */
    8484    @Test
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r14138 r14149  
    2626import org.junit.Rule;
    2727import org.junit.Test;
    28 import org.openstreetmap.josm.Main;
    2928import org.openstreetmap.josm.TestUtils;
    3029import org.openstreetmap.josm.data.Bounds;
     
    217216        assertEquals(0xff00ff00, paintedSlippyMap.getRGB(0, 0));
    218217
    219         assertEquals("Green Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));
     218        assertEquals("Green Tiles", Config.getPref().get("slippy_map_chooser.mapstyle", "Fail"));
    220219    }
    221220
     
    244243        this.assertSingleSelectedSourceLabel("Magenta Tiles");
    245244
    246         assertEquals("Magenta Tiles", Main.pref.get("slippy_map_chooser.mapstyle", "Fail"));
     245        assertEquals("Magenta Tiles", Config.getPref().get("slippy_map_chooser.mapstyle", "Fail"));
    247246    }
    248247
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java

    r14081 r14149  
    66import org.junit.Rule;
    77import org.junit.Test;
    8 import org.openstreetmap.josm.Main;
    98import org.openstreetmap.josm.TestUtils;
     9import org.openstreetmap.josm.data.Preferences;
    1010import org.openstreetmap.josm.testutils.JOSMTestRules;
    1111import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
     
    3535            "All the preferences of this group are default, nothing to save", JOptionPane.OK_OPTION
    3636        ));
    37         new ExportProfileAction(Main.pref, "foo", "bar").actionPerformed(null);
    38         new ExportProfileAction(Main.pref, "expert", "expert").actionPerformed(null);
     37        new ExportProfileAction(Preferences.main(), "foo", "bar").actionPerformed(null);
     38        new ExportProfileAction(Preferences.main(), "expert", "expert").actionPerformed(null);
    3939    }
    4040}
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    r14138 r14149  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.TestUtils;
     25import org.openstreetmap.josm.data.Preferences;
    2526import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    2627import org.openstreetmap.josm.gui.util.GuiHelper;
     
    9798        this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar");
    9899        this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar");
    99         this.pluginDir = Main.pref.getPluginsDirectory();
     100        this.pluginDir = Preferences.main().getPluginsDirectory();
    100101        this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar");
    101102        this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new");
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java

    r14081 r14149  
    1717import org.openstreetmap.josm.Main;
    1818import org.openstreetmap.josm.TestUtils;
     19import org.openstreetmap.josm.data.Preferences;
    1920import org.openstreetmap.josm.spi.preferences.Config;
    2021import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    6667        this.referenceBazJarOld = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v6.jar");
    6768        this.referenceBazJarNew = new File(TestUtils.getTestDataRoot(), "__files/plugin/baz_plugin.v7.jar");
    68         this.pluginDir = Main.pref.getPluginsDirectory();
     69        this.pluginDir = Preferences.main().getPluginsDirectory();
    6970        this.targetDummyJar = new File(this.pluginDir, "dummy_plugin.jar");
    7071        this.targetDummyJarNew = new File(this.pluginDir, "dummy_plugin.jar.new");
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    r14138 r14149  
    1919import org.junit.Rule;
    2020import org.junit.Test;
    21 import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.data.Preferences;
    2222import org.openstreetmap.josm.data.gpx.GpxData;
    2323import org.openstreetmap.josm.data.osm.DataSet;
     
    9393        // Download complete list of plugins
    9494        ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask(
    95                 Main.pref.getOnlinePluginSites());
     95                Preferences.main().getOnlinePluginSites());
    9696        pluginInfoDownloadTask.run();
    9797        List<PluginInformation> plugins = pluginInfoDownloadTask.getAvailablePlugins();
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r14138 r14149  
    2626import org.openstreetmap.josm.actions.DeleteAction;
    2727import org.openstreetmap.josm.command.DeleteCommand;
     28import org.openstreetmap.josm.data.Preferences;
    2829import org.openstreetmap.josm.data.UserIdentityManager;
    2930import org.openstreetmap.josm.data.Version;
     
    418419        }
    419420
    420         Config.setPreferencesInstance(Main.pref);
     421        Preferences pref = Preferences.main();
     422        Config.setPreferencesInstance(pref);
    421423        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
    422424        Config.setUrlsProvider(JosmUrls.getInstance());
     
    449451        if (usePreferences) {
    450452            @SuppressWarnings("unchecked")
    451             final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(Main.pref, "defaultsMap");
     453            final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(pref, "defaultsMap");
    452454            defaultsMap.clear();
    453             Main.pref.resetToInitialState();
    454             Main.pref.enableSaveOnPut(false);
     455            pref.resetToInitialState();
     456            pref.enableSaveOnPut(false);
    455457            // No pref init -> that would only create the preferences file.
    456458            // We force the use of a wrong API server, just in case anyone attempts an upload
     
    543545        MemoryManagerTest.resetState(true);
    544546        cleanLayerEnvironment();
    545         Main.pref.resetToInitialState();
     547        Preferences.main().resetToInitialState();
    546548        System.gc();
    547549    }
     
    584586        // TODO: Remove global listeners and other global state.
    585587        ProjectionRegistry.clearProjectionChangeListeners();
    586         Main.pref.resetToInitialState();
     588        Preferences.main().resetToInitialState();
    587589
    588590        if (this.assumeRevisionString != null && this.originalVersion != null) {
Note: See TracChangeset for help on using the changeset viewer.