- Timestamp:
- 2014-04-29T15:35:53+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r7005 r7027 86 86 text.append("\n"); 87 87 if (Main.platform.getClass() == PlatformHookUnixoid.class) { 88 // Add Java package details for Debian/Ubuntu 88 // Add Java package details for Debian/Ubuntu 89 89 String packageDetails = ((PlatformHookUnixoid) Main.platform).getJavaPackageDetails(); 90 90 if (packageDetails != null) { … … 93 93 text.append("\n"); 94 94 } 95 // Add WebStart package details for Debian/Ubuntu, if run from JNLP 95 // Add WebStart package details for Debian/Ubuntu, if run from JNLP 96 96 if (Package.getPackage("javax.jnlp") != null) { 97 97 String webStartDetails = ((PlatformHookUnixoid) Main.platform).getWebStartPackageDetails(); … … 159 159 text.append(reportHeader); 160 160 try { 161 Map<String, Setting > settings = Main.pref.getAllSettings();161 Map<String, Setting<?>> settings = Main.pref.getAllSettings(); 162 162 settings.remove("osm-server.username"); 163 163 settings.remove("osm-server.password"); … … 170 170 } 171 171 } 172 for (Entry<String, Setting > entry : settings.entrySet()) {172 for (Entry<String, Setting<?>> entry : settings.entrySet()) { 173 173 text.append(entry.getKey()).append("=").append(entry.getValue().getValue().toString()).append("\n"); 174 174 } -
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r7012 r7027 60 60 */ 61 61 public final class CustomConfigurator { 62 62 63 63 private CustomConfigurator() { 64 64 // Hide default constructor for utils classes 65 65 } 66 66 67 67 private static StringBuilder summary = new StringBuilder(); 68 68 … … 216 216 public static void exportPreferencesKeysByPatternToFile(String fileName, boolean append, String pattern) { 217 217 List<String> keySet = new ArrayList<>(); 218 Map<String, Setting > allSettings = Main.pref.getAllSettings();218 Map<String, Setting<?>> allSettings = Main.pref.getAllSettings(); 219 219 for (String key: allSettings.keySet()) { 220 220 if (key.matches(pattern)) keySet.add(key); … … 751 751 752 752 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()) { 754 754 mainpref.putSetting(entry.getKey(), entry.getValue()); 755 755 } … … 757 757 758 758 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()) { 760 760 String key = entry.getKey(); 761 761 if (entry.getValue() instanceof StringSetting) { … … 807 807 private static void deletePreferenceValues(Preferences fragment, Preferences mainpref) { 808 808 809 for (Entry<String, Setting > entry : fragment.settingsMap.entrySet()) {809 for (Entry<String, Setting<?>> entry : fragment.settingsMap.entrySet()) { 810 810 String key = entry.getKey(); 811 811 if (entry.getValue() instanceof StringSetting) { … … 867 867 868 868 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()) { 871 871 String key = entry.getKey(); 872 872 if (key.matches(pattern)) { … … 878 878 879 879 private static void deletePreferenceKey(String key, Preferences pref) { 880 Map<String, Setting > allSettings = pref.getAllSettings();880 Map<String, Setting<?>> allSettings = pref.getAllSettings(); 881 881 if (allSettings.containsKey(key)) { 882 882 log("Deleting preferences: deleting key from preferences: " + key); … … 1008 1008 tmpPref.settingsMap.clear(); 1009 1009 1010 Map<String, Setting > tmp = new HashMap<>();1010 Map<String, Setting<?>> tmp = new HashMap<>(); 1011 1011 for (Entry<String, String> e : stringMap.entrySet()) { 1012 1012 tmp.put(e.getKey(), new StringSetting(e.getValue())); … … 1017 1017 1018 1018 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(); 1020 1021 tmp.put(e.getKey(), new ListListSetting(value)); 1021 1022 } … … 1023 1024 tmp.put(e.getKey(), new MapListSetting(e.getValue())); 1024 1025 } 1025 for (Entry<String, Setting > e : tmp.entrySet()) {1026 for (Entry<String, Setting<?>> e : tmp.entrySet()) { 1026 1027 if (e.getValue().equals(tmpPref.defaultsMap.get(e.getKey()))) continue; 1027 1028 tmpPref.settingsMap.put(e.getKey(), e.getValue()); … … 1044 1045 1045 1046 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(); 1048 1049 if (setting instanceof StringSetting) { 1049 1050 stringMap.put(e.getKey(), ((StringSetting) setting).getValue()); … … 1057 1058 } 1058 1059 } 1059 Iterator<Map.Entry<String, Setting >> it = tmpPref.settingsMap.entrySet().iterator();1060 Iterator<Map.Entry<String, Setting<?>>> it = tmpPref.settingsMap.entrySet().iterator(); 1060 1061 while (it.hasNext()) { 1061 Map.Entry<String, Setting > e = it.next();1062 Map.Entry<String, Setting<?>> e = it.next(); 1062 1063 if (e.getValue().getValue() == null) { 1063 1064 it.remove(); … … 1065 1066 } 1066 1067 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(); 1069 1070 if (setting instanceof StringSetting) { 1070 1071 stringMap.put(e.getKey(), ((StringSetting) setting).getValue()); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r7026 r7027 89 89 90 90 /** 91 * Map the setting name to the current value of the setting.91 * Maps the setting name to the current value of the setting. 92 92 * The map must not contain null as key or value. The mapped setting objects 93 93 * must not have a null value. 94 94 */ 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. 98 99 * The map must not contain null as key or value. The value of the mapped 99 100 * setting objects can be null. 100 101 */ 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 */ 103 107 protected final SortedMap<String, String> colornames = new TreeMap<>(); 104 108 … … 261 265 */ 262 266 public static class ListListSetting extends AbstractSetting<List<List<String>>> { 267 263 268 /** 264 269 * Constructs a new {@code ListListSetting} with the given value … … 269 274 consistencyTest(); 270 275 } 276 271 277 /** 272 278 * Convenience factory method. … … 284 290 return new ListListSetting(null); 285 291 } 286 @Override public boolean equalVal(List<List<String>> otherVal) { 292 293 @Override 294 public boolean equalVal(List<List<String>> otherVal) { 287 295 if (value == null) return otherVal == null; 288 296 if (otherVal == null) return false; … … 295 303 return true; 296 304 } 297 @Override public ListListSetting copy() { 305 306 @Override 307 public ListListSetting copy() { 298 308 if (value == null) return new ListListSetting(null); 299 309 … … 305 315 return new ListListSetting(Collections.unmodifiableList(copy)); 306 316 } 317 307 318 private void consistencyTest() { 308 319 if (value == null) return; … … 312 323 } 313 324 } 314 @Override public void visit(SettingVisitor visitor) { 325 326 @Override 327 public void visit(SettingVisitor visitor) { 315 328 visitor.visit(this); 316 329 } 317 @Override public ListListSetting getNullInstance() { 330 331 @Override 332 public ListListSetting getNullInstance() { 318 333 return new ListListSetting(null); 319 334 } 335 320 336 @Override 321 337 public boolean equals(Object other) { … … 329 345 */ 330 346 public static class MapListSetting extends AbstractSetting<List<Map<String, String>>> { 347 331 348 /** 332 349 * Constructs a new {@code MapListSetting} with the given value … … 337 354 consistencyTest(); 338 355 } 339 @Override public boolean equalVal(List<Map<String, String>> otherVal) { 356 357 @Override 358 public boolean equalVal(List<Map<String, String>> otherVal) { 340 359 if (value == null) return otherVal == null; 341 360 if (otherVal == null) return false; … … 348 367 return true; 349 368 } 369 350 370 private static boolean equalMap(Map<String, String> a, Map<String, String> b) { 351 371 if (a == null) return b == null; … … 357 377 return true; 358 378 } 359 @Override public MapListSetting copy() { 379 380 @Override 381 public MapListSetting copy() { 360 382 if (value == null) return new MapListSetting(null); 361 383 List<Map<String, String>> copy = new ArrayList<>(value.size()); … … 366 388 return new MapListSetting(Collections.unmodifiableList(copy)); 367 389 } 390 368 391 private void consistencyTest() { 369 392 if (value == null) return; … … 374 397 } 375 398 } 376 @Override public void visit(SettingVisitor visitor) { 399 400 @Override 401 public void visit(SettingVisitor visitor) { 377 402 visitor.visit(this); 378 403 } 379 @Override public MapListSetting getNullInstance() { 404 405 @Override 406 public MapListSetting getNullInstance() { 380 407 return new MapListSetting(null); 381 408 } 409 382 410 @Override 383 411 public boolean equals(Object other) { … … 396 424 public interface PreferenceChangeEvent { 397 425 String getKey(); 398 Setting getOldValue();399 Setting getNewValue();426 Setting<?> getOldValue(); 427 Setting<?> getNewValue(); 400 428 } 401 429 … … 406 434 private static class DefaultPreferenceChangeEvent implements PreferenceChangeEvent { 407 435 private final String key; 408 private final Setting oldValue;409 private final Setting newValue;410 411 public DefaultPreferenceChangeEvent(String key, Setting oldValue, SettingnewValue) {436 private final Setting<?> oldValue; 437 private final Setting<?> newValue; 438 439 public DefaultPreferenceChangeEvent(String key, Setting<?> oldValue, Setting<?> newValue) { 412 440 this.key = key; 413 441 this.oldValue = oldValue; … … 419 447 return key; 420 448 } 421 @Override 422 public Setting getOldValue() { 449 450 @Override 451 public Setting<?> getOldValue() { 423 452 return oldValue; 424 453 } 425 @Override 426 public Setting getNewValue() { 454 455 @Override 456 public Setting<?> getNewValue() { 427 457 return newValue; 428 458 } … … 437 467 private final CopyOnWriteArrayList<PreferenceChangedListener> listeners = new CopyOnWriteArrayList<>(); 438 468 469 /** 470 * Adds a new preferences listener. 471 * @param listener The listener to add 472 */ 439 473 public void addPreferenceChangeListener(PreferenceChangedListener listener) { 440 474 if (listener != null) { … … 443 477 } 444 478 479 /** 480 * Removes a preferences listener. 481 * @param listener The listener to remove 482 */ 445 483 public void removePreferenceChangeListener(PreferenceChangedListener listener) { 446 484 listeners.remove(listener); 447 485 } 448 486 449 protected void firePreferenceChanged(String key, Setting oldValue, SettingnewValue) {487 protected void firePreferenceChanged(String key, Setting<?> oldValue, Setting<?> newValue) { 450 488 PreferenceChangeEvent evt = new DefaultPreferenceChangeEvent(key, oldValue, newValue); 451 489 for (PreferenceChangedListener l : listeners) { … … 595 633 public synchronized Map<String, String> getAllPrefix(final String prefix) { 596 634 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()) { 598 636 if (e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting)) { 599 637 all.put(e.getKey(), ((StringSetting) e.getValue()).getValue()); … … 605 643 public synchronized List<String> getAllPrefixCollectionKeys(final String prefix) { 606 644 final List<String> all = new LinkedList<>(); 607 for (Map.Entry<String, Setting > entry : settingsMap.entrySet()) {645 for (Map.Entry<String, Setting<?>> entry : settingsMap.entrySet()) { 608 646 if (entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting) { 609 647 all.add(entry.getKey()); … … 615 653 public synchronized Map<String, String> getAllColors() { 616 654 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()) { 618 656 if (e.getKey().startsWith("color.") && e.getValue() instanceof StringSetting) { 619 657 StringSetting d = (StringSetting) e.getValue(); … … 623 661 } 624 662 } 625 for (final Entry<String,Setting > e : settingsMap.entrySet()) {663 for (final Entry<String,Setting<?>> e : settingsMap.entrySet()) { 626 664 if (e.getKey().startsWith("color.") && (e.getValue() instanceof StringSetting)) { 627 665 all.put(e.getKey().substring(6), ((StringSetting) e.getValue()).getValue()); … … 643 681 boolean generic = getBoolean(key, def); 644 682 String skey = key+"."+specName; 645 Setting prop = settingsMap.get(skey);683 Setting<?> prop = settingsMap.get(skey); 646 684 if (prop instanceof StringSetting) 647 685 return Boolean.parseBoolean(((StringSetting)prop).getValue()); … … 980 1018 * @return true, if something has changed (i.e. value is different than before) 981 1019 */ 982 public boolean putSetting(final String key, Setting setting) {1020 public boolean putSetting(final String key, Setting<?> setting) { 983 1021 CheckParameterUtil.ensureParameterNotNull(key); 984 1022 if (setting != null && setting.getValue() == null) 985 1023 throw new IllegalArgumentException("setting argument must not have null value"); 986 Setting settingOld;987 Setting settingCopy = null;1024 Setting<?> settingOld; 1025 Setting<?> settingCopy = null; 988 1026 synchronized (this) { 989 1027 if (setting == null) { … … 1011 1049 } 1012 1050 1013 public synchronized Setting getSetting(String key, Settingdef) {1051 public synchronized Setting<?> getSetting(String key, Setting<?> def) { 1014 1052 return getSetting(key, def, Setting.class); 1015 1053 } … … 1027 1065 */ 1028 1066 @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) { 1030 1068 CheckParameterUtil.ensureParameterNotNull(key); 1031 1069 CheckParameterUtil.ensureParameterNotNull(def); 1032 Setting oldDef = defaultsMap.get(key);1070 Setting<?> oldDef = defaultsMap.get(key); 1033 1071 if (oldDef != null && oldDef.getValue() != null && def.getValue() != null && !def.equals(oldDef)) { 1034 1072 Main.info("Defaults for " + key + " differ: " + def + " != " + defaultsMap.get(key)); … … 1037 1075 defaultsMap.put(key, def.copy()); 1038 1076 } 1039 Setting prop = settingsMap.get(key);1077 Setting<?> prop = settingsMap.get(key); 1040 1078 if (klass.isInstance(prop)) { 1041 1079 return (T) prop; … … 1237 1275 } 1238 1276 1239 public Map<String, Setting > getAllSettings() {1277 public Map<String, Setting<?>> getAllSettings() { 1240 1278 return new TreeMap<>(settingsMap); 1241 1279 } 1242 1280 1243 public Map<String, Setting > getAllDefaults() {1281 public Map<String, Setting<?>> getAllDefaults() { 1244 1282 return new TreeMap<>(defaultsMap); 1245 1283 } … … 1556 1594 Version.getInstance().getVersion() + "\">\n"); 1557 1595 SettingToXml toXml = new SettingToXml(b, nopass); 1558 for (Entry<String, Setting > e : settingsMap.entrySet()) {1596 for (Entry<String, Setting<?>> e : settingsMap.entrySet()) { 1559 1597 toXml.setKey(e.getKey()); 1560 1598 e.getValue().visit(toXml); … … 1584 1622 "gpxLayer.downloadAlongTrack.area", // 07/2013 - can be removed mid-2014. Replaced by downloadAlongTrack.area 1585 1623 "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.skip1587 "validator.testsBeforeUpload", // 01/2014 - can be removed mid-2014. Replaced by validator.skipBeforeUpload1588 "validator.TagChecker.sources", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source1589 "validator.TagChecker.usedatafile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source1590 "validator.TagChecker.useignorefile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source1591 "validator.TagChecker.usespellfile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source1592 "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.entries1624 "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 1593 1631 }; 1594 1632 for (String key : obsolete) { … … 1600 1638 } 1601 1639 1602 public static boolean isEqual(Setting a, Settingb) {1640 public static boolean isEqual(Setting<?> a, Setting<?> b) { 1603 1641 if (a == null) return b == null; 1604 1642 return a.equals(b); 1605 1643 } 1606 1607 1644 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r7005 r7027 205 205 @Override 206 206 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. 219 208 return whichSelectorMatchesPrimitive(primitive) != null; 220 209 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverTable.java
r6890 r7027 40 40 getActionMap().put("selectPreviousColumnCell", selectPreviousColumnCellAction); 41 41 42 setRowHeight((int)new JosmComboBox ().getPreferredSize().getHeight());42 setRowHeight((int)new JosmComboBox<String>().getPreferredSize().getHeight()); 43 43 } 44 44 -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
r7026 r7027 5 5 6 6 import 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;12 7 import java.util.ArrayList; 13 8 import java.util.Arrays; … … 16 11 import java.util.LinkedList; 17 12 import java.util.List; 18 import java.util.regex.Matcher;19 import java.util.regex.Pattern;20 13 21 14 import javax.swing.DefaultListModel; … … 23 16 import javax.swing.JLabel; 24 17 import javax.swing.JList; 25 import javax.swing.JOptionPane;26 18 import javax.swing.ListCellRenderer; 27 19 import javax.swing.UIManager; … … 30 22 import org.openstreetmap.josm.data.Bounds; 31 23 import org.openstreetmap.josm.tools.ImageProvider; 32 import org.openstreetmap.josm.tools.Utils;33 24 34 25 /** … … 84 75 return name.toLowerCase().compareTo(b.name.toLowerCase()); 85 76 } 86 77 87 78 @Override 88 79 public int hashCode() { -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r7005 r7027 166 166 167 167 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(); 171 171 orig.remove("osm-server.password"); 172 172 defaults.remove("osm-server.password"); … … 175 175 // plugins preference keys may be changed directly later, after plugins are downloaded 176 176 // 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"); 178 178 if (pluginSetting!=null) { 179 179 loaded.put("plugins", pluginSetting); … … 276 276 }; 277 277 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) { 279 279 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()); 284 284 if (def == null) { 285 285 def = value.getNullInstance(); … … 292 292 data.add(en); 293 293 } 294 for (Entry<String, Setting > e : defaults.entrySet()) {294 for (Entry<String, Setting<?>> e : defaults.entrySet()) { 295 295 if (!loaded.containsKey(e.getKey())) { 296 296 PrefEntry en = new PrefEntry(e.getKey(), e.getValue(), e.getValue(), true); 297 297 // 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) { 300 300 en.markAsChanged(); 301 301 } … … 326 326 menu.addSeparator(); 327 327 menu.add(new AbstractAction(tr("Reset preferences")) { 328 @Override public void actionPerformed(ActionEvent ae) { 328 @Override 329 public void actionPerformed(ActionEvent ae) { 329 330 if (!GuiHelper.warnUser(tr("Reset preferences"), 330 331 "<html>"+ … … 412 413 for (PrefEntry e : allData) { 413 414 String prefKey = e.getKey(); 414 Setting valueSetting = e.getValue();415 Setting<?> valueSetting = e.getValue(); 415 416 String prefValue = valueSetting.getValue() == null ? "" : valueSetting.getValue().toString(); 416 417 -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java
r7005 r7027 42 42 public void actionPerformed(ActionEvent ae) { 43 43 List<String> keys = new ArrayList<>(); 44 Map<String, Setting > all = prefs.getAllSettings();44 Map<String, Setting<?>> all = prefs.getAllSettings(); 45 45 for (String key: all.keySet()) { 46 46 if (key.matches(prefPattern)) { -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java
r6986 r7027 2 2 package org.openstreetmap.josm.gui.preferences.advanced; 3 3 4 import org.openstreetmap.josm.data.Preferences ;4 import org.openstreetmap.josm.data.Preferences.Setting; 5 5 import org.openstreetmap.josm.tools.CheckParameterUtil; 6 6 … … 11 11 public class PrefEntry implements Comparable<PrefEntry> { 12 12 private String key; 13 private Preferences.Settingvalue;14 private Preferences.SettingdefaultValue;13 private Setting<?> value; 14 private Setting<?> defaultValue; 15 15 private boolean isDefault; 16 16 private boolean changed; … … 23 23 * @param isDefault determines if the current value is the default value 24 24 */ 25 public PrefEntry(String key, Preferences.Setting value, Preferences.SettingdefaultValue, boolean isDefault) {25 public PrefEntry(String key, Setting<?> value, Setting<?> defaultValue, boolean isDefault) { 26 26 CheckParameterUtil.ensureParameterNotNull(key); 27 27 CheckParameterUtil.ensureParameterNotNull(value); … … 45 45 * @return the preference value 46 46 */ 47 public Preferences.SettinggetValue() {47 public Setting<?> getValue() { 48 48 return value; 49 49 } … … 53 53 * @return the preference default value 54 54 */ 55 public Preferences.SettinggetDefaultValue() {55 public Setting<?> getDefaultValue() { 56 56 return defaultValue; 57 57 } … … 61 61 * @param value the preference value 62 62 */ 63 public void setValue( Preferences.Settingvalue) {63 public void setValue(Setting<?> value) { 64 64 this.value = value; 65 65 changed = true; -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java
r7005 r7027 27 27 28 28 import org.openstreetmap.josm.Main; 29 import org.openstreetmap.josm.data.Preferences; 29 import org.openstreetmap.josm.data.Preferences.ListListSetting; 30 import org.openstreetmap.josm.data.Preferences.ListSetting; 31 import org.openstreetmap.josm.data.Preferences.MapListSetting; 32 import org.openstreetmap.josm.data.Preferences.Setting; 33 import org.openstreetmap.josm.data.Preferences.StringSetting; 30 34 import org.openstreetmap.josm.gui.ExtendedDialog; 31 35 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … 98 102 } 99 103 final PrefEntry e = (PrefEntry) model.getValueAt(getSelectedRow(), 1); 100 Preferences.Settingstg = e.getValue();101 if (stg instanceof Preferences.StringSetting) {104 Setting<?> stg = e.getValue(); 105 if (stg instanceof StringSetting) { 102 106 editCellAt(getSelectedRow(), 1); 103 107 Component editor = getEditorComponent(); … … 105 109 editor.requestFocus(); 106 110 } 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; 109 113 ListEditor lEditor = new ListEditor(gui, e, lSetting); 110 114 lEditor.showDialog(); … … 112 116 List<String> data = lEditor.getData(); 113 117 if (!lSetting.equalVal(data)) { 114 e.setValue(new Preferences.ListSetting(data));118 e.setValue(new ListSetting(data)); 115 119 return true; 116 120 } 117 121 } 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; 120 124 ListListEditor llEditor = new ListListEditor(gui, e, llSetting); 121 125 llEditor.showDialog(); … … 123 127 List<List<String>> data = llEditor.getData(); 124 128 if (!llSetting.equalVal(data)) { 125 e.setValue(new Preferences.ListListSetting(data));129 e.setValue(new ListListSetting(data)); 126 130 return true; 127 131 } 128 132 } 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; 131 135 MapListEditor mlEditor = new MapListEditor(gui, e, mlSetting); 132 136 mlEditor.showDialog(); … … 134 138 List<Map<String, String>> data = mlEditor.getData(); 135 139 if (!mlSetting.equalVal(data)) { 136 e.setValue(new Preferences.MapListSetting(data));140 e.setValue(new MapListSetting(data)); 137 141 return true; 138 142 } … … 182 186 if (dlg.getValue() == 1) { 183 187 if (rbString.isSelected()) { 184 Preferences.StringSetting sSetting = new Preferences.StringSetting(null);188 StringSetting sSetting = new StringSetting(null); 185 189 pe = new PrefEntry(tkey.getText(), sSetting, sSetting, false); 186 190 StringEditor sEditor = new StringEditor(gui, pe, sSetting); … … 189 193 String data = sEditor.getData(); 190 194 if (!Utils.equal(sSetting.getValue(), data)) { 191 pe.setValue(new Preferences.StringSetting(data));195 pe.setValue(new StringSetting(data)); 192 196 ok = true; 193 197 } 194 198 } 195 199 } else if (rbList.isSelected()) { 196 Preferences.ListSetting lSetting = new Preferences.ListSetting(null);200 ListSetting lSetting = new ListSetting(null); 197 201 pe = new PrefEntry(tkey.getText(), lSetting, lSetting, false); 198 202 ListEditor lEditor = new ListEditor(gui, pe, lSetting); … … 201 205 List<String> data = lEditor.getData(); 202 206 if (!lSetting.equalVal(data)) { 203 pe.setValue(new Preferences.ListSetting(data));207 pe.setValue(new ListSetting(data)); 204 208 ok = true; 205 209 } 206 210 } 207 211 } else if (rbListList.isSelected()) { 208 Preferences.ListListSetting llSetting = new Preferences.ListListSetting(null);212 ListListSetting llSetting = new ListListSetting(null); 209 213 pe = new PrefEntry(tkey.getText(), llSetting, llSetting, false); 210 214 ListListEditor llEditor = new ListListEditor(gui, pe, llSetting); … … 213 217 List<List<String>> data = llEditor.getData(); 214 218 if (!llSetting.equalVal(data)) { 215 pe.setValue(new Preferences.ListListSetting(data));219 pe.setValue(new ListListSetting(data)); 216 220 ok = true; 217 221 } 218 222 } 219 223 } else if (rbMapList.isSelected()) { 220 Preferences.MapListSetting mlSetting = new Preferences.MapListSetting(null);224 MapListSetting mlSetting = new MapListSetting(null); 221 225 pe = new PrefEntry(tkey.getText(), mlSetting, mlSetting, false); 222 226 MapListEditor mlEditor = new MapListEditor(gui, pe, mlSetting); … … 225 229 List<Map<String, String>> data = mlEditor.getData(); 226 230 if (!mlSetting.equalVal(data)) { 227 pe.setValue(new Preferences.MapListSetting(data));231 pe.setValue(new MapListSetting(data)); 228 232 ok = true; 229 233 } … … 266 270 @Override 267 271 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); 269 273 } 270 274 … … 287 291 String s = (String) o; 288 292 if (!s.equals(pe.getValue().getValue())) { 289 pe.setValue(new Preferences.StringSetting(s));293 pe.setValue(new StringSetting(s)); 290 294 fireTableCellUpdated(row, column); 291 295 } … … 308 312 return this; 309 313 PrefEntry pe = (PrefEntry) value; 310 Preferences.Settingsetting = pe.getValue();314 Setting<?> setting = pe.getValue(); 311 315 Object val = setting.getValue(); 312 316 String display = val != null ? val.toString() : "<html><i><"+tr("unset")+"></i></html>"; … … 351 355 public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { 352 356 PrefEntry pe = (PrefEntry) value; 353 Preferences.StringSetting stg = (Preferences.StringSetting) pe.getValue();357 StringSetting stg = (StringSetting) pe.getValue(); 354 358 String s = stg.getValue() == null ? "" : stg.getValue(); 355 359 return super.getTableCellEditorComponent(table, s, isSelected, row, column);
Note:
See TracChangeset
for help on using the changeset viewer.