Ignore:
Timestamp:
2017-08-26T01:29:38+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - remove dependence on GUI from data.osm.search.SearchCompiler

Location:
trunk/src/org/openstreetmap/josm/actions/search
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r12659 r12662  
    4747import org.openstreetmap.josm.data.osm.Filter;
    4848import org.openstreetmap.josm.data.osm.OsmPrimitive;
     49import org.openstreetmap.josm.data.osm.search.PushbackTokenizer;
     50import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     51import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     52import org.openstreetmap.josm.data.osm.search.SearchCompiler.SimpleMatchFactory;
     53import org.openstreetmap.josm.data.osm.search.SearchMode;
    4954import org.openstreetmap.josm.data.osm.search.SearchParseError;
    5055import 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;
    5356import org.openstreetmap.josm.gui.ExtendedDialog;
    5457import org.openstreetmap.josm.gui.MainApplication;
     
    8992    private static final LinkedList<SearchSetting> searchHistory = new LinkedList<>();
    9093    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
    91113        for (String s: Main.pref.getCollection("search.history", Collections.<String>emptyList())) {
    92114            SearchSetting ss = SearchSetting.readFromString(s);
Note: See TracChangeset for help on using the changeset viewer.