Ignore:
Timestamp:
2017-09-13T16:30:27+02:00 (2 years ago)
Author:
bastiK
Message:

see #15229 - fix deprecations caused by [12840]

Location:
trunk/src/org/openstreetmap/josm/data
Files:
18 edited

Legend:

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

    r12826 r12841  
    9999            } else if (entry.getValue() instanceof ListSetting) {
    100100                ListSetting lSetting = (ListSetting) entry.getValue();
    101                 Collection<String> newItems = getCollection(mainpref, key, true);
     101                List<String> newItems = getList(mainpref, key, true);
    102102                if (newItems == null) continue;
    103103                for (String item : lSetting.getValue()) {
     
    107107                    }
    108108                }
    109                 mainpref.putCollection(key, newItems);
     109                mainpref.putList(key, newItems);
    110110            } else if (entry.getValue() instanceof ListListSetting) {
    111111                ListListSetting llSetting = (ListListSetting) entry.getValue();
    112                 Collection<Collection<String>> newLists = getArray(mainpref, key, true);
     112                List<List<String>> newLists = getListOfLists(mainpref, key, true);
    113113                if (newLists == null) continue;
    114114
    115                 for (Collection<String> list : llSetting.getValue()) {
     115                for (List<String> list : llSetting.getValue()) {
    116116                    // add nonexisting list (equals comparison for lists is used implicitly)
    117117                    if (!newLists.contains(list)) {
     
    119119                    }
    120120                }
    121                 mainpref.putArray(key, newLists);
     121                mainpref.putListOfLists(key, newLists);
    122122            } else if (entry.getValue() instanceof MapListSetting) {
    123123                MapListSetting mlSetting = (MapListSetting) entry.getValue();
     
    133133                    }
    134134                }
    135                 mainpref.putListOfStructs(entry.getKey(), newMaps);
     135                mainpref.putListOfMaps(entry.getKey(), newMaps);
    136136            }
    137137        }
     
    155155            } else if (entry.getValue() instanceof ListSetting) {
    156156                ListSetting lSetting = (ListSetting) entry.getValue();
    157                 Collection<String> newItems = getCollection(mainpref, key, true);
     157                List<String> newItems = getList(mainpref, key, true);
    158158                if (newItems == null) continue;
    159159
     
    163163                    newItems.remove(item);
    164164                }
    165                 mainpref.putCollection(entry.getKey(), newItems);
     165                mainpref.putList(entry.getKey(), newItems);
    166166            } else if (entry.getValue() instanceof ListListSetting) {
    167167                ListListSetting llSetting = (ListListSetting) entry.getValue();
    168                 Collection<Collection<String>> newLists = getArray(mainpref, key, true);
     168                List<List<String>> newLists = getListOfLists(mainpref, key, true);
    169169                if (newLists == null) continue;
    170170
    171171                // if items are found in one of lists, remove that list!
    172                 Iterator<Collection<String>> listIterator = newLists.iterator();
     172                Iterator<List<String>> listIterator = newLists.iterator();
    173173                while (listIterator.hasNext()) {
    174174                    Collection<String> list = listIterator.next();
     
    182182                }
    183183
    184                 mainpref.putArray(key, newLists);
     184                mainpref.putListOfLists(key, newLists);
    185185            } else if (entry.getValue() instanceof MapListSetting) {
    186186                MapListSetting mlSetting = (MapListSetting) entry.getValue();
     
    199199                    }
    200200                }
    201                 mainpref.putListOfStructs(entry.getKey(), newMaps);
     201                mainpref.putListOfMaps(entry.getKey(), newMaps);
    202202            }
    203203        }
     
    223223    }
    224224
    225     private static Collection<String> getCollection(Preferences mainpref, String key, boolean warnUnknownDefault) {
     225    private static List<String> getList(Preferences mainpref, String key, boolean warnUnknownDefault) {
    226226        ListSetting existing = Utils.cast(mainpref.settingsMap.get(key), ListSetting.class);
    227227        ListSetting defaults = Utils.cast(mainpref.defaultsMap.get(key), ListSetting.class);
     
    236236    }
    237237
    238     private static Collection<Collection<String>> getArray(Preferences mainpref, String key, boolean warnUnknownDefault) {
     238    private static List<List<String>> getListOfLists(Preferences mainpref, String key, boolean warnUnknownDefault) {
    239239        ListListSetting existing = Utils.cast(mainpref.settingsMap.get(key), ListListSetting.class);
    240240        ListListSetting defaults = Utils.cast(mainpref.defaultsMap.get(key), ListListSetting.class);
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r12718 r12841  
    7474        // Currently you have to undo the commands one by one. If
    7575        // this changes, a higher default value may be reasonable.
    76         if (commands.size() > Main.pref.getInteger("undo.max", 1000)) {
     76        if (commands.size() > Main.pref.getInt("undo.max", 1000)) {
    7777            commands.removeFirst();
    7878        }
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java

    r12620 r12841  
    7272
    7373        return getLoader(listener, cache,
    74                 (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.connect", 15)),
    75                 (int) TimeUnit.SECONDS.toMillis(Main.pref.getInteger("socket.timeout.read", 30)),
     74                (int) TimeUnit.SECONDS.toMillis(Main.pref.getInt("socket.timeout.connect", 15)),
     75                (int) TimeUnit.SECONDS.toMillis(Main.pref.getInt("socket.timeout.read", 30)),
    7676                headers);
    7777    }
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r12620 r12841  
    817817    public void clearId() {
    818818        if (this.id != null) {
    819             Collection<String> newAddedIds = new TreeSet<>(Main.pref.getCollection("imagery.layers.addedIds"));
     819            Collection<String> newAddedIds = new TreeSet<>(Main.pref.getList("imagery.layers.addedIds"));
    820820            newAddedIds.add(this.id);
    821             Main.pref.putCollection("imagery.layers.addedIds", newAddedIds);
     821            Main.pref.putList("imagery.layers.addedIds", new ArrayList<>(newAddedIds));
    822822        }
    823823        setId(null);
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java

    r12635 r12841  
    5757     */
    5858    public static Collection<String> getImageryLayersSites() {
    59         return Main.pref.getCollection("imagery.layers.sites", Arrays.asList(DEFAULT_LAYER_SITES));
     59        return Main.pref.getList("imagery.layers.sites", Arrays.asList(DEFAULT_LAYER_SITES));
    6060    }
    6161
     
    236236        // add new default entries to the user selection
    237237        boolean changed = false;
    238         Collection<String> knownDefaults = new TreeSet<>(Main.pref.getCollection("imagery.layers.default"));
     238        Collection<String> knownDefaults = new TreeSet<>(Main.pref.getList("imagery.layers.default"));
    239239        Collection<String> newKnownDefaults = new TreeSet<>();
    240240        for (ImageryInfo def : defaultLayers) {
     
    279279            newKnownDefaults.addAll(knownDefaults);
    280280        }
    281         Main.pref.putCollection("imagery.layers.default", newKnownDefaults);
     281        Main.pref.putList("imagery.layers.default", new ArrayList<>(newKnownDefaults));
    282282
    283283        // automatically update user entries with same id as a default entry
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuthAccessTokenHolder.java

    r12686 r12841  
    177177        CheckParameterUtil.ensureParameterNotNull(preferences, "preferences");
    178178        CheckParameterUtil.ensureParameterNotNull(cm, "cm");
    179         preferences.put("oauth.access-token.save-to-preferences", saveToPreferences);
     179        preferences.putBoolean("oauth.access-token.save-to-preferences", saveToPreferences);
    180180        try {
    181181            if (!saveToPreferences) {
  • trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java

    r12735 r12841  
    105105        if (namingTagsForRelations == null) {
    106106            namingTagsForRelations = new ArrayList<>(
    107                     Main.pref.getCollection("relation.nameOrder", Arrays.asList(DEFAULT_NAMING_TAGS_FOR_RELATIONS))
     107                    Main.pref.getList("relation.nameOrder", Arrays.asList(DEFAULT_NAMING_TAGS_FOR_RELATIONS))
    108108                    );
    109109        }
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r12816 r12841  
    650650            l.addAll(getDiscardableKeys());
    651651            l.addAll(getWorkInProgressKeys());
    652             uninteresting = new HashSet<>(Main.pref.getCollection("tags.uninteresting", l));
     652            uninteresting = new HashSet<>(Main.pref.getList("tags.uninteresting", l));
    653653        }
    654654        return uninteresting;
     
    662662    public static Collection<String> getDiscardableKeys() {
    663663        if (discardable == null) {
    664             discardable = new HashSet<>(Main.pref.getCollection("tags.discardable",
     664            discardable = new HashSet<>(Main.pref.getList("tags.discardable",
    665665                    Arrays.asList(
    666666                            "created_by",
     
    720720    public static Collection<String> getWorkInProgressKeys() {
    721721        if (workinprogress == null) {
    722             workinprogress = new HashSet<>(Main.pref.getCollection("tags.workinprogress",
     722            workinprogress = new HashSet<>(Main.pref.getList("tags.workinprogress",
    723723                    Arrays.asList("note", "fixme", "FIXME")));
    724724        }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java

    r12620 r12841  
    182182     */
    183183    protected void getSettings(boolean virtual) {
    184         this.virtualNodeSize = virtual ? Main.pref.getInteger("mappaint.node.virtual-size", 8) / 2 : 0;
    185         this.virtualNodeSpace = Main.pref.getInteger("mappaint.node.virtual-space", 70);
    186         this.segmentNumberSpace = Main.pref.getInteger("mappaint.segmentnumber.space", 40);
     184        this.virtualNodeSize = virtual ? Main.pref.getInt("mappaint.node.virtual-size", 8) / 2 : 0;
     185        this.virtualNodeSpace = Main.pref.getInt("mappaint.node.virtual-space", 70);
     186        this.segmentNumberSpace = Main.pref.getInt("mappaint.segmentnumber.space", 40);
    187187        getColors();
    188188    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java

    r12813 r12841  
    6060        this.output = output;
    6161        this.directExecutionTaskSize = directExecutionTaskSize;
    62         this.drawArea = circum <= Main.pref.getInteger("mappaint.fillareas", 10_000_000);
     62        this.drawArea = circum <= Main.pref.getInt("mappaint.fillareas", 10_000_000);
    6363        this.drawMultipolygon = drawArea && Main.pref.getBoolean("mappaint.multipolygon", true);
    6464        this.drawRestriction = Main.pref.getBoolean("mappaint.restriction", true);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java

    r11100 r12841  
    7676        showOnewayArrow = Main.pref.getBoolean("draw.oneway", true);
    7777        useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false);
    78         defaultSegmentWidth = Main.pref.getInteger("mappaint.segment.default-width", 2);
     78        defaultSegmentWidth = Main.pref.getInt("mappaint.segment.default-width", 2);
    7979
    8080        selectedColor = PaintColors.SELECTED.get();
     
    9595        showHeadArrowOnly = Main.pref.getBoolean("draw.segment.head_only", false);
    9696
    97         showNamesDistance = Main.pref.getInteger("mappaint.shownames", 10_000_000);
    98         useStrokesDistance = Main.pref.getInteger("mappaint.strokes", 10_000_000);
    99         showIconsDistance = Main.pref.getInteger("mappaint.showicons", 10_000_000);
    100 
    101         selectedNodeSize = Main.pref.getInteger("mappaint.node.selected-size", 5);
    102         unselectedNodeSize = Main.pref.getInteger("mappaint.node.unselected-size", 3);
    103         connectionNodeSize = Main.pref.getInteger("mappaint.node.connection-size", 5);
    104         taggedNodeSize = Main.pref.getInteger("mappaint.node.tagged-size", 3);
     97        showNamesDistance = Main.pref.getInt("mappaint.shownames", 10_000_000);
     98        useStrokesDistance = Main.pref.getInt("mappaint.strokes", 10_000_000);
     99        showIconsDistance = Main.pref.getInt("mappaint.showicons", 10_000_000);
     100
     101        selectedNodeSize = Main.pref.getInt("mappaint.node.selected-size", 5);
     102        unselectedNodeSize = Main.pref.getInt("mappaint.node.unselected-size", 3);
     103        connectionNodeSize = Main.pref.getInt("mappaint.node.connection-size", 5);
     104        taggedNodeSize = Main.pref.getInt("mappaint.node.tagged-size", 3);
    105105        fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", true);
    106106        fillUnselectedNode = Main.pref.getBoolean("mappaint.node.fill-unselected", false);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r12620 r12841  
    9898            if (Main.pref == null) return;
    9999            Collection<String> literals;
    100             literals = Main.pref.getCollection(PREF_KEY_OUTER_ROLES);
     100            literals = Main.pref.getList(PREF_KEY_OUTER_ROLES);
    101101            if (literals != null && !literals.isEmpty()) {
    102102                setNormalized(literals, outerExactRoles);
    103103            }
    104             literals = Main.pref.getCollection(PREF_KEY_OUTER_ROLE_PREFIXES);
     104            literals = Main.pref.getList(PREF_KEY_OUTER_ROLE_PREFIXES);
    105105            if (literals != null && !literals.isEmpty()) {
    106106                setNormalized(literals, outerRolePrefixes);
    107107            }
    108             literals = Main.pref.getCollection(PREF_KEY_INNER_ROLES);
     108            literals = Main.pref.getList(PREF_KEY_INNER_ROLES);
    109109            if (literals != null && !literals.isEmpty()) {
    110110                setNormalized(literals, innerExactRoles);
    111111            }
    112             literals = Main.pref.getCollection(PREF_KEY_INNER_ROLE_PREFIXES);
     112            literals = Main.pref.getList(PREF_KEY_INNER_ROLE_PREFIXES);
    113113            if (literals != null && !literals.isEmpty()) {
    114114                setNormalized(literals, innerRolePrefixes);
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java

    r12825 r12841  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.util.ArrayList;
    67import java.util.Arrays;
    78import java.util.Collection;
     
    5253        boolean changed = false;
    5354
    54         Collection<String> knownDefaults = new TreeSet<>(Main.pref.getCollection("mappaint.style.known-defaults"));
     55        Collection<String> knownDefaults = new TreeSet<>(Main.pref.getList("mappaint.style.known-defaults"));
    5556
    5657        Collection<ExtendedSourceEntry> defaults = getDefault();
     
    7071            knownDefaults.add(def.url);
    7172        }
    72         Main.pref.putCollection("mappaint.style.known-defaults", knownDefaults);
     73        Main.pref.putList("mappaint.style.known-defaults", new ArrayList<>(knownDefaults));
    7374
    7475        // XML style is not bundled anymore
  • trunk/src/org/openstreetmap/josm/data/preferences/sources/SourcePrefHelper.java

    r12825 r12841  
    5858    public List<SourceEntry> get() {
    5959
    60         Collection<Map<String, String>> src = Main.pref.getListOfStructs(pref, (Collection<Map<String, String>>) null);
     60        List<Map<String, String>> src = Main.pref.getListOfMaps(pref, null);
    6161        if (src == null)
    6262            return new ArrayList<>(getDefault());
     
    7878     */
    7979    public boolean put(Collection<? extends SourceEntry> entries) {
    80         Collection<Map<String, String>> setting = serializeList(entries);
    81         boolean unset = Main.pref.getListOfStructs(pref, (Collection<Map<String, String>>) null) == null;
     80        List<Map<String, String>> setting = serializeList(entries);
     81        boolean unset = Main.pref.getListOfMaps(pref, null) == null;
    8282        if (unset) {
    8383            Collection<Map<String, String>> def = serializeList(getDefault());
     
    8585                return false;
    8686        }
    87         return Main.pref.putListOfStructs(pref, setting);
     87        return Main.pref.putListOfMaps(pref, setting);
    8888    }
    8989
    90     private Collection<Map<String, String>> serializeList(Collection<? extends SourceEntry> entries) {
    91         Collection<Map<String, String>> setting = new ArrayList<>(entries.size());
     90    private List<Map<String, String>> serializeList(Collection<? extends SourceEntry> entries) {
     91        List<Map<String, String>> setting = new ArrayList<>(entries.size());
    9292        for (SourceEntry e : entries) {
    9393            setting.add(serialize(e));
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r12667 r12841  
    282282
    283283    private static void applyPrefs(Map<String, Test> tests, boolean beforeUpload) {
    284         for (String testName : Main.pref.getCollection(beforeUpload
     284        for (String testName : Main.pref.getList(beforeUpload
    285285        ? ValidatorPrefHelper.PREF_SKIP_TESTS_BEFORE_UPLOAD : ValidatorPrefHelper.PREF_SKIP_TESTS)) {
    286286            Test test = tests.get(testName);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java

    r12050 r12841  
    112112    public void startTest(ProgressMonitor monitor) {
    113113        super.startTest(monitor);
    114         maxlength = Main.pref.getInteger("validator.maximum.segment.length", 15_000);
     114        maxlength = Main.pref.getInt("validator.maximum.segment.length", 15_000);
    115115        reported = new HashSet<>();
    116116        visitedWays = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r11913 r12841  
    2323import org.openstreetmap.josm.data.osm.Way;
    2424import org.openstreetmap.josm.data.osm.WaySegment;
    25 import org.openstreetmap.josm.data.preferences.CollectionProperty;
     25import org.openstreetmap.josm.data.preferences.ListProperty;
    2626import org.openstreetmap.josm.data.validation.Severity;
    2727import org.openstreetmap.josm.data.validation.Test;
     
    5050    protected static final int DUPLICATE_WAY_SEGMENT = 121;
    5151
    52     protected static final CollectionProperty IGNORED_KEYS = new CollectionProperty(
     52    protected static final ListProperty IGNORED_KEYS = new ListProperty(
    5353            "overlapping-ways.ignored-keys", Arrays.asList("barrier", "building", "historic:building", "man_made"));
    5454
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r12649 r12841  
    1313import java.util.Collection;
    1414import java.util.HashMap;
    15 import java.util.HashSet;
    1615import java.util.List;
    1716import java.util.Locale;
     
    159158    protected EditableList sourcesList;
    160159
    161     private static final Set<String> DEFAULT_SOURCES = new HashSet<>(Arrays.asList(/*DATA_FILE, */IGNORE_FILE, SPELL_FILE));
     160    private static final List<String> DEFAULT_SOURCES = Arrays.asList(/*DATA_FILE, */IGNORE_FILE, SPELL_FILE);
    162161
    163162    /**
     
    191190
    192191        StringBuilder errorSources = new StringBuilder();
    193         for (String source : Main.pref.getCollection(PREF_SOURCES, DEFAULT_SOURCES)) {
     192        for (String source : Main.pref.getList(PREF_SOURCES, DEFAULT_SOURCES)) {
    194193            try (
    195194                CachedFile cf = new CachedFile(source);
     
    293292            }
    294293            // TODO directionKeys are no longer in OsmPrimitive (search pattern is used instead)
    295             for (String a : Main.pref.getCollection(ValidatorPrefHelper.PREFIX + ".knownkeys",
     294            for (String a : Main.pref.getList(ValidatorPrefHelper.PREFIX + ".knownkeys",
    296295                    Arrays.asList("is_in", "int_ref", "fixme", "population"))) {
    297296                additionalPresetsValueData.putVoid(a);
     
    636635        testPanel.add(prefCheckComplexBeforeUpload, a);
    637636
    638         final Collection<String> sources = Main.pref.getCollection(PREF_SOURCES, DEFAULT_SOURCES);
     637        final Collection<String> sources = Main.pref.getList(PREF_SOURCES, DEFAULT_SOURCES);
    639638        sourcesList = new EditableList(tr("TagChecker source"));
    640639        sourcesList.setItems(sources);
     
    682681                || prefCheckFixmesBeforeUpload.isSelected() || prefCheckComplexBeforeUpload.isSelected();
    683682
    684         Main.pref.put(PREF_CHECK_VALUES, prefCheckValues.isSelected());
    685         Main.pref.put(PREF_CHECK_COMPLEX, prefCheckComplex.isSelected());
    686         Main.pref.put(PREF_CHECK_KEYS, prefCheckKeys.isSelected());
    687         Main.pref.put(PREF_CHECK_FIXMES, prefCheckFixmes.isSelected());
    688         Main.pref.put(PREF_CHECK_VALUES_BEFORE_UPLOAD, prefCheckValuesBeforeUpload.isSelected());
    689         Main.pref.put(PREF_CHECK_COMPLEX_BEFORE_UPLOAD, prefCheckComplexBeforeUpload.isSelected());
    690         Main.pref.put(PREF_CHECK_KEYS_BEFORE_UPLOAD, prefCheckKeysBeforeUpload.isSelected());
    691         Main.pref.put(PREF_CHECK_FIXMES_BEFORE_UPLOAD, prefCheckFixmesBeforeUpload.isSelected());
    692         return Main.pref.putCollection(PREF_SOURCES, sourcesList.getItems());
     683        Main.pref.putBoolean(PREF_CHECK_VALUES, prefCheckValues.isSelected());
     684        Main.pref.putBoolean(PREF_CHECK_COMPLEX, prefCheckComplex.isSelected());
     685        Main.pref.putBoolean(PREF_CHECK_KEYS, prefCheckKeys.isSelected());
     686        Main.pref.putBoolean(PREF_CHECK_FIXMES, prefCheckFixmes.isSelected());
     687        Main.pref.putBoolean(PREF_CHECK_VALUES_BEFORE_UPLOAD, prefCheckValuesBeforeUpload.isSelected());
     688        Main.pref.putBoolean(PREF_CHECK_COMPLEX_BEFORE_UPLOAD, prefCheckComplexBeforeUpload.isSelected());
     689        Main.pref.putBoolean(PREF_CHECK_KEYS_BEFORE_UPLOAD, prefCheckKeysBeforeUpload.isSelected());
     690        Main.pref.putBoolean(PREF_CHECK_FIXMES_BEFORE_UPLOAD, prefCheckFixmesBeforeUpload.isSelected());
     691        return Main.pref.putList(PREF_SOURCES, sourcesList.getItems());
    693692    }
    694693
Note: See TracChangeset for help on using the changeset viewer.