public class TaggingPreset extends javax.swing.AbstractAction implements MainLayerManager.ActiveLayerChangeListener, AdaptableAction, java.util.function.Predicate<IPrimitive>
Modifier and Type | Class and Description |
---|---|
private static class |
TaggingPreset.PresetDialog |
private static class |
TaggingPreset.PresetPanel |
class |
TaggingPreset.ToolbarButtonAction
Action that adds or removes the button on main toolbar
|
Modifier and Type | Field and Description |
---|---|
java.util.List<TaggingPresetItem> |
data |
static int |
DIALOG_ANSWER_APPLY |
static int |
DIALOG_ANSWER_CANCEL |
static int |
DIALOG_ANSWER_NEW_RELATION |
TaggingPresetMenu |
group
The preset group this preset belongs to.
|
private java.util.concurrent.CompletableFuture<java.lang.Void> |
iconFuture
The completable future task of asynchronous icon loading
|
java.lang.String |
iconName
The icon name assigned to this preset.
|
java.lang.String |
locale_name
A cache for the local name.
|
java.lang.String |
name
The name of the tagging preset.
|
java.lang.String |
name_context |
TemplateEntry |
nameTemplate |
SearchCompiler.Match |
nameTemplateFilter |
static java.lang.String |
OPTIONAL_TOOLTIP_TEXT |
private boolean |
originalSelectionEmpty
True whenever the original selection given into createSelection was empty
|
static java.lang.String |
PRESET_ICON_ERROR_MSG_PREFIX
Prefix of preset icon loading failure error message
|
boolean |
preset_name_label |
Roles |
roles |
java.util.Set<TaggingPresetType> |
types
The types as preparsed collection.
|
Constructor and Description |
---|
TaggingPreset()
Create an empty tagging preset.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
void |
activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
Called whenever the active or edit layer changed.
|
static Command |
createCommand(java.util.Collection<OsmPrimitive> sel,
java.util.List<Tag> changedTags)
Create a command to change the given list of tags.
|
TaggingPreset.PresetPanel |
createPanel(java.util.Collection<OsmPrimitive> selected)
Creates a panel for this preset.
|
java.util.Collection<OsmPrimitive> |
createSelection(java.util.Collection<OsmPrimitive> participants)
Removes all unsuitable OsmPrimitives from the given list
|
java.util.List<Tag> |
getChangedTags()
Gets a list of tags that are set by this preset.
|
private java.util.List<Tag> |
getDirectlyAppliedTags()
Returns the tags being directly applied (without UI element) by
Key items |
javax.swing.ImageIcon |
getIcon()
Returns the preset icon (16px).
|
javax.swing.ImageIcon |
getIcon(java.lang.String key)
Returns the preset icon (16 or 24px).
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
getIconLoadingTask()
Returns the completable future task that performs icon loading, if any.
|
java.lang.String |
getLocaleName()
Gets the localized version of the name
|
java.lang.String |
getName()
Returns the translated name of this preset, prefixed with the group names it belongs to.
|
java.lang.String |
getRawName()
Returns the non translated name of this preset, prefixed with the (non translated) group names it belongs to.
|
java.lang.String |
getToolbarString()
Gets a string describing this preset that can be used for the toolbar
|
boolean |
isShowable()
Determines whether a dialog can be shown for this preset, i.e., at least one tag can/must be set by the user.
|
boolean |
matches(java.util.Collection<TaggingPresetType> t,
java.util.Map<java.lang.String,java.lang.String> tags,
boolean onlyShowable)
Determines whether this preset matches the parameters.
|
void |
setDisplayName()
Change the display name without changing the toolbar value.
|
void |
setIcon(java.lang.String iconName)
Called from the XML parser to set the icon.
|
void |
setName_template_filter(java.lang.String filter) |
void |
setName_template(java.lang.String pattern) |
void |
setType(java.lang.String types)
Called from the XML parser to set the types this preset affects.
|
int |
showDialog(java.util.Collection<OsmPrimitive> sel,
boolean showNewRelation)
Shows the preset dialog.
|
java.lang.String |
suggestRoleForOsmPrimitive(OsmPrimitive osm) |
private boolean |
supportsRelation() |
boolean |
test(IPrimitive p)
Determines whether this preset matches the given primitive, i.e.,
whether the
type matches and the tags match . |
java.lang.String |
toString() |
boolean |
typeMatches(java.util.Collection<TaggingPresetType> t)
Determines whether this preset matches the types.
|
protected void |
updateEnabledState() |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public static final int DIALOG_ANSWER_APPLY
public static final int DIALOG_ANSWER_NEW_RELATION
public static final int DIALOG_ANSWER_CANCEL
public static final java.lang.String OPTIONAL_TOOLTIP_TEXT
public static final java.lang.String PRESET_ICON_ERROR_MSG_PREFIX
public TaggingPresetMenu group
public java.lang.String name
getRawName()
public java.lang.String iconName
public java.lang.String name_context
public java.lang.String locale_name
getLocaleName()
public boolean preset_name_label
public transient java.util.Set<TaggingPresetType> types
public final transient java.util.List<TaggingPresetItem> data
public transient TemplateEntry nameTemplate
public transient SearchCompiler.Match nameTemplateFilter
private boolean originalSelectionEmpty
private java.util.concurrent.CompletableFuture<java.lang.Void> iconFuture
public TaggingPreset()
public void setDisplayName()
public java.lang.String getLocaleName()
public java.lang.String getName()
public java.lang.String getRawName()
public final javax.swing.ImageIcon getIcon()
null
if none definedpublic final javax.swing.ImageIcon getIcon(java.lang.String key)
key
- Key determining icon size: Action.SMALL_ICON
for 16x, Action.LARGE_ICON_KEY
for 24pxnull
if none definedpublic void setIcon(java.lang.String iconName)
iconName
- icon namepublic void setType(java.lang.String types) throws org.xml.sax.SAXException
types
- comma-separated primitive types ("node", "way", "relation" or "closedway")org.xml.sax.SAXException
- if any SAX error occursTaggingPresetType.fromString(java.lang.String)
public void setName_template(java.lang.String pattern) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void setName_template_filter(java.lang.String filter) throws org.xml.sax.SAXException
org.xml.sax.SAXException
private java.util.List<Tag> getDirectlyAppliedTags()
Key
itemspublic TaggingPreset.PresetPanel createPanel(java.util.Collection<OsmPrimitive> selected)
types
.
This includes the elements from the individual items
.selected
- the selected primitivespublic boolean isShowable()
true
if a dialog can be shown for this presetpublic java.lang.String suggestRoleForOsmPrimitive(OsmPrimitive osm)
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public int showDialog(java.util.Collection<OsmPrimitive> sel, boolean showNewRelation)
sel
- selectionshowNewRelation
- whether to display "New relation" buttonpublic java.util.Collection<OsmPrimitive> createSelection(java.util.Collection<OsmPrimitive> participants)
participants
- List of possible OsmPrimitives to tagpublic java.util.List<Tag> getChangedTags()
public static Command createCommand(java.util.Collection<OsmPrimitive> sel, java.util.List<Tag> changedTags)
sel
- The primitives to change the tags forchangedTags
- The tags to changeprivate boolean supportsRelation()
protected final void updateEnabledState()
public void activeOrEditLayerChanged(MainLayerManager.ActiveLayerChangeEvent e)
MainLayerManager.ActiveLayerChangeListener
You can be sure that this layer is still contained in this set.
Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.
activeOrEditLayerChanged
in interface MainLayerManager.ActiveLayerChangeListener
e
- The change event.public java.lang.String toString()
toString
in class java.lang.Object
public boolean typeMatches(java.util.Collection<TaggingPresetType> t)
t
- The types that must matchtrue
if all types match.public boolean test(IPrimitive p)
type matches
and the tags match
.test
in interface java.util.function.Predicate<IPrimitive>
p
- the primitivetrue
if this preset matches the primitivepublic boolean matches(java.util.Collection<TaggingPresetType> t, java.util.Map<java.lang.String,java.lang.String> tags, boolean onlyShowable)
t
- the preset types to include, see typeMatches(Collection)
tags
- the tags to perform matching on, see TaggingPresetItem.matches(Map)
onlyShowable
- whether the preset must be showable
true
if this preset matches the parameters.public java.lang.String getToolbarString()
ToolbarPreferences.addCustomButton(String, int, boolean)
public java.util.concurrent.CompletableFuture<java.lang.Void> getIconLoadingTask()