Changeset 5441 in josm for trunk/src/org/openstreetmap/josm/actions/search
- Timestamp:
- 2012-08-13T09:05:30+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r5360 r5441 47 47 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 48 48 import org.openstreetmap.josm.tools.GBC; 49 import org.openstreetmap.josm.tools.Predicate; 49 50 import org.openstreetmap.josm.tools.Property; 50 51 import org.openstreetmap.josm.tools.Shortcut; … … 474 475 } 475 476 476 public interface Function{ 477 public Boolean isSomething(OsmPrimitive o); 478 } 479 480 public static int getSelection(SearchSetting s, Collection<OsmPrimitive> sel, Function f) { 477 public static int getSelection(SearchSetting s, Collection<OsmPrimitive> sel, Predicate<OsmPrimitive> p) { 481 478 int foundMatches = 0; 482 479 try { … … 500 497 ++foundMatches; 501 498 } 502 } else if (s.mode == SearchMode.add && ! f.isSomething(osm) && matcher.match(osm)) {499 } else if (s.mode == SearchMode.add && !p.evaluate(osm) && matcher.match(osm)) { 503 500 sel.add(osm); 504 501 ++foundMatches; 505 } else if (s.mode == SearchMode.remove && f.isSomething(osm) && matcher.match(osm)) {502 } else if (s.mode == SearchMode.remove && p.evaluate(osm) && matcher.match(osm)) { 506 503 sel.remove(osm); 507 504 ++foundMatches; 508 } else if (s.mode == SearchMode.in_selection && f.isSomething(osm)&& !matcher.match(osm)) {505 } else if (s.mode == SearchMode.in_selection && p.evaluate(osm) && !matcher.match(osm)) { 509 506 sel.remove(osm); 510 507 ++foundMatches; … … 570 567 571 568 public static void search(SearchSetting s) { 572 // FIXME: This is confusing. The GUI says nothing about loading primitives from an URL. We'd like to *search*573 // for URLs in the current data set.574 // Disabling until a better solution is in place575 //576 // if (search.startsWith("http://") || search.startsWith("ftp://") || search.startsWith("https://")577 // || search.startsWith("file:/")) {578 // SelectionWebsiteLoader loader = new SelectionWebsiteLoader(search, mode);579 // if (loader.url != null && loader.url.getHost() != null) {580 // Main.worker.execute(loader);581 // return;582 // }583 // }584 569 585 570 final DataSet ds = Main.main.getCurrentDataSet(); 586 571 Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(ds.getAllSelected()); 587 int foundMatches = getSelection(s, sel, new Function(){ 588 public Boolean isSomething(OsmPrimitive o){ 572 int foundMatches = getSelection(s, sel, new Predicate<OsmPrimitive>(){ 573 @Override 574 public boolean evaluate(OsmPrimitive o){ 589 575 return ds.isSelected(o); 590 576 }
Note:
See TracChangeset
for help on using the changeset viewer.