- Timestamp:
- 2011-10-08T00:24:18+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r4499 r4503 585 585 return Collections.<ActionParameter<?>>singletonList(new SearchSettingsActionParameter(SEARCH_EXPRESSION)); 586 586 } 587 588 public static String escapeStringForSearch(String s) { 589 return s.replace("\\", "\\\\").replace("\"", "\\\""); 590 } 587 591 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r4500 r4503 102 102 import org.openstreetmap.josm.tools.Shortcut; 103 103 import org.openstreetmap.josm.tools.Utils; 104 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 105 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 104 106 105 107 /** … … 182 184 private CopyKeyValueAction copyKeyValueAction = new CopyKeyValueAction(); 183 185 private CopyAllKeyValueAction copyAllKeyValueAction = new CopyAllKeyValueAction(); 186 private SearchAction searchActionSame = new SearchAction(true); 187 private SearchAction searchActionAny = new SearchAction(false); 184 188 private AddAction addAction = new AddAction(); 185 189 … … 616 620 propertyMenu.add(copyAllKeyValueAction); 617 621 propertyMenu.addSeparator(); 622 propertyMenu.add(searchActionAny); 623 propertyMenu.add(searchActionSame); 624 propertyMenu.addSeparator(); 618 625 propertyMenu.add(helpAction); 619 626 … … 1412 1419 } 1413 1420 } 1421 1422 class SearchAction extends AbstractAction { 1423 final boolean sameType; 1424 1425 public SearchAction(boolean sameType) { 1426 this.sameType = sameType; 1427 if (sameType) { 1428 putValue(NAME, tr("Search Key/Value/Type")); 1429 putValue(SHORT_DESCRIPTION, tr("Search with the key and value of the selected tag, restrict to type (i.e., node/way/relation)")); 1430 } else { 1431 putValue(NAME, tr("Search Key/Value")); 1432 putValue(SHORT_DESCRIPTION, tr("Search with the key and value of the selected tag")); 1433 } 1434 } 1435 1436 public void actionPerformed(ActionEvent e) { 1437 if (propertyTable.getSelectedRowCount() != 1) { 1438 return; 1439 } 1440 String key = propertyData.getValueAt(propertyTable.getSelectedRow(), 0).toString(); 1441 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 1442 if (sel.isEmpty()) { 1443 return; 1444 } 1445 String sep = ""; 1446 String s = ""; 1447 for (OsmPrimitive p : sel) { 1448 String val = p.get(key); 1449 if (val == null) { 1450 continue; 1451 } 1452 String t = ""; 1453 if (!sameType) { 1454 t = ""; 1455 } else if (p instanceof Node) { 1456 t = "type:node "; 1457 } else if (p instanceof Way) { 1458 t = "type:way "; 1459 } else if (p instanceof Relation) { 1460 t = "type:relation "; 1461 } 1462 s += sep + "(" + t + "\"" + 1463 org.openstreetmap.josm.actions.search.SearchAction.escapeStringForSearch(key) + "\"=\"" + 1464 org.openstreetmap.josm.actions.search.SearchAction.escapeStringForSearch(val) + "\")"; 1465 sep = " OR "; 1466 } 1467 1468 SearchSetting ss = new SearchSetting(s, SearchMode.replace, true, false, false); 1469 org.openstreetmap.josm.actions.search.SearchAction.searchWithoutHistory(ss); 1470 } 1471 } 1414 1472 }
Note:
See TracChangeset
for help on using the changeset viewer.