Changeset 12662 in josm
- Timestamp:
- 2017-08-26T01:29:38+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r12659 r12662 47 47 import org.openstreetmap.josm.data.osm.Filter; 48 48 import org.openstreetmap.josm.data.osm.OsmPrimitive; 49 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer; 50 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 51 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; 52 import org.openstreetmap.josm.data.osm.search.SearchCompiler.SimpleMatchFactory; 53 import org.openstreetmap.josm.data.osm.search.SearchMode; 49 54 import org.openstreetmap.josm.data.osm.search.SearchParseError; 50 55 import org.openstreetmap.josm.data.osm.search.SearchSetting; 51 import org.openstreetmap.josm.data.osm.search.SearchCompiler;52 import org.openstreetmap.josm.data.osm.search.SearchMode;53 56 import org.openstreetmap.josm.gui.ExtendedDialog; 54 57 import org.openstreetmap.josm.gui.MainApplication; … … 89 92 private static final LinkedList<SearchSetting> searchHistory = new LinkedList<>(); 90 93 static { 94 SearchCompiler.addMatchFactory(new SimpleMatchFactory() { 95 @Override 96 public Collection<String> getKeywords() { 97 return Arrays.asList("inview", "allinview"); 98 } 99 100 @Override 101 public Match get(String keyword, PushbackTokenizer tokenizer) throws SearchParseError { 102 switch(keyword) { 103 case "inview": 104 return new InView(false); 105 case "allinview": 106 return new InView(true); 107 default: 108 throw new IllegalStateException("Not expecting keyword " + keyword); 109 } 110 } 111 }); 112 91 113 for (String s: Main.pref.getCollection("search.history", Collections.<String>emptyList())) { 92 114 SearchSetting ss = SearchSetting.readFromString(s); -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r12659 r12662 36 36 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range; 37 37 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token; 38 import org.openstreetmap.josm.gui.MainApplication;39 38 import org.openstreetmap.josm.gui.mappaint.Environment; 40 39 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; … … 124 123 "changeset", "nodes", "ways", "tags", "areasize", "waylength", "modified", "deleted", "selected", 125 124 "incomplete", "untagged", "closed", "new", "indownloadedarea", 126 "allindownloadedarea", " inview", "allinview", "timestamp", "nth", "nth%", "hasRole", "preset");125 "allindownloadedarea", "timestamp", "nth", "nth%", "hasRole", "preset"); 127 126 128 127 @Override … … 147 146 case "allindownloadedarea": 148 147 return new InDataSourceArea(true); 149 case "inview":150 return new InView(false);151 case "allinview":152 return new InView(true);153 148 default: 154 149 if (tokenizer != null) { … … 1461 1456 * Matches objects within the given bounds. 1462 1457 */ 1463 p rivateabstract static class InArea extends Match {1458 public abstract static class InArea extends Match { 1464 1459 1465 1460 protected final boolean all; … … 1468 1463 * @param all if true, all way nodes or relation members have to be within source area;if false, one suffices. 1469 1464 */ 1470 InArea(boolean all) {1465 protected InArea(boolean all) { 1471 1466 this.all = all; 1472 1467 } … … 1539 1534 public String toString() { 1540 1535 return "NotOutsideDataSourceArea"; 1541 }1542 }1543 1544 /**1545 * Matches objects within current map view.1546 */1547 private static class InView extends InArea {1548 1549 InView(boolean all) {1550 super(all);1551 }1552 1553 @Override1554 protected Collection<Bounds> getBounds(OsmPrimitive primitive) {1555 if (!MainApplication.isDisplayingMapView()) {1556 return null;1557 }1558 return Collections.singleton(MainApplication.getMap().mapView.getRealBounds());1559 }1560 1561 @Override1562 public String toString() {1563 return all ? "allinview" : "inview";1564 1536 } 1565 1537 }
Note:
See TracChangeset
for help on using the changeset viewer.