1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.preferences.sources;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Collection;
|
---|
7 | import java.util.Collections;
|
---|
8 | import java.util.HashMap;
|
---|
9 | import java.util.Map;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Helper class for tagging presets preferences.
|
---|
13 | * @since 12649 (extracted from gui.preferences package)
|
---|
14 | */
|
---|
15 | public class PresetPrefHelper extends SourcePrefHelper {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * The unique instance.
|
---|
19 | */
|
---|
20 | public static final PresetPrefHelper INSTANCE = new PresetPrefHelper();
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Constructs a new {@code PresetPrefHelper}.
|
---|
24 | */
|
---|
25 | public PresetPrefHelper() {
|
---|
26 | super("taggingpreset.entries", SourceType.TAGGING_PRESET);
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public Collection<ExtendedSourceEntry> getDefault() {
|
---|
31 | ExtendedSourceEntry i = new ExtendedSourceEntry(type, "defaultpresets.xml", "resource://data/defaultpresets.xml");
|
---|
32 | i.title = tr("Internal Preset");
|
---|
33 | i.description = tr("The default preset for JOSM");
|
---|
34 | return Collections.singletonList(i);
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | public Map<String, String> serialize(SourceEntry entry) {
|
---|
39 | Map<String, String> res = new HashMap<>();
|
---|
40 | res.put("url", entry.url);
|
---|
41 | res.put("title", entry.title == null ? "" : entry.title);
|
---|
42 | return res;
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Override
|
---|
46 | public SourceEntry deserialize(Map<String, String> s) {
|
---|
47 | return new SourceEntry(type, s.get("url"), null, s.get("title"), true);
|
---|
48 | }
|
---|
49 | }
|
---|