Changeset 12999 in josm for trunk/src


Ignore:
Timestamp:
2017-10-15T12:26:33+02:00 (7 years ago)
Author:
bastiK
Message:

see #15229 - use Config.getPref() in *Property classes

Location:
trunk/src/org/openstreetmap/josm/data/preferences
Files:
3 edited

Legend:

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

    r12987 r12999  
    22package org.openstreetmap.josm.data.preferences;
    33
    4 import org.openstreetmap.josm.Main;
    5 import org.openstreetmap.josm.data.Preferences;
     4import org.openstreetmap.josm.spi.preferences.Config;
     5import org.openstreetmap.josm.spi.preferences.IPreferences;
    66import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
    77import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
     
    152152     * The preferences object this property is for.
    153153     */
    154     protected final Preferences preferences;
     154    protected final IPreferences preferences;
    155155    protected final String key;
    156156    protected final T defaultValue;
     
    164164    public AbstractProperty(String key, T defaultValue) {
    165165        // Main.pref should not change in production but may change during tests.
    166         preferences = Main.pref;
     166        preferences = Config.getPref();
    167167        this.key = key;
    168168        this.defaultValue = defaultValue;
     
    227227     * Gets the preferences used for this property.
    228228     * @return The preferences for this property.
    229      * @since 10824
    230      */
    231     protected Preferences getPreferences() {
     229     * @since 12999
     230     */
     231    protected IPreferences getPreferences() {
    232232        return preferences;
    233233    }
  • trunk/src/org/openstreetmap/josm/data/preferences/CollectionProperty.java

    r12840 r12999  
    22package org.openstreetmap.josm.data.preferences;
    33
     4import java.util.ArrayList;
    45import java.util.Collection;
    56
     
    2728    @Override
    2829    public Collection<String> get() {
    29         return getPreferences().getCollection(getKey(), getDefaultValue());
     30        return getPreferences().getList(getKey(), new ArrayList<>(getDefaultValue()));
    3031    }
    3132
    3233    @Override
    3334    public boolean put(Collection<String> value) {
    34         return getPreferences().putCollection(getKey(), value);
     35        return getPreferences().putList(getKey(), new ArrayList<>(value));
    3536    }
    3637}
  • trunk/src/org/openstreetmap/josm/data/preferences/ColorProperty.java

    r12987 r12999  
    55import java.util.Locale;
    66
     7import org.openstreetmap.josm.Main;
    78import org.openstreetmap.josm.tools.CheckParameterUtil;
    89import org.openstreetmap.josm.tools.ColorHelper;
     
    3637        CheckParameterUtil.ensureParameterNotNull(defaultValue, "defaultValue");
    3738        this.name = colName;
    38         getPreferences().registerColor(getColorKey(colName), colName);
     39        Main.pref.registerColor(getColorKey(colName), colName);
    3940    }
    4041
Note: See TracChangeset for help on using the changeset viewer.