- Timestamp:
- 2015-10-01T21:06:17+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r8811 r8812 249 249 JCheckBox allElements = new JCheckBox(tr("all objects"), initialValues.allElements); 250 250 allElements.setToolTipText(tr("Also include incomplete and deleted objects in search.")); 251 final JCheckBox regexSearch = new JCheckBox(tr("regular expression"), initialValues.regexSearch); 252 final JCheckBox addOnToolbar = new JCheckBox(tr("add toolbar button"), false); 251 final JCheckBox regexSearch = new JCheckBox(tr("regular expression"), initialValues.regexSearch); 252 final JCheckBox mapCSSSearch = new JCheckBox(tr("MapCSS selector"), initialValues.mapCSSSearch); 253 final JCheckBox addOnToolbar = new JCheckBox(tr("add toolbar button"), false); 254 final ButtonGroup bg2 = new ButtonGroup(); 255 bg2.add(regexSearch); 256 bg2.add(mapCSSSearch); 253 257 254 258 JPanel top = new JPanel(new GridBagLayout()); … … 264 268 left.add(allElements, GBC.eol()); 265 269 left.add(regexSearch, GBC.eol()); 270 left.add(mapCSSSearch, GBC.eol()); 266 271 left.add(addOnToolbar, GBC.eol()); 267 272 } … … 290 295 ss.caseSensitive = caseSensitive.isSelected(); 291 296 ss.regexSearch = regexSearch.isSelected(); 297 ss.mapCSSSearch = mapCSSSearch.isSelected(); 292 298 SearchCompiler.compile(ss); 293 299 super.buttonAction(buttonIndex, evt); … … 321 327 initialValues.allElements = allElements.isSelected(); 322 328 initialValues.regexSearch = regexSearch.isSelected(); 329 initialValues.mapCSSSearch = mapCSSSearch.isSelected(); 323 330 324 331 if (addOnToolbar.isSelected()) { … … 589 596 public boolean caseSensitive; 590 597 public boolean regexSearch; 598 public boolean mapCSSSearch; 591 599 public boolean allElements; 592 600 … … 602 610 caseSensitive = original.caseSensitive; 603 611 regexSearch = original.regexSearch; 612 mapCSSSearch = original.mapCSSSearch; 604 613 allElements = original.allElements; 605 614 } … … 612 621 String rx = regexSearch ? ", " + 613 622 /*regex search*/ trc("search", "RX") : ""; 623 String css = mapCSSSearch ? ", " + 624 /*MapCSS search*/ trc("search", "CSS") : ""; 614 625 String all = allElements ? ", " + 615 626 /*all elements*/ trc("search", "A") : ""; 616 return "\"" + text + "\" (" + cs + rx + all + ", " + mode + ")";627 return "\"" + text + "\" (" + cs + rx + css + all + ", " + mode + ")"; 617 628 } 618 629 … … 624 635 return o.caseSensitive == this.caseSensitive 625 636 && o.regexSearch == this.regexSearch 637 && o.mapCSSSearch == this.mapCSSSearch 626 638 && o.allElements == this.allElements 627 639 && o.mode.equals(this.mode) … … 655 667 } else if (s.charAt(index) == 'A') { 656 668 result.allElements = true; 669 } else if (s.charAt(index) == 'M') { 670 result.mapCSSSearch = true; 657 671 } else if (s.charAt(index) == ' ') { 658 672 break; … … 685 699 result.append('R'); 686 700 } 701 if (mapCSSSearch) { 702 result.append('M'); 703 } 687 704 if (allElements) { 688 705 result.append('A'); -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r8811 r8812 28 28 import org.openstreetmap.josm.data.osm.RelationMember; 29 29 import org.openstreetmap.josm.data.osm.Way; 30 import org.openstreetmap.josm.gui.mappaint.Environment; 31 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 32 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; 33 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser; 34 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; 30 35 import org.openstreetmap.josm.tools.Geometry; 31 36 import org.openstreetmap.josm.tools.Predicate; … … 1424 1429 */ 1425 1430 public static Match compile(SearchAction.SearchSetting setting) throws ParseError { 1431 if (setting.mapCSSSearch) { 1432 return compileMapCSS(setting.text); 1433 } 1426 1434 return new SearchCompiler(setting.caseSensitive, setting.regexSearch, 1427 1435 new PushbackTokenizer( 1428 1436 new PushbackReader(new StringReader(setting.text)))) 1429 1437 .parse(); 1438 } 1439 1440 static Match compileMapCSS(String mapCSS) throws ParseError { 1441 try { 1442 final Selector selector = new MapCSSParser(new StringReader(mapCSS)).selector(); 1443 return new Match() { 1444 @Override 1445 public boolean match(OsmPrimitive osm) { 1446 return selector.matches(new Environment(osm)); 1447 } 1448 }; 1449 } catch (ParseException e) { 1450 throw new ParseError(tr("Failed to parse MapCSS selector"), e); 1451 } 1430 1452 } 1431 1453 -
trunk/src/org/openstreetmap/josm/data/osm/Filter.java
r8811 r8812 40 40 caseSensitive = e.case_sensitive; 41 41 regexSearch = e.regex_search; 42 mapCSSSearch = e.mapCSS_search; 42 43 enable = e.enable; 43 44 hiding = e.hiding; … … 51 52 @pref public boolean case_sensitive = false; 52 53 @pref public boolean regex_search = false; 54 @pref public boolean mapCSS_search = false; 53 55 @pref @writeExplicitly public boolean enable = true; 54 56 @pref @writeExplicitly public boolean hiding = false; … … 63 65 e.case_sensitive = caseSensitive; 64 66 e.regex_search = regexSearch; 67 e.mapCSS_search = mapCSSSearch; 65 68 e.enable = enable; 66 69 e.hiding = hiding;
Note:
See TracChangeset
for help on using the changeset viewer.