Changeset 17662 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/resources/data/tagging-preset.xsd
r17610 r17662 156 156 </annotation> 157 157 </attribute> 158 <attribute name="match_expression" type="string"> 159 <annotation> 160 <documentation> 161 Additional criteria for matching primitives. Specified in <a href="https://josm.openstreetmap.de/wiki/Help/Action/Search">JOSM search syntax</a>. 162 For instance, a preset with <code>match_expression="foo=bar"</code> requires OSM objects to have the tag <code>foo=bar</code>. 163 You may want to use the <code>match_expression</code> to exclude certain OSM objects, for instance when a more specific preset is present. 164 </documentation> 165 </annotation> 166 </attribute> 158 167 <attribute name="preset_name_label" type="boolean"> 159 168 <annotation> -
trunk/src/org/openstreetmap/josm/data/osm/Tagged.java
r17584 r17662 233 233 return OsmUtils.isFalse(get(key)); 234 234 } 235 236 /** 237 * Returns a Tagged instance for the given tag map 238 * @param tags the tag map 239 * @return a Tagged instance for the given tag map 240 */ 241 static Tagged ofMap(Map<String, String> tags) { 242 return new Tagged() { 243 244 @Override 245 public String get(String key) { 246 return tags.get(key); 247 } 248 249 @Override 250 public Map<String, String> getKeys() { 251 return tags; 252 } 253 254 @Override 255 public Collection<String> keySet() { 256 return tags.keySet(); 257 } 258 259 @Override 260 public void put(String key, String value) { 261 tags.put(key, value); 262 } 263 264 @Override 265 public void setKeys(Map<String, String> keys) { 266 tags.putAll(keys); 267 } 268 269 @Override 270 public boolean hasKeys() { 271 return !tags.isEmpty(); 272 } 273 274 @Override 275 public int getNumKeys() { 276 return tags.size(); 277 } 278 279 @Override 280 public void remove(String key) { 281 tags.remove(key); 282 } 283 284 @Override 285 public void removeAll() { 286 tags.clear(); 287 } 288 }; 289 } 235 290 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r17651 r17662 48 48 import org.openstreetmap.josm.data.osm.RelationMember; 49 49 import org.openstreetmap.josm.data.osm.Tag; 50 import org.openstreetmap.josm.data.osm.Tagged; 50 51 import org.openstreetmap.josm.data.osm.Way; 51 52 import org.openstreetmap.josm.data.osm.search.SearchCompiler; … … 135 136 public transient TemplateEntry nameTemplate; 136 137 public transient Match nameTemplateFilter; 138 public transient Match matchExpression; 137 139 138 140 /** … … 288 290 } 289 291 292 public void setMatch_expression(String filter) throws SAXException { 293 try { 294 this.matchExpression = SearchCompiler.compile(filter); 295 } catch (SearchParseError e) { 296 Logging.error("Error while parsing" + filter + ": " + e.getMessage()); 297 throw new SAXException(e); 298 } 299 } 300 290 301 private static class PresetPanel extends JPanel { 291 302 private boolean hasElements; … … 646 657 if ((onlyShowable && !isShowable()) || !typeMatches(t)) { 647 658 return false; 659 } else if (matchExpression != null && !matchExpression.match(Tagged.ofMap(tags))) { 660 return false; 648 661 } else { 649 662 return TaggingPresetItem.matches(data, tags);
Note:
See TracChangeset
for help on using the changeset viewer.