diff --git a/src/org/openstreetmap/josm/data/osm/FilterMatcher.java b/src/org/openstreetmap/josm/data/osm/FilterMatcher.java
index fcc52a6..94a7ec4 100644
a
|
b
|
public class FilterMatcher {
|
92 | 92 | private final List<FilterInfo> hiddenFilters = new ArrayList<>(); |
93 | 93 | private final List<FilterInfo> disabledFilters = new ArrayList<>(); |
94 | 94 | |
95 | | public void update(Collection<Filter> filters) throws ParseError { |
| 95 | public void reset() { |
96 | 96 | hiddenFilters.clear(); |
97 | 97 | disabledFilters.clear(); |
| 98 | } |
98 | 99 | |
99 | | for (Filter filter: filters) { |
| 100 | public void add(final Filter filter) throws ParseError { |
| 101 | if (!filter.enable) { |
| 102 | return; |
| 103 | } |
100 | 104 | |
101 | | if (!filter.enable) { |
102 | | continue; |
103 | | } |
104 | | |
105 | | FilterInfo fi = new FilterInfo(filter); |
106 | | if (fi.isDelete) { |
107 | | if (filter.hiding) { |
108 | | // Remove only hide flag |
109 | | hiddenFilters.add(fi); |
110 | | } else { |
111 | | // Remove both flags |
112 | | disabledFilters.add(fi); |
113 | | hiddenFilters.add(fi); |
114 | | } |
| 105 | FilterInfo fi = new FilterInfo(filter); |
| 106 | if (fi.isDelete) { |
| 107 | if (filter.hiding) { |
| 108 | // Remove only hide flag |
| 109 | hiddenFilters.add(fi); |
115 | 110 | } else { |
116 | | if (filter.mode == SearchMode.replace) { |
117 | | if (filter.hiding) { |
118 | | hiddenFilters.clear(); |
119 | | disabledFilters.clear(); |
120 | | } |
121 | | } |
122 | | |
| 111 | // Remove both flags |
123 | 112 | disabledFilters.add(fi); |
| 113 | hiddenFilters.add(fi); |
| 114 | } |
| 115 | } else { |
| 116 | if (filter.mode == SearchMode.replace) { |
124 | 117 | if (filter.hiding) { |
125 | | hiddenFilters.add(fi); |
| 118 | hiddenFilters.clear(); |
| 119 | disabledFilters.clear(); |
126 | 120 | } |
127 | 121 | } |
| 122 | |
| 123 | disabledFilters.add(fi); |
| 124 | if (filter.hiding) { |
| 125 | hiddenFilters.add(fi); |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | public void update(Collection<Filter> filters) throws ParseError { |
| 131 | reset(); |
| 132 | for (Filter filter : filters) { |
| 133 | add(filter); |
128 | 134 | } |
129 | 135 | } |
130 | 136 | |
diff --git a/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java b/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java
index 3b546d4..d71b87a 100644
a
|
b
|
import org.openstreetmap.josm.data.osm.FilterMatcher;
|
29 | 29 | import org.openstreetmap.josm.data.osm.FilterWorker; |
30 | 30 | import org.openstreetmap.josm.data.osm.Node; |
31 | 31 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| 32 | import org.openstreetmap.josm.tools.Utils; |
32 | 33 | |
33 | 34 | /** |
34 | 35 | * |
… |
… |
public class FilterTableModel extends AbstractTableModel {
|
57 | 58 | private final transient FilterMatcher filterMatcher = new FilterMatcher(); |
58 | 59 | |
59 | 60 | private void updateFilters() { |
60 | | try { |
61 | | filterMatcher.update(filters); |
62 | | executeFilters(); |
63 | | } catch (ParseError e) { |
64 | | JOptionPane.showMessageDialog( |
65 | | Main.parent, |
66 | | e.getMessage(), |
67 | | tr("Error in filter"), |
68 | | JOptionPane.ERROR_MESSAGE); |
| 61 | filterMatcher.reset(); |
| 62 | for (Filter filter : filters) { |
| 63 | try { |
| 64 | filterMatcher.add(filter); |
| 65 | } catch (ParseError e) { |
| 66 | JOptionPane.showMessageDialog( |
| 67 | Main.parent, |
| 68 | tr("<html>Error in filter <code>{0}</code>:<br>{1}", Utils.shortenString(filter.text, 80), e.getMessage()), |
| 69 | tr("Error in filter"), |
| 70 | JOptionPane.ERROR_MESSAGE); |
| 71 | filter.enable = false; |
| 72 | savePrefs(); |
| 73 | } |
69 | 74 | } |
| 75 | executeFilters(); |
70 | 76 | } |
71 | 77 | |
72 | 78 | public void executeFilters() { |