Changeset 14122 in josm


Ignore:
Timestamp:
2018-08-11T18:18:58+02:00 (8 months ago)
Author:
Don-vip
Message:

see #15229 - minor preferences refactoring

Location:
trunk
Files:
4 edited

Legend:

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

    r14119 r14122  
    693693    }
    694694
    695     /**
    696      * Gets a map of all settings that are currently stored
    697      * @return The settings
    698      */
     695    @Override
    699696    public Map<String, Setting<?>> getAllSettings() {
    700697        return new TreeMap<>(settingsMap);
  • trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java

    r12881 r14122  
    124124
    125125    /**
     126     * Gets a map of all settings that are currently stored
     127     * @return The settings
     128     */
     129    public abstract Map<String, Setting<?>> getAllSettings();
     130
     131    /**
    126132     * Set a value for a certain setting. The changed setting is saved to the preference file immediately.
    127133     * Due to caching mechanisms on modern operating systems and hardware, this shouldn't be a performance problem.
  • trunk/src/org/openstreetmap/josm/spi/preferences/MemoryPreferences.java

    r12987 r14122  
    77import java.util.Objects;
    88import java.util.Set;
     9import java.util.TreeMap;
    910
    1011/**
     
    2223    @Override
    2324    public boolean putSetting(String key, Setting<?> setting) {
    24         Setting current = settings.get(key);
     25        Setting<?> current = settings.get(key);
    2526        if (setting == null) {
    2627            settings.remove(key);
     
    3334    @Override
    3435    public <T extends Setting<?>> T getSetting(String key, T def, Class<T> klass) {
    35         Setting current = settings.get(key);
     36        Setting<?> current = settings.get(key);
    3637        if (current != null && klass.isInstance(current)) {
    3738            @SuppressWarnings("unchecked")
     
    4546    public Set<String> getKeySet() {
    4647        return Collections.unmodifiableSet(settings.keySet());
     48    }
     49
     50    @Override
     51    public Map<String, Setting<?>> getAllSettings() {
     52        return new TreeMap<>(settings);
    4753    }
    4854
     
    6672        // do nothing
    6773    }
    68 
    6974}
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r14120 r14122  
    4040import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    4141import org.openstreetmap.josm.gui.util.GuiHelper;
     42import org.openstreetmap.josm.spi.preferences.Config;
    4243import org.openstreetmap.josm.testutils.ImagePatternMatching;
    4344import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    225226    @Test
    226227    public void testSourcePrefObeyed() throws Exception {
    227         Main.pref.put("slippy_map_chooser.mapstyle", "Green Tiles");
     228        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    228229
    229230        this.setUpMiniMap();
     
    252253    @Test
    253254    public void testSourcePrefInvalid() throws Exception {
    254         Main.pref.put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles");
     255        Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles");
    255256
    256257        this.setUpMiniMap();
     
    277278        MainApplication.getLayerManager().addLayer(new TestLayer());
    278279
    279         Main.pref.put("slippy_map_chooser.mapstyle", "White Tiles");
     280        Config.getPref().put("slippy_map_chooser.mapstyle", "White Tiles");
    280281        // ensure projection matches JMapViewer's
    281282        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     
    415416    @Test
    416417    public void testShowDownloadedArea() throws Exception {
    417         Main.pref.put("slippy_map_chooser.mapstyle", "Green Tiles");
    418         Main.pref.putBoolean("slippy_map_chooser.show_downloaded_area", false);
     418        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
     419        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false);
    419420
    420421        DataSet dataSet = new DataSet();
     
    574575    @Test
    575576    public void testShowDownloadedAreaLayerSwitching() throws Exception {
    576         Main.pref.put("slippy_map_chooser.mapstyle", "Green Tiles");
    577         Main.pref.putBoolean("slippy_map_chooser.show_downloaded_area", true);
     577        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
     578        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true);
    578579
    579580        DataSet dataSetA = new DataSet();
Note: See TracChangeset for help on using the changeset viewer.