-
Notifications
You must be signed in to change notification settings - Fork 204
Add support for deprecated attribute and update the presets search dialog #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||||
| // License: GPL. For details, see LICENSE file. | ||||||||
| package org.openstreetmap.josm.gui.tagging.presets; | ||||||||
|
|
||||||||
| import java.util.EnumMap; | ||||||||
| import java.util.Map; | ||||||||
|
|
||||||||
| import static org.openstreetmap.josm.tools.I18n.marktr; | ||||||||
|
|
||||||||
| /** | ||||||||
| * This enum defines different filters for searching presets. | ||||||||
| */ | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| public enum PresetSearchFilter { | ||||||||
| ONLY_APPLICABLE(marktr("Show only applicable to selection")), | ||||||||
| SEARCH_IN_TAGS(marktr("Search in tags")), | ||||||||
| DEPRECATED_TAGS(marktr("Show deprecated tags")); | ||||||||
|
|
||||||||
| /** | ||||||||
| * Map containing the preferences for the filters | ||||||||
| */ | ||||||||
| private Map<PresetSearchFilter, Boolean> filtersPreference; | ||||||||
|
|
||||||||
| static { | ||||||||
| for (PresetSearchFilter filter : values()) { | ||||||||
| filter.filtersPreference = new EnumMap<>(PresetSearchFilter.class); | ||||||||
| filter.filtersPreference.put(filter, true); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Sets the preference for the filter | ||||||||
| * @param filter the filter to set the preference for | ||||||||
| * @param pref true if the filter is enabled, false otherwise | ||||||||
| * @since xxx | ||||||||
| */ | ||||||||
| public void setPref(PresetSearchFilter filter, Boolean pref) { | ||||||||
| filtersPreference.put(filter, pref); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Gets the preference for the filter | ||||||||
| * @param filter the filter to get the preference for | ||||||||
| * @return true if the filter is enabled, false otherwise | ||||||||
| * @since xxx | ||||||||
| */ | ||||||||
| public Boolean getPref(PresetSearchFilter filter) { | ||||||||
| return filtersPreference.get(filter); | ||||||||
|
||||||||
| } | ||||||||
|
||||||||
|
|
||||||||
| /** | ||||||||
| * The translated text associated with the enum constant. | ||||||||
| */ | ||||||||
| private final String translatedText; | ||||||||
|
|
||||||||
| /** | ||||||||
| * Constructor for the PresetSearchFilter enum. | ||||||||
| * Initializes an enum constant with its corresponding translated text. | ||||||||
| * | ||||||||
| * @param translatedText The translated text associated with the enum constant. | ||||||||
| */ | ||||||||
| PresetSearchFilter(String translatedText) { | ||||||||
| this.translatedText = translatedText; | ||||||||
|
||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Returns the text associated with the filter | ||||||||
| * @return the text marked for translation | ||||||||
| */ | ||||||||
| public String getText() { | ||||||||
| return translatedText; | ||||||||
| } | ||||||||
|
|
||||||||
| } | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -136,6 +136,10 @@ public class TaggingPreset extends AbstractAction implements ActiveLayerChangeLi | |||||||
| * Show the preset name if true | ||||||||
| */ | ||||||||
| public boolean preset_name_label; | ||||||||
| /** | ||||||||
| * True if the preset is deprecated | ||||||||
| */ | ||||||||
| private boolean deprecated; | ||||||||
|
|
||||||||
| /** | ||||||||
| * The types as preparsed collection. | ||||||||
|
|
@@ -349,6 +353,23 @@ public void setMatch_expression(String filter) throws SAXException { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * @return true if the preset is deprecated | ||||||||
| * @apiNote this is not {@code isDeprecated} just in case we decide to make {@link TaggingPreset} a record class. | ||||||||
| * @since xxx | ||||||||
| */ | ||||||||
| public final boolean deprecated() { | ||||||||
| return this.deprecated; | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Set if the preset is deprecated | ||||||||
| * @param deprecated if true the preset is deprecated | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| */ | ||||||||
| public final void setDeprecated(boolean deprecated) { | ||||||||
| this.deprecated = deprecated; | ||||||||
| } | ||||||||
|
|
||||||||
| private static class PresetPanel extends JPanel { | ||||||||
| private boolean hasElements; | ||||||||
|
|
||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,7 @@ public static synchronized TaggingPresetSearchPrimitiveDialog getInstance() { | |
| super(MainApplication.getMainFrame(), tr("Search for objects by preset"), tr("Search"), tr("Cancel")); | ||
| setButtonIcons("dialogs/search", "cancel"); | ||
| configureContextsensitiveHelp("/Action/TaggingPresetSearchPrimitive", true /* show help button */); | ||
| selector = new TaggingPresetSelector(false, false); | ||
| selector = new TaggingPresetSelector(PresetSearchFilter.values()); | ||
|
||
| setContent(selector, false); | ||
| selector.setDblClickListener(e -> buttonAction(0, null)); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be the equivalent of
new TaggingPresetSelector(true, true, true), which I don't think you wanted. You probably wanted to just donew TaggingPresetSelector().