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