Changeset 7027 in josm for trunk/src/org


Ignore:
Timestamp:
2014-04-29T15:35:53+02:00 (11 years ago)
Author:
Don-vip
Message:

fix more warnings (-Xlint:rawtypes), remove deprecated method and unused imports

Location:
trunk/src/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r7005 r7027  
    8686        text.append("\n");
    8787        if (Main.platform.getClass() == PlatformHookUnixoid.class) {
    88             // Add Java package details for Debian/Ubuntu 
     88            // Add Java package details for Debian/Ubuntu
    8989            String packageDetails = ((PlatformHookUnixoid) Main.platform).getJavaPackageDetails();
    9090            if (packageDetails != null) {
     
    9393                text.append("\n");
    9494            }
    95             // Add WebStart package details for Debian/Ubuntu, if run from JNLP 
     95            // Add WebStart package details for Debian/Ubuntu, if run from JNLP
    9696            if (Package.getPackage("javax.jnlp") != null) {
    9797                String webStartDetails = ((PlatformHookUnixoid) Main.platform).getWebStartPackageDetails();
     
    159159        text.append(reportHeader);
    160160        try {
    161             Map<String, Setting> settings = Main.pref.getAllSettings();
     161            Map<String, Setting<?>> settings = Main.pref.getAllSettings();
    162162            settings.remove("osm-server.username");
    163163            settings.remove("osm-server.password");
     
    170170                }
    171171            }
    172             for (Entry<String, Setting> entry : settings.entrySet()) {
     172            for (Entry<String, Setting<?>> entry : settings.entrySet()) {
    173173                text.append(entry.getKey()).append("=").append(entry.getValue().getValue().toString()).append("\n");
    174174            }
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r7012 r7027  
    6060 */
    6161public final class CustomConfigurator {
    62    
     62
    6363    private CustomConfigurator() {
    6464        // Hide default constructor for utils classes
    6565    }
    66    
     66
    6767    private static StringBuilder summary = new StringBuilder();
    6868
     
    216216    public static void exportPreferencesKeysByPatternToFile(String fileName, boolean append, String pattern) {
    217217        List<String> keySet = new ArrayList<>();
    218         Map<String, Setting> allSettings = Main.pref.getAllSettings();
     218        Map<String, Setting<?>> allSettings = Main.pref.getAllSettings();
    219219        for (String key: allSettings.keySet()) {
    220220            if (key.matches(pattern)) keySet.add(key);
     
    751751
    752752        private static void replacePreferences(Preferences fragment, Preferences mainpref) {
    753             for (Entry<String, Setting> entry: fragment.settingsMap.entrySet()) {
     753            for (Entry<String, Setting<?>> entry: fragment.settingsMap.entrySet()) {
    754754                mainpref.putSetting(entry.getKey(), entry.getValue());
    755755            }
     
    757757
    758758        private static void appendPreferences(Preferences fragment, Preferences mainpref) {
    759             for (Entry<String, Setting> entry: fragment.settingsMap.entrySet()) {
     759            for (Entry<String, Setting<?>> entry: fragment.settingsMap.entrySet()) {
    760760                String key = entry.getKey();
    761761                if (entry.getValue() instanceof StringSetting) {
     
    807807        private static void deletePreferenceValues(Preferences fragment, Preferences mainpref) {
    808808
    809             for (Entry<String, Setting> entry : fragment.settingsMap.entrySet()) {
     809            for (Entry<String, Setting<?>> entry : fragment.settingsMap.entrySet()) {
    810810                String key = entry.getKey();
    811811                if (entry.getValue() instanceof StringSetting) {
     
    867867
    868868    private static void deletePreferenceKeyByPattern(String pattern, Preferences pref) {
    869         Map<String, Setting> allSettings = pref.getAllSettings();
    870         for (Entry<String, Setting> entry : allSettings.entrySet()) {
     869        Map<String, Setting<?>> allSettings = pref.getAllSettings();
     870        for (Entry<String, Setting<?>> entry : allSettings.entrySet()) {
    871871            String key = entry.getKey();
    872872            if (key.matches(pattern)) {
     
    878878
    879879    private static void deletePreferenceKey(String key, Preferences pref) {
    880         Map<String, Setting> allSettings = pref.getAllSettings();
     880        Map<String, Setting<?>> allSettings = pref.getAllSettings();
    881881        if (allSettings.containsKey(key)) {
    882882            log("Deleting preferences: deleting key from preferences: " + key);
     
    10081008        tmpPref.settingsMap.clear();
    10091009
    1010         Map<String, Setting> tmp = new HashMap<>();
     1010        Map<String, Setting<?>> tmp = new HashMap<>();
    10111011        for (Entry<String, String> e : stringMap.entrySet()) {
    10121012            tmp.put(e.getKey(), new StringSetting(e.getValue()));
     
    10171017
    10181018        for (Entry<String, List<Collection<String>>> e : listlistMap.entrySet()) {
    1019             @SuppressWarnings("unchecked") List<List<String>> value = (List)e.getValue();
     1019            @SuppressWarnings("unchecked")
     1020            List<List<String>> value = (List)e.getValue();
    10201021            tmp.put(e.getKey(), new ListListSetting(value));
    10211022        }
     
    10231024            tmp.put(e.getKey(), new MapListSetting(e.getValue()));
    10241025        }
    1025         for (Entry<String, Setting> e : tmp.entrySet()) {
     1026        for (Entry<String, Setting<?>> e : tmp.entrySet()) {
    10261027            if (e.getValue().equals(tmpPref.defaultsMap.get(e.getKey()))) continue;
    10271028            tmpPref.settingsMap.put(e.getKey(), e.getValue());
     
    10441045
    10451046        if (includeDefaults) {
    1046             for (Map.Entry<String, Setting> e: tmpPref.defaultsMap.entrySet()) {
    1047                 Setting setting = e.getValue();
     1047            for (Map.Entry<String, Setting<?>> e: tmpPref.defaultsMap.entrySet()) {
     1048                Setting<?> setting = e.getValue();
    10481049                if (setting instanceof StringSetting) {
    10491050                    stringMap.put(e.getKey(), ((StringSetting) setting).getValue());
     
    10571058            }
    10581059        }
    1059         Iterator<Map.Entry<String, Setting>> it = tmpPref.settingsMap.entrySet().iterator();
     1060        Iterator<Map.Entry<String, Setting<?>>> it = tmpPref.settingsMap.entrySet().iterator();
    10601061        while (it.hasNext()) {
    1061             Map.Entry<String, Setting> e = it.next();
     1062            Map.Entry<String, Setting<?>> e = it.next();
    10621063            if (e.getValue().getValue() == null) {
    10631064                it.remove();
     
    10651066        }
    10661067
    1067         for (Map.Entry<String, Setting> e: tmpPref.settingsMap.entrySet()) {
    1068             Setting setting = e.getValue();
     1068        for (Map.Entry<String, Setting<?>> e: tmpPref.settingsMap.entrySet()) {
     1069            Setting<?> setting = e.getValue();
    10691070            if (setting instanceof StringSetting) {
    10701071                stringMap.put(e.getKey(), ((StringSetting) setting).getValue());
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r7026 r7027  
    8989
    9090    /**
    91      * Map the setting name to the current value of the setting.
     91     * Maps the setting name to the current value of the setting.
    9292     * The map must not contain null as key or value. The mapped setting objects
    9393     * must not have a null value.
    9494     */
    95     protected final SortedMap<String, Setting> settingsMap = new TreeMap<>();
    96     /**
    97      * Map the setting name to the default value of the setting.
     95    protected final SortedMap<String, Setting<?>> settingsMap = new TreeMap<>();
     96
     97    /**
     98     * Maps the setting name to the default value of the setting.
    9899     * The map must not contain null as key or value. The value of the mapped
    99100     * setting objects can be null.
    100101     */
    101     protected final SortedMap<String, Setting> defaultsMap = new TreeMap<>();
    102     // maps color keys to human readable color name
     102    protected final SortedMap<String, Setting<?>> defaultsMap = new TreeMap<>();
     103
     104    /**
     105     * Maps color keys to human readable color name
     106     */
    103107    protected final SortedMap<String, String> colornames = new TreeMap<>();
    104108
     
    261265     */
    262266    public static class ListListSetting extends AbstractSetting<List<List<String>>> {
     267
    263268        /**
    264269         * Constructs a new {@code ListListSetting} with the given value
     
    269274            consistencyTest();
    270275        }
     276
    271277        /**
    272278         * Convenience factory method.
     
    284290            return new ListListSetting(null);
    285291        }
    286         @Override public boolean equalVal(List<List<String>> otherVal) {
     292
     293        @Override
     294        public boolean equalVal(List<List<String>> otherVal) {
    287295            if (value == null) return otherVal == null;
    288296            if (otherVal == null) return false;
     
    295303            return true;
    296304        }
    297         @Override public ListListSetting copy() {
     305
     306        @Override
     307        public ListListSetting copy() {
    298308            if (value == null) return new ListListSetting(null);
    299309
     
    305315            return new ListListSetting(Collections.unmodifiableList(copy));
    306316        }
     317
    307318        private void consistencyTest() {
    308319            if (value == null) return;
     
    312323            }
    313324        }
    314         @Override public void visit(SettingVisitor visitor) {
     325
     326        @Override
     327        public void visit(SettingVisitor visitor) {
    315328            visitor.visit(this);
    316329        }
    317         @Override public ListListSetting getNullInstance() {
     330
     331        @Override
     332        public ListListSetting getNullInstance() {
    318333            return new ListListSetting(null);
    319334        }
     335
    320336        @Override
    321337        public boolean equals(Object other) {
     
    329345     */
    330346    public static class MapListSetting extends AbstractSetting<List<Map<String, String>>> {
     347
    331348        /**
    332349         * Constructs a new {@code MapListSetting} with the given value
     
    337354            consistencyTest();
    338355        }
    339         @Override public boolean equalVal(List<Map<String, String>> otherVal) {
     356
     357        @Override
     358        public boolean equalVal(List<Map<String, String>> otherVal) {
    340359            if (value == null) return otherVal == null;
    341360            if (otherVal == null) return false;
     
    348367            return true;
    349368        }
     369
    350370        private static boolean equalMap(Map<String, String> a, Map<String, String> b) {
    351371            if (a == null) return b == null;
     
    357377            return true;
    358378        }
    359         @Override public MapListSetting copy() {
     379
     380        @Override
     381        public MapListSetting copy() {
    360382            if (value == null) return new MapListSetting(null);
    361383            List<Map<String, String>> copy = new ArrayList<>(value.size());
     
    366388            return new MapListSetting(Collections.unmodifiableList(copy));
    367389        }
     390
    368391        private void consistencyTest() {
    369392            if (value == null) return;
     
    374397            }
    375398        }
    376         @Override public void visit(SettingVisitor visitor) {
     399
     400        @Override
     401        public void visit(SettingVisitor visitor) {
    377402            visitor.visit(this);
    378403        }
    379         @Override public MapListSetting getNullInstance() {
     404
     405        @Override
     406        public MapListSetting getNullInstance() {
    380407            return new MapListSetting(null);
    381408        }
     409
    382410        @Override
    383411        public boolean equals(Object other) {
     
    396424    public interface PreferenceChangeEvent {
    397425        String getKey();
    398         Setting getOldValue();
    399         Setting getNewValue();
     426        Setting<?> getOldValue();
     427        Setting<?> getNewValue();
    400428    }
    401429
     
    406434    private static class DefaultPreferenceChangeEvent implements PreferenceChangeEvent {
    407435        private final String key;
    408         private final Setting oldValue;
    409         private final Setting newValue;
    410 
    411         public DefaultPreferenceChangeEvent(String key, Setting oldValue, Setting newValue) {
     436        private final Setting<?> oldValue;
     437        private final Setting<?> newValue;
     438
     439        public DefaultPreferenceChangeEvent(String key, Setting<?> oldValue, Setting<?> newValue) {
    412440            this.key = key;
    413441            this.oldValue = oldValue;
     
    419447            return key;
    420448        }
    421         @Override
    422         public Setting getOldValue() {
     449
     450        @Override
     451        public Setting<?> getOldValue() {
    423452            return oldValue;
    424453        }
    425         @Override
    426         public Setting getNewValue() {
     454
     455        @Override
     456        public Setting<?> getNewValue() {
    427457            return newValue;
    428458        }
     
    437467    private final CopyOnWriteArrayList<PreferenceChangedListener> listeners = new CopyOnWriteArrayList<>();
    438468
     469    /**
     470     * Adds a new preferences listener.
     471     * @param listener The listener to add
     472     */
    439473    public void addPreferenceChangeListener(PreferenceChangedListener listener) {
    440474        if (listener != null) {
     
    443477    }
    444478
     479    /**
     480     * Removes a preferences listener.
     481     * @param listener The listener to remove
     482     */
    445483    public void removePreferenceChangeListener(PreferenceChangedListener listener) {
    446484        listeners.remove(listener);
    447485    }
    448486
    449     protected void firePreferenceChanged(String key, Setting oldValue, Setting newValue) {
     487    protected void firePreferenceChanged(String key, Setting<?> oldValue, Setting<?> newValue) {
    450488        PreferenceChangeEvent evt = new DefaultPreferenceChangeEvent(key, oldValue, newValue);
    451489        for (PreferenceChangedListener l : listeners) {
     
    595633    public synchronized Map<String, String> getAllPrefix(final String prefix) {
    596634        final Map<String,String> all = new TreeMap<>();
    597         for (final Entry<String,Setting> e : settingsMap.entrySet()) {
     635        for (final Entry<String,Setting<?>> e : settingsMap.entrySet()) {
    598636            if (e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting)) {
    599637                all.put(e.getKey(), ((StringSetting) e.getValue()).getValue());
     
    605643    public synchronized List<String> getAllPrefixCollectionKeys(final String prefix) {
    606644        final List<String> all = new LinkedList<>();
    607         for (Map.Entry<String, Setting> entry : settingsMap.entrySet()) {
     645        for (Map.Entry<String, Setting<?>> entry : settingsMap.entrySet()) {
    608646            if (entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting) {
    609647                all.add(entry.getKey());
     
    615653    public synchronized Map<String, String> getAllColors() {
    616654        final Map<String,String> all = new TreeMap<>();
    617         for (final Entry<String,Setting> e : defaultsMap.entrySet()) {
     655        for (final Entry<String,Setting<?>> e : defaultsMap.entrySet()) {
    618656            if (e.getKey().startsWith("color.") && e.getValue() instanceof StringSetting) {
    619657                StringSetting d = (StringSetting) e.getValue();
     
    623661            }
    624662        }
    625         for (final Entry<String,Setting> e : settingsMap.entrySet()) {
     663        for (final Entry<String,Setting<?>> e : settingsMap.entrySet()) {
    626664            if (e.getKey().startsWith("color.") && (e.getValue() instanceof StringSetting)) {
    627665                all.put(e.getKey().substring(6), ((StringSetting) e.getValue()).getValue());
     
    643681        boolean generic = getBoolean(key, def);
    644682        String skey = key+"."+specName;
    645         Setting prop = settingsMap.get(skey);
     683        Setting<?> prop = settingsMap.get(skey);
    646684        if (prop instanceof StringSetting)
    647685            return Boolean.parseBoolean(((StringSetting)prop).getValue());
     
    9801018     * @return true, if something has changed (i.e. value is different than before)
    9811019     */
    982     public boolean putSetting(final String key, Setting setting) {
     1020    public boolean putSetting(final String key, Setting<?> setting) {
    9831021        CheckParameterUtil.ensureParameterNotNull(key);
    9841022        if (setting != null && setting.getValue() == null)
    9851023            throw new IllegalArgumentException("setting argument must not have null value");
    986         Setting settingOld;
    987         Setting settingCopy = null;
     1024        Setting<?> settingOld;
     1025        Setting<?> settingCopy = null;
    9881026        synchronized (this) {
    9891027            if (setting == null) {
     
    10111049    }
    10121050
    1013     public synchronized Setting getSetting(String key, Setting def) {
     1051    public synchronized Setting<?> getSetting(String key, Setting<?> def) {
    10141052        return getSetting(key, def, Setting.class);
    10151053    }
     
    10271065     */
    10281066    @SuppressWarnings("unchecked")
    1029     public synchronized <T extends Setting> T getSetting(String key, T def, Class<T> klass) {
     1067    public synchronized <T extends Setting<?>> T getSetting(String key, T def, Class<T> klass) {
    10301068        CheckParameterUtil.ensureParameterNotNull(key);
    10311069        CheckParameterUtil.ensureParameterNotNull(def);
    1032         Setting oldDef = defaultsMap.get(key);
     1070        Setting<?> oldDef = defaultsMap.get(key);
    10331071        if (oldDef != null && oldDef.getValue() != null && def.getValue() != null && !def.equals(oldDef)) {
    10341072            Main.info("Defaults for " + key + " differ: " + def + " != " + defaultsMap.get(key));
     
    10371075            defaultsMap.put(key, def.copy());
    10381076        }
    1039         Setting prop = settingsMap.get(key);
     1077        Setting<?> prop = settingsMap.get(key);
    10401078        if (klass.isInstance(prop)) {
    10411079            return (T) prop;
     
    12371275    }
    12381276
    1239     public Map<String, Setting> getAllSettings() {
     1277    public Map<String, Setting<?>> getAllSettings() {
    12401278        return new TreeMap<>(settingsMap);
    12411279    }
    12421280
    1243     public Map<String, Setting> getAllDefaults() {
     1281    public Map<String, Setting<?>> getAllDefaults() {
    12441282        return new TreeMap<>(defaultsMap);
    12451283    }
     
    15561594                Version.getInstance().getVersion() + "\">\n");
    15571595        SettingToXml toXml = new SettingToXml(b, nopass);
    1558         for (Entry<String, Setting> e : settingsMap.entrySet()) {
     1596        for (Entry<String, Setting<?>> e : settingsMap.entrySet()) {
    15591597            toXml.setKey(e.getKey());
    15601598            e.getValue().visit(toXml);
     
    15841622                "gpxLayer.downloadAlongTrack.area",            // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.area
    15851623                "gpxLayer.downloadAlongTrack.near",            // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.near
    1586                 "validator.tests",                             // 01/2014 - can be removed mid-2014. Replaced by validator.skip
    1587                 "validator.testsBeforeUpload",                 // 01/2014 - can be removed mid-2014. Replaced by validator.skipBeforeUpload
    1588                 "validator.TagChecker.sources",                // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source
    1589                 "validator.TagChecker.usedatafile",            // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source
    1590                 "validator.TagChecker.useignorefile",          // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source
    1591                 "validator.TagChecker.usespellfile",           // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source
    1592                 "validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.sources" // 01/2014 - can be removed mid-2014. Replaced by validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries
     1624                "validator.tests",                             // 01/2014 - can be removed end-2014. Replaced by validator.skip
     1625                "validator.testsBeforeUpload",                 // 01/2014 - can be removed end-2014. Replaced by validator.skipBeforeUpload
     1626                "validator.TagChecker.sources",                // 01/2014 - can be removed end-2014. Replaced by validator.TagChecker.source
     1627                "validator.TagChecker.usedatafile",            // 01/2014 - can be removed end-2014. Replaced by validator.TagChecker.source
     1628                "validator.TagChecker.useignorefile",          // 01/2014 - can be removed end-2014. Replaced by validator.TagChecker.source
     1629                "validator.TagChecker.usespellfile",           // 01/2014 - can be removed end-2014. Replaced by validator.TagChecker.source
     1630                "validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.sources" // 01/2014 - can be removed end-2014. Replaced by validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries
    15931631        };
    15941632        for (String key : obsolete) {
     
    16001638    }
    16011639
    1602     public static boolean isEqual(Setting a, Setting b) {
     1640    public static boolean isEqual(Setting<?> a, Setting<?> b) {
    16031641        if (a == null) return b == null;
    16041642        return a.equals(b);
    16051643    }
    1606 
    16071644}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r7005 r7027  
    205205        @Override
    206206        public boolean evaluate(OsmPrimitive primitive) {
    207             return matchesPrimitive(primitive);
    208         }
    209 
    210         /**
    211          * Tests whether the {@link OsmPrimitive} contains a deprecated tag which is represented by this {@code MapCSSTagChecker}.
    212          *
    213          * @param primitive the primitive to test
    214          * @return true when the primitive contains a deprecated tag
    215          * @deprecated since it does not handle MapCSS-classes
    216          */
    217         @Deprecated
    218         boolean matchesPrimitive(OsmPrimitive primitive) {
     207            // Tests whether the primitive contains a deprecated tag which is represented by this MapCSSTagChecker.
    219208            return whichSelectorMatchesPrimitive(primitive) != null;
    220209        }
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverTable.java

    r6890 r7027  
    4040        getActionMap().put("selectPreviousColumnCell", selectPreviousColumnCellAction);
    4141
    42         setRowHeight((int)new JosmComboBox().getPreferredSize().getHeight());
     42        setRowHeight((int)new JosmComboBox<String>().getPreferredSize().getHeight());
    4343    }
    4444
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java

    r7026 r7027  
    55
    66import java.awt.Component;
    7 import java.io.BufferedReader;
    8 import java.io.File;
    9 import java.io.FileInputStream;
    10 import java.io.IOException;
    11 import java.io.InputStreamReader;
    127import java.util.ArrayList;
    138import java.util.Arrays;
     
    1611import java.util.LinkedList;
    1712import java.util.List;
    18 import java.util.regex.Matcher;
    19 import java.util.regex.Pattern;
    2013
    2114import javax.swing.DefaultListModel;
     
    2316import javax.swing.JLabel;
    2417import javax.swing.JList;
    25 import javax.swing.JOptionPane;
    2618import javax.swing.ListCellRenderer;
    2719import javax.swing.UIManager;
     
    3022import org.openstreetmap.josm.data.Bounds;
    3123import org.openstreetmap.josm.tools.ImageProvider;
    32 import org.openstreetmap.josm.tools.Utils;
    3324
    3425/**
     
    8475            return name.toLowerCase().compareTo(b.name.toLowerCase());
    8576        }
    86        
     77
    8778        @Override
    8879        public int hashCode() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java

    r7005 r7027  
    166166
    167167    private void readPreferences(Preferences tmpPrefs) {
    168         Map<String, Setting> loaded;
    169         Map<String, Setting> orig = Main.pref.getAllSettings();
    170         Map<String, Setting> defaults = tmpPrefs.getAllDefaults();
     168        Map<String, Setting<?>> loaded;
     169        Map<String, Setting<?>> orig = Main.pref.getAllSettings();
     170        Map<String, Setting<?>> defaults = tmpPrefs.getAllDefaults();
    171171        orig.remove("osm-server.password");
    172172        defaults.remove("osm-server.password");
     
    175175            // plugins preference keys may be changed directly later, after plugins are downloaded
    176176            // so we do not want to show it in the table as "changed" now
    177             Setting pluginSetting = orig.get("plugins");
     177            Setting<?> pluginSetting = orig.get("plugins");
    178178            if (pluginSetting!=null) {
    179179                loaded.put("plugins", pluginSetting);
     
    276276    };
    277277
    278     private List<PrefEntry> prepareData(Map<String, Setting> loaded, Map<String, Setting> orig, Map<String, Setting> defaults) {
     278    private List<PrefEntry> prepareData(Map<String, Setting<?>> loaded, Map<String, Setting<?>> orig, Map<String, Setting<?>> defaults) {
    279279        List<PrefEntry> data = new ArrayList<>();
    280         for (Entry<String, Setting> e : loaded.entrySet()) {
    281             Setting value = e.getValue();
    282             Setting old = orig.get(e.getKey());
    283             Setting def = defaults.get(e.getKey());
     280        for (Entry<String, Setting<?>> e : loaded.entrySet()) {
     281            Setting<?> value = e.getValue();
     282            Setting<?> old = orig.get(e.getKey());
     283            Setting<?> def = defaults.get(e.getKey());
    284284            if (def == null) {
    285285                def = value.getNullInstance();
     
    292292            data.add(en);
    293293        }
    294         for (Entry<String, Setting> e : defaults.entrySet()) {
     294        for (Entry<String, Setting<?>> e : defaults.entrySet()) {
    295295            if (!loaded.containsKey(e.getKey())) {
    296296                PrefEntry en = new PrefEntry(e.getKey(), e.getValue(), e.getValue(), true);
    297297                // after changes we have default value. So, value is changed if old value is not default
    298                 Setting old = orig.get(e.getKey());
    299                 if ( old!=null ) {
     298                Setting<?> old = orig.get(e.getKey());
     299                if (old != null) {
    300300                    en.markAsChanged();
    301301                }
     
    326326        menu.addSeparator();
    327327        menu.add(new AbstractAction(tr("Reset preferences")) {
    328             @Override public void actionPerformed(ActionEvent ae) {
     328            @Override
     329            public void actionPerformed(ActionEvent ae) {
    329330                if (!GuiHelper.warnUser(tr("Reset preferences"),
    330331                        "<html>"+
     
    412413        for (PrefEntry e : allData) {
    413414            String prefKey = e.getKey();
    414             Setting valueSetting = e.getValue();
     415            Setting<?> valueSetting = e.getValue();
    415416            String prefValue = valueSetting.getValue() == null ? "" : valueSetting.getValue().toString();
    416417
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java

    r7005 r7027  
    4242    public void actionPerformed(ActionEvent ae) {
    4343        List<String> keys = new ArrayList<>();
    44         Map<String, Setting> all = prefs.getAllSettings();
     44        Map<String, Setting<?>> all = prefs.getAllSettings();
    4545        for (String key: all.keySet()) {
    4646            if (key.matches(prefPattern)) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java

    r6986 r7027  
    22package org.openstreetmap.josm.gui.preferences.advanced;
    33
    4 import org.openstreetmap.josm.data.Preferences;
     4import org.openstreetmap.josm.data.Preferences.Setting;
    55import org.openstreetmap.josm.tools.CheckParameterUtil;
    66
     
    1111public class PrefEntry implements Comparable<PrefEntry> {
    1212    private String key;
    13     private Preferences.Setting value;
    14     private Preferences.Setting defaultValue;
     13    private Setting<?> value;
     14    private Setting<?> defaultValue;
    1515    private boolean isDefault;
    1616    private boolean changed;
     
    2323     * @param isDefault determines if the current value is the default value
    2424     */
    25     public PrefEntry(String key, Preferences.Setting value, Preferences.Setting defaultValue, boolean isDefault) {
     25    public PrefEntry(String key, Setting<?> value, Setting<?> defaultValue, boolean isDefault) {
    2626        CheckParameterUtil.ensureParameterNotNull(key);
    2727        CheckParameterUtil.ensureParameterNotNull(value);
     
    4545     * @return the preference value
    4646     */
    47     public Preferences.Setting getValue() {
     47    public Setting<?> getValue() {
    4848        return value;
    4949    }
     
    5353     * @return the preference default value
    5454     */
    55     public Preferences.Setting getDefaultValue() {
     55    public Setting<?> getDefaultValue() {
    5656        return defaultValue;
    5757    }
     
    6161     * @param value the preference value
    6262     */
    63     public void setValue(Preferences.Setting value) {
     63    public void setValue(Setting<?> value) {
    6464        this.value = value;
    6565        changed = true;
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    r7005 r7027  
    2727
    2828import org.openstreetmap.josm.Main;
    29 import org.openstreetmap.josm.data.Preferences;
     29import org.openstreetmap.josm.data.Preferences.ListListSetting;
     30import org.openstreetmap.josm.data.Preferences.ListSetting;
     31import org.openstreetmap.josm.data.Preferences.MapListSetting;
     32import org.openstreetmap.josm.data.Preferences.Setting;
     33import org.openstreetmap.josm.data.Preferences.StringSetting;
    3034import org.openstreetmap.josm.gui.ExtendedDialog;
    3135import org.openstreetmap.josm.gui.widgets.JosmTextField;
     
    98102        }
    99103        final PrefEntry e = (PrefEntry) model.getValueAt(getSelectedRow(), 1);
    100         Preferences.Setting stg = e.getValue();
    101         if (stg instanceof Preferences.StringSetting) {
     104        Setting<?> stg = e.getValue();
     105        if (stg instanceof StringSetting) {
    102106            editCellAt(getSelectedRow(), 1);
    103107            Component editor = getEditorComponent();
     
    105109                editor.requestFocus();
    106110            }
    107         } else if (stg instanceof Preferences.ListSetting) {
    108             Preferences.ListSetting lSetting = (Preferences.ListSetting) stg;
     111        } else if (stg instanceof ListSetting) {
     112            ListSetting lSetting = (ListSetting) stg;
    109113            ListEditor lEditor = new ListEditor(gui, e, lSetting);
    110114            lEditor.showDialog();
     
    112116                List<String> data = lEditor.getData();
    113117                if (!lSetting.equalVal(data)) {
    114                     e.setValue(new Preferences.ListSetting(data));
     118                    e.setValue(new ListSetting(data));
    115119                    return true;
    116120                }
    117121            }
    118         } else if (stg instanceof Preferences.ListListSetting) {
    119             Preferences.ListListSetting llSetting = (Preferences.ListListSetting) stg;
     122        } else if (stg instanceof ListListSetting) {
     123            ListListSetting llSetting = (ListListSetting) stg;
    120124            ListListEditor llEditor = new ListListEditor(gui, e, llSetting);
    121125            llEditor.showDialog();
     
    123127                List<List<String>> data = llEditor.getData();
    124128                if (!llSetting.equalVal(data)) {
    125                     e.setValue(new Preferences.ListListSetting(data));
     129                    e.setValue(new ListListSetting(data));
    126130                    return true;
    127131                }
    128132            }
    129         } else if (stg instanceof Preferences.MapListSetting) {
    130             Preferences.MapListSetting mlSetting = (Preferences.MapListSetting) stg;
     133        } else if (stg instanceof MapListSetting) {
     134            MapListSetting mlSetting = (MapListSetting) stg;
    131135            MapListEditor mlEditor = new MapListEditor(gui, e, mlSetting);
    132136            mlEditor.showDialog();
     
    134138                List<Map<String, String>> data = mlEditor.getData();
    135139                if (!mlSetting.equalVal(data)) {
    136                     e.setValue(new Preferences.MapListSetting(data));
     140                    e.setValue(new MapListSetting(data));
    137141                    return true;
    138142                }
     
    182186        if (dlg.getValue() == 1) {
    183187            if (rbString.isSelected()) {
    184                 Preferences.StringSetting sSetting = new Preferences.StringSetting(null);
     188                StringSetting sSetting = new StringSetting(null);
    185189                pe = new PrefEntry(tkey.getText(), sSetting, sSetting, false);
    186190                StringEditor sEditor = new StringEditor(gui, pe, sSetting);
     
    189193                    String data = sEditor.getData();
    190194                    if (!Utils.equal(sSetting.getValue(), data)) {
    191                         pe.setValue(new Preferences.StringSetting(data));
     195                        pe.setValue(new StringSetting(data));
    192196                        ok = true;
    193197                    }
    194198                }
    195199            } else if (rbList.isSelected()) {
    196                 Preferences.ListSetting lSetting = new Preferences.ListSetting(null);
     200                ListSetting lSetting = new ListSetting(null);
    197201                pe = new PrefEntry(tkey.getText(), lSetting, lSetting, false);
    198202                ListEditor lEditor = new ListEditor(gui, pe, lSetting);
     
    201205                    List<String> data = lEditor.getData();
    202206                    if (!lSetting.equalVal(data)) {
    203                         pe.setValue(new Preferences.ListSetting(data));
     207                        pe.setValue(new ListSetting(data));
    204208                        ok = true;
    205209                    }
    206210                }
    207211            } else if (rbListList.isSelected()) {
    208                 Preferences.ListListSetting llSetting = new Preferences.ListListSetting(null);
     212                ListListSetting llSetting = new ListListSetting(null);
    209213                pe = new PrefEntry(tkey.getText(), llSetting, llSetting, false);
    210214                ListListEditor llEditor = new ListListEditor(gui, pe, llSetting);
     
    213217                    List<List<String>> data = llEditor.getData();
    214218                    if (!llSetting.equalVal(data)) {
    215                         pe.setValue(new Preferences.ListListSetting(data));
     219                        pe.setValue(new ListListSetting(data));
    216220                        ok = true;
    217221                    }
    218222                }
    219223            } else if (rbMapList.isSelected()) {
    220                 Preferences.MapListSetting mlSetting = new Preferences.MapListSetting(null);
     224                MapListSetting mlSetting = new MapListSetting(null);
    221225                pe = new PrefEntry(tkey.getText(), mlSetting, mlSetting, false);
    222226                MapListEditor mlEditor = new MapListEditor(gui, pe, mlSetting);
     
    225229                    List<Map<String, String>> data = mlEditor.getData();
    226230                    if (!mlSetting.equalVal(data)) {
    227                         pe.setValue(new Preferences.MapListSetting(data));
     231                        pe.setValue(new MapListSetting(data));
    228232                        ok = true;
    229233                    }
     
    266270        @Override
    267271        public boolean isCellEditable(int row, int column) {
    268             return column == 1 && (displayData.get(row).getValue() instanceof Preferences.StringSetting);
     272            return column == 1 && (displayData.get(row).getValue() instanceof StringSetting);
    269273        }
    270274
     
    287291            String s = (String) o;
    288292            if (!s.equals(pe.getValue().getValue())) {
    289                 pe.setValue(new Preferences.StringSetting(s));
     293                pe.setValue(new StringSetting(s));
    290294                fireTableCellUpdated(row, column);
    291295            }
     
    308312                return this;
    309313            PrefEntry pe = (PrefEntry) value;
    310             Preferences.Setting setting = pe.getValue();
     314            Setting<?> setting = pe.getValue();
    311315            Object val = setting.getValue();
    312316            String display = val != null ? val.toString() : "<html><i>&lt;"+tr("unset")+"&gt;</i></html>";
     
    351355        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    352356            PrefEntry pe = (PrefEntry) value;
    353             Preferences.StringSetting stg = (Preferences.StringSetting) pe.getValue();
     357            StringSetting stg = (StringSetting) pe.getValue();
    354358            String s = stg.getValue() == null ? "" : stg.getValue();
    355359            return super.getTableCellEditorComponent(table, s, isSelected, row, column);
Note: See TracChangeset for help on using the changeset viewer.