Changeset 11424 in josm for trunk/src


Ignore:
Timestamp:
2016-12-31T17:29:54+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #10387, fix #12914 - enable territorial rules by default

File:
1 edited

Legend:

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

    r11400 r11424  
    6868import org.openstreetmap.josm.data.preferences.Setting;
    6969import org.openstreetmap.josm.data.preferences.StringSetting;
     70import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference;
     71import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference.RulePrefHelper;
    7072import org.openstreetmap.josm.io.OfflineAccessException;
    7173import org.openstreetmap.josm.io.OnlineResource;
     
    15211523            migrateOldColorKeys();
    15221524        }
     1525        // drop in September 2017
     1526        if (loadedVersion < 11424) {
     1527            addNewerDefaultEntry(
     1528                    "validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries",
     1529                    "resource://data/validator/territories.mapcss");
     1530        }
    15231531
    15241532        for (String key : OBSOLETE_PREF_KEYS) {
     
    15701578    }
    15711579
     1580    private void addNewerDefaultEntry(String key, final String url) {
     1581        Setting<?> setting = settingsMap.get(key);
     1582        if (setting instanceof MapListSetting) {
     1583            List<Map<String, String>> l = new ArrayList<>(((MapListSetting) setting).getValue());
     1584            if (l.stream().noneMatch(x -> x.values().contains(url))) {
     1585                RulePrefHelper helper = ValidatorTagCheckerRulesPreference.RulePrefHelper.INSTANCE;
     1586                l.add(helper.serialize(helper.getDefault().stream().filter(x -> url.equals(x.url)).findFirst().get()));
     1587                putListOfStructs(key, l);
     1588            }
     1589        }
     1590    }
     1591
    15721592    /**
    15731593     * Enables or not the preferences file auto-save mechanism (save each time a setting is changed).
Note: See TracChangeset for help on using the changeset viewer.