Changeset 11913 in josm for trunk/src/org/openstreetmap/josm/data/Preferences.java
- Timestamp:
- 2017-04-15T01:38:46+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r11746 r11913 106 106 public class Preferences { 107 107 108 private static final String COLOR_PREFIX = "color."; 109 108 110 private static final String[] OBSOLETE_PREF_KEYS = { 109 111 "hdop.factor", /* remove entry after April 2017 */ … … 501 503 final Map<String, String> all = new TreeMap<>(); 502 504 for (final Entry<String, Setting<?>> e : defaultsMap.entrySet()) { 503 if (e.getKey().startsWith( "color.") && e.getValue() instanceof StringSetting) {505 if (e.getKey().startsWith(COLOR_PREFIX) && e.getValue() instanceof StringSetting) { 504 506 StringSetting d = (StringSetting) e.getValue(); 505 507 if (d.getValue() != null) { … … 509 511 } 510 512 for (final Entry<String, Setting<?>> e : settingsMap.entrySet()) { 511 if (e.getKey().startsWith( "color.") && (e.getValue() instanceof StringSetting)) {513 if (e.getKey().startsWith(COLOR_PREFIX) && (e.getValue() instanceof StringSetting)) { 512 514 all.put(e.getKey().substring(6), ((StringSetting) e.getValue()).getValue()); 513 515 } … … 864 866 String colKey = ColorProperty.getColorKey(colName); 865 867 registerColor(colKey, colName); 866 String colStr = specName != null ? get( "color."+specName) : "";868 String colStr = specName != null ? get(COLOR_PREFIX+specName) : ""; 867 869 if (colStr.isEmpty()) { 868 870 colStr = get(colKey, ColorHelper.color2html(def, true)); … … 888 890 889 891 public synchronized Color getDefaultColor(String colKey) { 890 StringSetting col = Utils.cast(defaultsMap.get( "color."+colKey), StringSetting.class);892 StringSetting col = Utils.cast(defaultsMap.get(COLOR_PREFIX+colKey), StringSetting.class); 891 893 String colStr = col == null ? null : col.getValue(); 892 894 return colStr == null || colStr.isEmpty() ? null : ColorHelper.html2color(colStr); … … 894 896 895 897 public synchronized boolean putColor(String colKey, Color val) { 896 return put( "color."+colKey, val != null ? ColorHelper.color2html(val, true) : null);898 return put(COLOR_PREFIX+colKey, val != null ? ColorHelper.color2html(val, true) : null); 897 899 } 898 900 … … 1532 1534 private void migrateOldColorKeys() { 1533 1535 settingsMap.keySet().stream() 1534 .filter(key -> key.startsWith( "color."))1536 .filter(key -> key.startsWith(COLOR_PREFIX)) 1535 1537 .flatMap(key -> { 1536 final String newKey = ColorProperty.getColorKey(key.substring( "color.".length()));1538 final String newKey = ColorProperty.getColorKey(key.substring(COLOR_PREFIX.length())); 1537 1539 return key.equals(newKey) || settingsMap.containsKey(newKey) 1538 1540 ? Stream.empty()
Note:
See TracChangeset
for help on using the changeset viewer.