Changeset 9348 in josm
- Timestamp:
- 2016-01-09T12:06:54+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java
r8870 r9348 93 93 private final List<FilterInfo> disabledFilters = new ArrayList<>(); 94 94 95 /** 96 * Clears the current filters, and adds the given filters 97 * @param filters the filters to add 98 * @throws ParseError if the search expression in one of the filters cannot be parsed 99 */ 95 100 public void update(Collection<Filter> filters) throws ParseError { 101 reset(); 102 for (Filter filter : filters) { 103 add(filter); 104 } 105 } 106 107 /** 108 * Clears the filters in use. 109 */ 110 public void reset() { 96 111 hiddenFilters.clear(); 97 112 disabledFilters.clear(); 98 99 for (Filter filter: filters) { 100 101 if (!filter.enable) { 102 continue; 103 } 104 105 FilterInfo fi = new FilterInfo(filter); 106 if (fi.isDelete) { 113 } 114 115 /** 116 * Adds a filter to the currently used filters 117 * @param filter the filter to add 118 * @throws ParseError if the search expression in the filter cannot be parsed 119 */ 120 public void add(final Filter filter) throws ParseError { 121 if (!filter.enable) { 122 return; 123 } 124 125 FilterInfo fi = new FilterInfo(filter); 126 if (fi.isDelete) { 127 if (filter.hiding) { 128 // Remove only hide flag 129 hiddenFilters.add(fi); 130 } else { 131 // Remove both flags 132 disabledFilters.add(fi); 133 hiddenFilters.add(fi); 134 } 135 } else { 136 if (filter.mode == SearchMode.replace) { 107 137 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 } 115 } else { 116 if (filter.mode == SearchMode.replace) { 117 if (filter.hiding) { 118 hiddenFilters.clear(); 119 disabledFilters.clear(); 120 } 121 } 122 123 disabledFilters.add(fi); 124 if (filter.hiding) { 125 hiddenFilters.add(fi); 126 } 138 hiddenFilters.clear(); 139 disabledFilters.clear(); 140 } 141 } 142 143 disabledFilters.add(fi); 144 if (filter.hiding) { 145 hiddenFilters.add(fi); 127 146 } 128 147 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterTableModel.java
r9078 r9348 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 /** … … 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); 69 } 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 } 74 } 75 executeFilters(); 70 76 } 71 77
Note:
See TracChangeset
for help on using the changeset viewer.