Package org.openstreetmap.josm.data.Preferences

Examples of org.openstreetmap.josm.data.Preferences.MapListSetting


                    e.setValue(new ListListSetting(data));
                    return true;
                }
            }
        } else if (stg instanceof MapListSetting) {
            MapListSetting mlSetting = (MapListSetting) stg;
            MapListEditor mlEditor = new MapListEditor(gui, e, mlSetting);
            mlEditor.showDialog();
            if (mlEditor.getValue() == 1) {
                List<Map<String, String>> data = mlEditor.getData();
                if (!mlSetting.equalVal(data)) {
                    e.setValue(new MapListSetting(data));
                    return true;
                }
            }
        }
        return false;
View Full Code Here


                        pe.setValue(new ListListSetting(data));
                        ok = true;
                    }
                }
            } else if (rbMapList.isSelected()) {
                MapListSetting mlSetting = new MapListSetting(null);
                pe = new PrefEntry(tkey.getText(), mlSetting, mlSetting, false);
                MapListEditor mlEditor = new MapListEditor(gui, pe, mlSetting);
                mlEditor.showDialog();
                if (mlEditor.getValue() == 1) {
                    List<Map<String, String>> data = mlEditor.getData();
                    if (!mlSetting.equalVal(data)) {
                        pe.setValue(new MapListSetting(data));
                        ok = true;
                    }
                }
            }
        }
View Full Code Here

                            newLists.add(list);
                        }
                    }
                    mainpref.putArray(key, newLists);
                } else if (entry.getValue() instanceof MapListSetting) {
                    MapListSetting mlSetting = (MapListSetting) entry.getValue();
                    List<Map<String, String>> newMaps = getListOfStructs(mainpref, key, true);
                    if (newMaps == null) continue;

                    // get existing properties as list of maps

                    for (Map<String, String> map : mlSetting.getValue()) {
                        // add nonexisting map (equals comparison for maps is used implicitly)
                        if (!newMaps.contains(map)) {
                            newMaps.add(map);
                        }
                    }
View Full Code Here

                        }
                    }

                    mainpref.putArray(key, newLists);
                } else if (entry.getValue() instanceof MapListSetting) {
                    MapListSetting mlSetting = (MapListSetting) entry.getValue();
                    List<Map<String, String>> newMaps = getListOfStructs(mainpref, key, true);
                    if (newMaps == null) continue;

                    Iterator<Map<String, String>> mapIterator = newMaps.iterator();
                    while (mapIterator.hasNext()) {
                        Map<String, String> map = mapIterator.next();
                        for (Map<String, String> removeMap : mlSetting.getValue()) {
                            if (map.entrySet().containsAll(removeMap.entrySet())) {
                                // the map contain all mentioned key-value pair, so it should be deleted from "maps"
                                log("Deleting preferences: deleting map from maps %s: %s\n", key, map);
                                mapIterator.remove();
                            }
View Full Code Here

        else
            return defaults.getValue() == null ? null : new ArrayList<Collection<String>>(defaults.getValue());
    }

    private static List<Map<String, String>> getListOfStructs(Preferences mainpref, String key, boolean warnUnknownDefault)  {
        MapListSetting existing = Utils.cast(mainpref.settingsMap.get(key), MapListSetting.class);
        MapListSetting defaults = Utils.cast(mainpref.settingsMap.get(key), MapListSetting.class);

        if (existing == null && defaults == null) {
            if (warnUnknownDefault) defaultUnknownWarning(key);
            return null;
        }

        if (existing != null)
            return new ArrayList<>(existing.getValue());
        else
            return defaults.getValue() == null ? null : new ArrayList<>(defaults.getValue());
    }
View Full Code Here

            @SuppressWarnings("unchecked")
            List<List<String>> value = (List)e.getValue();
            tmp.put(e.getKey(), new ListListSetting(value));
        }
        for (Entry<String, List<Map<String, String>>> e : listmapMap.entrySet()) {
            tmp.put(e.getKey(), new MapListSetting(e.getValue()));
        }
        for (Entry<String, Setting<?>> e : tmp.entrySet()) {
            if (e.getValue().equals(tmpPref.defaultsMap.get(e.getKey()))) continue;
            tmpPref.settingsMap.put(e.getKey(), e.getValue());
        }
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.Preferences.MapListSetting

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.