1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
|
---|
5 | import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | *
|
---|
9 | * @author Petr_Dlouhý
|
---|
10 | */
|
---|
11 | public class Filter extends SearchSetting {
|
---|
12 | private static final String version = "1";
|
---|
13 |
|
---|
14 | public boolean enable = true;
|
---|
15 | public boolean hiding = false;
|
---|
16 | public boolean inverted = false;
|
---|
17 |
|
---|
18 | public Filter() {
|
---|
19 | super("", SearchMode.add, false, false, false);
|
---|
20 | }
|
---|
21 | public Filter(String text, SearchMode mode, boolean caseSensitive,
|
---|
22 | boolean regexSearch, boolean allElements) {
|
---|
23 | super(text, mode, caseSensitive, regexSearch, allElements);
|
---|
24 | }
|
---|
25 |
|
---|
26 | public Filter(String prefText) {
|
---|
27 | super("", SearchMode.add, false, false, false);
|
---|
28 | String[] prfs = prefText.split(";");
|
---|
29 | if(prfs.length != 10 && !prfs[0].equals(version))
|
---|
30 | throw new Error("Incompatible filter preferences");
|
---|
31 | text = prfs[1];
|
---|
32 | if(prfs[2].equals("replace")) {
|
---|
33 | mode = SearchMode.replace;
|
---|
34 | }
|
---|
35 | if(prfs[2].equals("add")) {
|
---|
36 | mode = SearchMode.add;
|
---|
37 | }
|
---|
38 | if(prfs[2].equals("remove")) {
|
---|
39 | mode = SearchMode.remove;
|
---|
40 | }
|
---|
41 | if(prfs[2].equals("in_selection")) {
|
---|
42 | mode = SearchMode.in_selection;
|
---|
43 | }
|
---|
44 | caseSensitive = Boolean.parseBoolean(prfs[3]);
|
---|
45 | regexSearch = Boolean.parseBoolean(prfs[4]);
|
---|
46 | enable = Boolean.parseBoolean(prfs[6]);
|
---|
47 | hiding = Boolean.parseBoolean(prfs[7]);
|
---|
48 | inverted = Boolean.parseBoolean(prfs[8]);
|
---|
49 | }
|
---|
50 |
|
---|
51 | public String getPrefString(){
|
---|
52 | return version + ";" +
|
---|
53 | text + ";" + mode + ";" + caseSensitive + ";" + regexSearch + ";" +
|
---|
54 | "legacy" + ";" + enable + ";" + hiding + ";" +
|
---|
55 | inverted + ";" +
|
---|
56 | "false"; // last parameter is not used any more (was: applyForChildren)
|
---|
57 | }
|
---|
58 | }
|
---|