source: josm/trunk/src/org/openstreetmap/josm/data/preferences/sources/ValidatorPrefHelper.java@ 12825

Last change on this file since 12825 was 12825, checked in by Don-vip, 7 years ago

see #15229 - see #15182 - make FileWatcher generic so it has no more dependence on MapCSS

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.preferences.sources;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.ArrayList;
7import java.util.Collection;
8import java.util.HashMap;
9import java.util.List;
10import java.util.Map;
11
12import org.openstreetmap.josm.data.preferences.BooleanProperty;
13import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
14
15/**
16 * Helper class for validator tag checker rules preferences.
17 * @since 12649 (extracted from gui.preferences package)
18 */
19public class ValidatorPrefHelper extends SourcePrefHelper {
20
21 /**
22 * The unique instance.
23 */
24 public static final ValidatorPrefHelper INSTANCE = new ValidatorPrefHelper();
25
26 /** The preferences prefix */
27 public static final String PREFIX = "validator";
28
29 /** The preferences key for error layer */
30 public static final BooleanProperty PREF_LAYER = new BooleanProperty(PREFIX + ".layer", true);
31
32 /** The preferences key for enabled tests */
33 public static final String PREF_SKIP_TESTS = PREFIX + ".skip";
34
35 /** The preferences key for enabled tests */
36 public static final BooleanProperty PREF_USE_IGNORE = new BooleanProperty(PREFIX + ".ignore", true);
37
38 /** The preferences key for enabled tests before upload*/
39 public static final String PREF_SKIP_TESTS_BEFORE_UPLOAD = PREFIX + ".skipBeforeUpload";
40
41 /** The preferences key for ignored severity other on upload */
42 public static final BooleanProperty PREF_OTHER_UPLOAD = new BooleanProperty(PREFIX + ".otherUpload", false);
43
44 /** The preferences for ignored severity other */
45 public static final BooleanProperty PREF_OTHER = new BooleanProperty(PREFIX + ".other", false);
46
47 /**
48 * The preferences key for enabling the permanent filtering
49 * of the displayed errors in the tree regarding the current selection
50 */
51 public static final String PREF_FILTER_BY_SELECTION = PREFIX + ".selectionFilter";
52
53 /**
54 * Constructs a new {@code PresetPrefHelper}.
55 */
56 public ValidatorPrefHelper() {
57 super(MapCSSTagChecker.ENTRIES_PREF_KEY, SourceType.TAGCHECKER_RULE);
58 }
59
60 @Override
61 public Collection<ExtendedSourceEntry> getDefault() {
62 List<ExtendedSourceEntry> def = new ArrayList<>();
63
64 // CHECKSTYLE.OFF: SingleSpaceSeparator
65 addDefault(def, "addresses", tr("Addresses"), tr("Checks for errors on addresses"));
66 addDefault(def, "combinations", tr("Tag combinations"), tr("Checks for missing tag or suspicious combinations"));
67 addDefault(def, "deprecated", tr("Deprecated features"), tr("Checks for deprecated features"));
68 addDefault(def, "geometry", tr("Geometry"), tr("Checks for geometry errors"));
69 addDefault(def, "highway", tr("Highways"), tr("Checks for errors on highways"));
70 addDefault(def, "multiple", tr("Multiple values"), tr("Checks for wrong multiple values"));
71 addDefault(def, "numeric", tr("Numeric values"), tr("Checks for wrong numeric values"));
72 addDefault(def, "religion", tr("Religion"), tr("Checks for errors on religious objects"));
73 addDefault(def, "relation", tr("Relations"), tr("Checks for errors on relations"));
74 addDefault(def, "territories", tr("Territories"), tr("Checks for territories-specific features"));
75 addDefault(def, "unnecessary", tr("Unnecessary tags"), tr("Checks for unnecessary tags"));
76 addDefault(def, "wikipedia", tr("Wikipedia"), tr("Checks for wrong wikipedia tags"));
77 // CHECKSTYLE.ON: SingleSpaceSeparator
78
79 return def;
80 }
81
82 private void addDefault(List<ExtendedSourceEntry> defaults, String filename, String title, String description) {
83 ExtendedSourceEntry i = new ExtendedSourceEntry(type, filename+".mapcss", "resource://data/validator/"+filename+".mapcss");
84 i.title = title;
85 i.description = description;
86 defaults.add(i);
87 }
88
89 @Override
90 public Map<String, String> serialize(SourceEntry entry) {
91 Map<String, String> res = new HashMap<>();
92 res.put("url", entry.url);
93 res.put("title", entry.title == null ? "" : entry.title);
94 res.put("active", Boolean.toString(entry.active));
95 return res;
96 }
97
98 @Override
99 public SourceEntry deserialize(Map<String, String> s) {
100 return new SourceEntry(type, s.get("url"), null, s.get("title"), Boolean.parseBoolean(s.get("active")));
101 }
102}
Note: See TracBrowser for help on using the repository browser.