Changeset 3305 in josm for trunk/src/org
- Timestamp:
- 2010-06-04T07:54:55+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions/search
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r3300 r3305 190 190 + "<li>"+tr("<b>nodes:</b>... - object with given number of nodes (nodes:count or nodes:min-max)")+"</li>" 191 191 + "<li>"+tr("<b>tags:</b>... - object with given number of tags (tags:count or tags:min-max)")+"</li>" 192 + "<li>"+tr("<b>role:</b>... - object with given role in a relation")+"</li>" 192 193 + "<li>"+tr("<b>timestamp:</b>... - objects with this timestamp (<b>2009-11-12T14:51:09Z</b>, <b>2009-11-12</b> or <b>T14:51</b> ...)")+"</li>" 193 194 + "<li>"+tr("<b>modified</b> - all changed objects")+"</li>" -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r3304 r3305 48 48 private boolean regexSearch = false; 49 49 private static String rxErrorMsg = marktr("The regex \"{0}\" had a parse error at offset {1}, full error:\n\n{2}"); 50 private static String rxErrorMsgNoPos = marktr("The regex \"{0}\" had a parse error, full error:\n\n{1}"); 50 51 private PushbackTokenizer tokenizer; 51 52 … … 167 168 throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage())); 168 169 } catch (Exception e) { 169 throw new ParseError(tr(rxErrorMsg , key, tr("<unknown>"), e.getMessage()));170 throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage())); 170 171 } 171 172 try { … … 174 175 throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage())); 175 176 } catch (Exception e) { 176 throw new ParseError(tr(rxErrorMsg , value, tr("<unknown>"), e.getMessage()));177 throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage())); 177 178 } 178 179 this.key = key; … … 299 300 throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage())); 300 301 } catch (Exception e) { 301 throw new ParseError(tr(rxErrorMsg , key, tr("<unknown>"), e.getMessage()));302 throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage())); 302 303 } 303 304 } else { … … 310 311 throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage())); 311 312 } catch (Exception e) { 312 throw new ParseError(tr(rxErrorMsg , value, tr("<unknown>"), e.getMessage()));313 throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage())); 313 314 } 314 315 } else { … … 386 387 throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage())); 387 388 } catch (Exception e) { 388 throw new ParseError(tr(rxErrorMsg , s, tr("<unknown>"), e.getMessage()));389 throw new ParseError(tr(rxErrorMsgNoPos, s, e.getMessage())); 389 390 } 390 391 this.search = s; … … 487 488 @Override public String toString() { 488 489 return "user=" + user == null ? "" : user; 490 } 491 } 492 493 private static class RoleMatch extends Match { 494 private String role; 495 public RoleMatch(String role) { 496 if (role == null) { 497 this.role = ""; 498 } else { 499 this.role = role; 500 } 501 } 502 503 @Override public boolean match(OsmPrimitive osm) { 504 for (OsmPrimitive ref: osm.getReferrers()) { 505 if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) { 506 for (RelationMember m : ((Relation) ref).getMembers()) { 507 if (m.getMember() == osm) { 508 String testRole = m.getRole(); 509 if(role.equals(testRole == null ? "" : testRole)) 510 return true; 511 } 512 } 513 } 514 } 515 return false; 516 } 517 518 @Override public String toString() { 519 return "role=" + role; 489 520 } 490 521 } … … 718 749 else if (key.equals("user")) 719 750 return new UserMatch(value); 751 else if (key.equals("role")) 752 return new RoleMatch(value); 720 753 else 721 754 return new KeyValue(key, value, regexSearch, caseSensitive);
Note:
See TracChangeset
for help on using the changeset viewer.