Changeset 8811 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2015-10-01T21:06:10+02:00 (7 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
r8540 r8811 286 286 if (buttonIndex == 0) { 287 287 try { 288 SearchCompiler.compile(hcbSearchString.getText(), caseSensitive.isSelected(), regexSearch.isSelected()); 288 SearchSetting ss = new SearchSetting(); 289 ss.text = hcbSearchString.getText(); 290 ss.caseSensitive = caseSensitive.isSelected(); 291 ss.regexSearch = regexSearch.isSelected(); 292 SearchCompiler.compile(ss); 289 293 super.buttonAction(buttonIndex, evt); 290 294 } catch (ParseError e) { … … 454 458 int foundMatches = 0; 455 459 try { 456 String searchText = s.text; 457 SearchCompiler.Match matcher = SearchCompiler.compile(searchText, s.caseSensitive, s.regexSearch); 460 SearchCompiler.Match matcher = SearchCompiler.compile(s); 458 461 459 462 if (s.mode == SearchMode.replace) { … … 508 511 public static void getSelection(SearchSetting s, Collection<OsmPrimitive> all, Property<OsmPrimitive, Boolean> p) { 509 512 try { 510 String searchText = s.text;511 513 if (s instanceof Filter && ((Filter) s).inverted) { 512 searchText = String.format("-(%s)", searchText); 513 } 514 SearchCompiler.Match matcher = SearchCompiler.compile(searchText, s.caseSensitive, s.regexSearch); 514 s = new SearchSetting(s); 515 s.text = String.format("-(%s)", s.text); 516 } 517 SearchCompiler.Match matcher = SearchCompiler.compile(s); 515 518 516 519 for (OsmPrimitive osm : all) { … … 540 543 541 544 public static void search(String search, SearchMode mode) { 542 search(new SearchSetting(search, mode, false, false, false)); 545 final SearchSetting searchSetting = new SearchSetting(); 546 searchSetting.text = search; 547 searchSetting.mode = mode; 548 search(searchSetting); 543 549 } 544 550 … … 579 585 580 586 public static class SearchSetting { 581 public String text ;582 public SearchMode mode ;587 public String text = ""; 588 public SearchMode mode = SearchMode.replace; 583 589 public boolean caseSensitive; 584 590 public boolean regexSearch; … … 589 595 */ 590 596 public SearchSetting() { 591 this("", SearchMode.replace, false /* case insensitive */,592 false /* no regexp */, false /* only useful primitives */);593 }594 595 public SearchSetting(String text, SearchMode mode, boolean caseSensitive,596 boolean regexSearch, boolean allElements) {597 this.caseSensitive = caseSensitive;598 this.regexSearch = regexSearch;599 this.allElements = allElements;600 this.mode = mode;601 this.text = text;602 597 } 603 598 604 599 public SearchSetting(SearchSetting original) { 605 this(original.text, original.mode, original.caseSensitive, 606 original.regexSearch, original.allElements); 600 text = original.text; 601 mode = original.mode; 602 caseSensitive = original.caseSensitive; 603 regexSearch = original.regexSearch; 604 allElements = original.allElements; 607 605 } 608 606 … … 612 610 /*case sensitive*/ trc("search", "CS") : 613 611 /*case insensitive*/ trc("search", "CI"); 614 612 String rx = regexSearch ? ", " + 615 613 /*regex search*/ trc("search", "RX") : ""; 616 614 String all = allElements ? ", " + 617 615 /*all elements*/ trc("search", "A") : ""; 618 616 return "\"" + text + "\" (" + cs + rx + all + ", " + mode + ")"; 619 617 } 620 618 -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r8781 r8811 1402 1402 } 1403 1403 1404 public static Match compile(String searchStr, boolean caseSensitive, boolean regexSearch) throws ParseError { 1405 return new SearchCompiler(caseSensitive, regexSearch, 1404 /** 1405 * Compiles the search expression. 1406 * @param searchStr the search expression 1407 * @return a {@link Match} object for the expression 1408 * @throws ParseError if an error has been encountered while compiling 1409 * @see #compile(org.openstreetmap.josm.actions.search.SearchAction.SearchSetting) 1410 */ 1411 public static Match compile(String searchStr) throws ParseError { 1412 return new SearchCompiler(false, false, 1406 1413 new PushbackTokenizer( 1407 1414 new PushbackReader(new StringReader(searchStr)))) 1408 .parse(); 1415 .parse(); 1416 } 1417 1418 /** 1419 * Compiles the search expression. 1420 * @param setting the settings to use 1421 * @return a {@link Match} object for the expression 1422 * @throws ParseError if an error has been encountered while compiling 1423 * @see #compile(String) 1424 */ 1425 public static Match compile(SearchAction.SearchSetting setting) throws ParseError { 1426 return new SearchCompiler(setting.caseSensitive, setting.regexSearch, 1427 new PushbackTokenizer( 1428 new PushbackReader(new StringReader(setting.text)))) 1429 .parse(); 1409 1430 } 1410 1431
Note: See TracChangeset
for help on using the changeset viewer.