Class TaggingPresetItemGuiSupport
- java.lang.Object
-
- org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport
-
- All Implemented Interfaces:
TemplateEngineDataProvider
public final class TaggingPresetItemGuiSupport extends Object implements TemplateEngineDataProvider
Supporting class for creating the GUI for a preset item.- Since:
- 17609
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TaggingPresetItemGuiSupport.ChangeListener
Interface to notify listeners that a preset item input as changed.
-
Field Summary
Fields Modifier and Type Field Description private Supplier<Collection<Tag>>
changedTagsSupplier
private boolean
enabled
whether to fire events or notprivate ListenerList<TaggingPresetItemGuiSupport.ChangeListener>
listeners
private boolean
presetInitiallyMatches
True if all selected primitives matched this preset at the moment it was openend.private Collection<OsmPrimitive>
selected
-
Constructor Summary
Constructors Modifier Constructor Description private
TaggingPresetItemGuiSupport(boolean presetInitiallyMatches, Collection<OsmPrimitive> selected, Supplier<Collection<Tag>> changedTagsSupplier)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(TaggingPresetItemGuiSupport.ChangeListener listener)
Adds a new change listenerstatic TaggingPresetItemGuiSupport
create(boolean presetInitiallyMatches, Collection<OsmPrimitive> selected, Supplier<Collection<Tag>> changedTagsSupplier)
Creates a newTaggingPresetItemGuiSupport
static TaggingPresetItemGuiSupport
create(boolean presetInitiallyMatches, OsmPrimitive... selected)
Creates a newTaggingPresetItemGuiSupport
boolean
evaluateCondition(SearchCompiler.Match condition)
Check if a condition holds for the object represented by thisTemplateEngineDataProvider
.void
fireItemValueModified(TaggingPresetItem source, String key, String newValue)
Notifies all listeners that a preset item input as changed.ComponentOrientation
getDefaultComponentOrientation()
Returns the default component orientation by the user's localeCollection<OsmPrimitive>
getSelected()
Returns the selected primitivesTagged
getTagged()
Get tags with values as currently shown in the dialog.Collection<String>
getTemplateKeys()
Get the collection of all keys that can be mapped to values.Object
getTemplateValue(String key, boolean special)
Map a key to a value given the properties of the object.boolean
isEnabled()
Returns whether firing of events is enabledboolean
isPresetInitiallyMatches()
Returns true if all selected primitives matched this preset (before opening the dialog).boolean
setEnabled(boolean enabled)
Enables or disables the firing of events
-
-
-
Field Detail
-
selected
private final Collection<OsmPrimitive> selected
-
presetInitiallyMatches
private final boolean presetInitiallyMatches
True if all selected primitives matched this preset at the moment it was openend.
-
changedTagsSupplier
private final Supplier<Collection<Tag>> changedTagsSupplier
-
listeners
private final ListenerList<TaggingPresetItemGuiSupport.ChangeListener> listeners
-
enabled
private boolean enabled
whether to fire events or not
-
-
Constructor Detail
-
TaggingPresetItemGuiSupport
private TaggingPresetItemGuiSupport(boolean presetInitiallyMatches, Collection<OsmPrimitive> selected, Supplier<Collection<Tag>> changedTagsSupplier)
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
Returns whether firing of events is enabled- Returns:
- true if firing of events is enabled
-
setEnabled
public boolean setEnabled(boolean enabled)
Enables or disables the firing of events- Parameters:
enabled
- fires if true- Returns:
- the old state of enabled
-
getSelected
public Collection<OsmPrimitive> getSelected()
Returns the selected primitives- Returns:
- the selected primitives
-
isPresetInitiallyMatches
public boolean isPresetInitiallyMatches()
Returns true if all selected primitives matched this preset (before opening the dialog).This usually means that the preset dialog was opened from the Tags / Memberships panel as opposed to being opened by selection from the menu or toolbar or the search.
- Returns:
- true if the preset initially matched
-
create
public static TaggingPresetItemGuiSupport create(boolean presetInitiallyMatches, Collection<OsmPrimitive> selected, Supplier<Collection<Tag>> changedTagsSupplier)
Creates a newTaggingPresetItemGuiSupport
- Parameters:
presetInitiallyMatches
- whether the preset initially matchedselected
- the selected primitiveschangedTagsSupplier
- the changed tags- Returns:
- the new
TaggingPresetItemGuiSupport
-
create
public static TaggingPresetItemGuiSupport create(boolean presetInitiallyMatches, OsmPrimitive... selected)
Creates a newTaggingPresetItemGuiSupport
- Parameters:
presetInitiallyMatches
- whether the preset initially matchedselected
- the selected primitives- Returns:
- the new
TaggingPresetItemGuiSupport
-
getTagged
public Tagged getTagged()
Get tags with values as currently shown in the dialog. If exactly one primitive is selected, get all tags of it, then overwrite with the current values shown in the dialog. Else get only the tags shown in the dialog.- Returns:
- Tags
-
getTemplateKeys
public Collection<String> getTemplateKeys()
Description copied from interface:TemplateEngineDataProvider
Get the collection of all keys that can be mapped to values.- Specified by:
getTemplateKeys
in interfaceTemplateEngineDataProvider
- Returns:
- all keys that can be mapped to values
-
getTemplateValue
public Object getTemplateValue(String key, boolean special)
Description copied from interface:TemplateEngineDataProvider
Map a key to a value given the properties of the object.- Specified by:
getTemplateValue
in interfaceTemplateEngineDataProvider
- Parameters:
key
- the key to mapspecial
- if the key is a "special:*" keyword that is used to get certain information or automated behavior- Returns:
- a value that the key is mapped to or "special" information in case
special
is true
-
getDefaultComponentOrientation
public ComponentOrientation getDefaultComponentOrientation()
Returns the default component orientation by the user's locale- Returns:
- the default component orientation
-
evaluateCondition
public boolean evaluateCondition(SearchCompiler.Match condition)
Description copied from interface:TemplateEngineDataProvider
Check if a condition holds for the object represented by thisTemplateEngineDataProvider
.- Specified by:
evaluateCondition
in interfaceTemplateEngineDataProvider
- Parameters:
condition
- the condition to check (which is a search expression)- Returns:
- true if the condition holds
-
addListener
public void addListener(TaggingPresetItemGuiSupport.ChangeListener listener)
Adds a new change listener- Parameters:
listener
- the listener to add
-
fireItemValueModified
public void fireItemValueModified(TaggingPresetItem source, String key, String newValue)
Notifies all listeners that a preset item input as changed.- Parameters:
source
- the source of this eventkey
- the tag keynewValue
- the new tag value
-
-