-
Notifications
You must be signed in to change notification settings - Fork 194
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
Add support for deprecated attribute and update the presets search dialog #123
base: master
Are you sure you want to change the base?
Changes from 1 commit
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); | ||||||||
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. This should be done via the standard |
||||||||
} | ||||||||
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. When I said, "we should use an EnumMap", this is not what I was thinking. I'll go find one of the methods using this enum and see if I can hack together something there as an example. Generally speaking, |
||||||||
|
||||||||
/** | ||||||||
* 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; | ||||||||
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. To avoid confusion, this should probably be |
||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* 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 |
---|---|---|
|
@@ -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, false); | ||
selector = new TaggingPresetSelector(PresetSearchFilter.values()); | ||
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. This would be the equivalent of new |
||
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()
.