// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.data.osm; import java.util.Objects; import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; import org.openstreetmap.josm.data.Preferences.pref; import org.openstreetmap.josm.data.Preferences.writeExplicitly; /** * Data class representing one entry in the filter dialog. * * @author Petr_DlouhĂ˝ * @since 2125 */ public class Filter extends SearchSetting { private static final String version = "1"; /** * Enabled status. * @see FilterPreferenceEntry#enable */ public boolean enable = true; /** * If this option is activated, the chosen objects are completely hidden. * Otherwise they are disabled and shown in a shade of gray. * @see FilterPreferenceEntry#hiding */ public boolean hiding; /** * Normally, the specified objects are hidden and the rest is shown. * If this option is activated, only the specified objects are shown and the rest is hidden. * @see FilterPreferenceEntry#inverted */ public boolean inverted; /** * Constructs a new {@code Filter}. */ public Filter() { super(); mode = SearchMode.add; } /** * Constructs a new {@code Filter} from a preference entry. * @param e preference entry */ public Filter(FilterPreferenceEntry e) { this(); text = e.text; if ("replace".equals(e.mode)) { mode = SearchMode.replace; } else if ("add".equals(e.mode)) { mode = SearchMode.add; } else if ("remove".equals(e.mode)) { mode = SearchMode.remove; } else if ("in_selection".equals(e.mode)) { mode = SearchMode.in_selection; } caseSensitive = e.case_sensitive; regexSearch = e.regex_search; mapCSSSearch = e.mapCSS_search; enable = e.enable; hiding = e.hiding; inverted = e.inverted; } public static class FilterPreferenceEntry { @writeExplicitly @pref public String version = "1"; @pref public String text; /** * Mode selector which defines how a filter is combined with the previous one: