source: josm/trunk/src/org/openstreetmap/josm/data/osm/Filter.java@ 11383

Last change on this file since 11383 was 10378, checked in by Don-vip, 8 years ago

Checkstyle 6.19: enable SingleSpaceSeparator and fix violations

  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
5import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
6import org.openstreetmap.josm.data.Preferences.pref;
7import org.openstreetmap.josm.data.Preferences.writeExplicitly;
8
9/**
10 * Data class representing one entry in the filter dialog.
11 *
12 * @author Petr_Dlouhý
13 * @since 2125
14 */
15public class Filter extends SearchSetting {
16 private static final String version = "1";
17
18 /**
19 * Enabled status.
20 * @see FilterPreferenceEntry#enable
21 */
22 public boolean enable = true;
23
24 /**
25 * If this option is activated, the chosen objects are completely hidden.
26 * Otherwise they are disabled and shown in a shade of gray.
27 * @see FilterPreferenceEntry#hiding
28 */
29 public boolean hiding;
30
31 /**
32 * Normally, the specified objects are hidden and the rest is shown.
33 * If this option is activated, only the specified objects are shown and the rest is hidden.
34 * @see FilterPreferenceEntry#inverted
35 */
36 public boolean inverted;
37
38 /**
39 * Constructs a new {@code Filter}.
40 */
41 public Filter() {
42 super();
43 mode = SearchMode.add;
44 }
45
46 /**
47 * Constructs a new {@code Filter} from a preference entry.
48 * @param e preference entry
49 */
50 public Filter(FilterPreferenceEntry e) {
51 this();
52 text = e.text;
53 if ("replace".equals(e.mode)) {
54 mode = SearchMode.replace;
55 } else if ("add".equals(e.mode)) {
56 mode = SearchMode.add;
57 } else if ("remove".equals(e.mode)) {
58 mode = SearchMode.remove;
59 } else if ("in_selection".equals(e.mode)) {
60 mode = SearchMode.in_selection;
61 }
62 caseSensitive = e.case_sensitive;
63 regexSearch = e.regex_search;
64 mapCSSSearch = e.mapCSS_search;
65 enable = e.enable;
66 hiding = e.hiding;
67 inverted = e.inverted;
68 }
69
70 public static class FilterPreferenceEntry {
71 @writeExplicitly
72 @pref public String version = "1";
73
74 @pref public String text;
75
76 /**
77 * Mode selector which defines how a filter is combined with the previous one:<ul>
78 * <li>replace: replace selection</li>
79 * <li>add: add to selection</li>
80 * <li>remove: remove from selection</li>
81 * <li>in_selection: find in selection</li>
82 * </ul>
83 * @see SearchMode
84 */
85 @writeExplicitly
86 @pref public String mode = "add";
87
88 @pref public boolean case_sensitive;
89
90 @pref public boolean regex_search;
91
92 @pref public boolean mapCSS_search;
93
94 /**
95 * Enabled status.
96 * @see Filter#enable
97 */
98 @writeExplicitly
99 @pref public boolean enable = true;
100
101 /**
102 * If this option is activated, the chosen objects are completely hidden.
103 * Otherwise they are disabled and shown in a shade of gray.
104 * @see Filter#hiding
105 */
106 @writeExplicitly
107 @pref public boolean hiding;
108
109 /**
110 * Normally, the specified objects are hidden and the rest is shown.
111 * If this option is activated, only the specified objects are shown and the rest is hidden.
112 * @see Filter#inverted
113 */
114 @writeExplicitly
115 @pref public boolean inverted;
116 }
117
118 /**
119 * Returns a new preference entry for this filter.
120 * @return preference entry
121 */
122 public FilterPreferenceEntry getPreferenceEntry() {
123 FilterPreferenceEntry e = new FilterPreferenceEntry();
124 e.version = version;
125 e.text = text;
126 e.mode = mode.toString();
127 e.case_sensitive = caseSensitive;
128 e.regex_search = regexSearch;
129 e.mapCSS_search = mapCSSSearch;
130 e.enable = enable;
131 e.hiding = hiding;
132 e.inverted = inverted;
133 return e;
134 }
135}
Note: See TracBrowser for help on using the repository browser.