public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener, Predicate<OsmPrimitive>
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 |
---|---|
List<TaggingPresetItem> |
data |
static int |
DIALOG_ANSWER_APPLY |
static int |
DIALOG_ANSWER_CANCEL |
static int |
DIALOG_ANSWER_NEW_RELATION |
TaggingPresetMenu |
group |
String |
iconName |
String |
locale_name |
String |
name |
String |
name_context |
TemplateEntry |
nameTemplate |
SearchCompiler.Match |
nameTemplateFilter |
static String |
OPTIONAL_TOOLTIP_TEXT |
private boolean |
originalSelectionEmpty
True whenever the original selection given into createSelection was empty
|
static String |
PRESET_ICON_ERROR_MSG_PREFIX
Prefix of preset icon loading failure error message
|
boolean |
preset_name_label |
Roles |
roles |
Set<TaggingPresetType> |
types
The types as preparsed collection.
|
changeSupport, enabled
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
Constructor and Description |
---|
TaggingPreset()
Create an empty tagging preset.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e) |
void |
activeLayerChange(Layer oldLayer,
Layer newLayer)
Notifies this listener that the active layer has changed.
|
static Command |
createCommand(Collection<OsmPrimitive> sel,
List<Tag> changedTags) |
TaggingPreset.PresetPanel |
createPanel(Collection<OsmPrimitive> selected) |
Collection<OsmPrimitive> |
createSelection(Collection<OsmPrimitive> participants)
Removes all unsuitable OsmPrimitives from the given list
|
boolean |
evaluate(OsmPrimitive p)
Determines whether this preset matches the given primitive, i.e.,
whether the
type matches and the tags match . |
List<Tag> |
getChangedTags() |
ImageIcon |
getIcon()
Returns the preset icon.
|
String |
getLocaleName() |
String |
getName()
Returns the translated name of this preset, prefixed with the group names it belongs to.
|
String |
getRawName()
Returns the non translated name of this preset, prefixed with the (non translated) group names it belongs to.
|
String |
getToolbarString() |
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.
|
void |
layerAdded(Layer newLayer)
Notifies this listener that a layer has been added.
|
void |
layerRemoved(Layer oldLayer)
Notifies this listener that a layer has been removed.
|
boolean |
matches(Collection<TaggingPresetType> t,
Map<String,String> tags,
boolean onlyShowable)
Determines whether this preset matches the parameters.
|
void |
setDisplayName()
Change the display name without changing the toolbar value.
|
void |
setIcon(String iconName)
Called from the XML parser to set the icon.
|
void |
setName_template_filter(String filter) |
void |
setName_template(String pattern) |
void |
setType(String types)
Called from the XML parser to set the types this preset affects.
|
int |
showDialog(Collection<OsmPrimitive> sel,
boolean showNewRelation) |
String |
suggestRoleForOsmPrimitive(OsmPrimitive osm) |
private boolean |
supportsRelation() |
String |
toString() |
boolean |
typeMatches(Collection<TaggingPresetType> t) |
protected void |
updateEnabledState() |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
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 String OPTIONAL_TOOLTIP_TEXT
public static final String PRESET_ICON_ERROR_MSG_PREFIX
public TaggingPresetMenu group
public String name_context
public String locale_name
public boolean preset_name_label
public Set<TaggingPresetType> types
public transient List<TaggingPresetItem> data
public transient TemplateEntry nameTemplate
public transient SearchCompiler.Match nameTemplateFilter
private boolean originalSelectionEmpty
public TaggingPreset()
public void setDisplayName()
public String getLocaleName()
public String getName()
public String getRawName()
public final ImageIcon getIcon()
null
if none definedpublic void setIcon(String iconName)
iconName
- icon namepublic void setType(String types) throws SAXException
types
- comma-separated primitive types ("node", "way", "relation" or "closedway")SAXException
- if any SAX error occursTaggingPresetType.fromString(java.lang.String)
public void setName_template(String pattern) throws SAXException
SAXException
public void setName_template_filter(String filter) throws SAXException
SAXException
public TaggingPreset.PresetPanel createPanel(Collection<OsmPrimitive> selected)
public boolean isShowable()
true
if a dialog can be shown for this presetpublic String suggestRoleForOsmPrimitive(OsmPrimitive osm)
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public int showDialog(Collection<OsmPrimitive> sel, boolean showNewRelation)
public Collection<OsmPrimitive> createSelection(Collection<OsmPrimitive> participants)
participants
- List of possible OsmPrimitives to tagpublic List<Tag> getChangedTags()
public static Command createCommand(Collection<OsmPrimitive> sel, List<Tag> changedTags)
private boolean supportsRelation()
protected final void updateEnabledState()
public void activeLayerChange(Layer oldLayer, Layer newLayer)
MapView.LayerChangeListener
activeLayerChange
in interface MapView.LayerChangeListener
oldLayer
- The previous active layernewLayer
- The new activer layerpublic void layerAdded(Layer newLayer)
MapView.LayerChangeListener
layerAdded
in interface MapView.LayerChangeListener
newLayer
- The new added layerpublic void layerRemoved(Layer oldLayer)
MapView.LayerChangeListener
layerRemoved
in interface MapView.LayerChangeListener
oldLayer
- The old removed layerpublic boolean typeMatches(Collection<TaggingPresetType> t)
public boolean evaluate(OsmPrimitive p)
type matches
and the tags match
.evaluate
in interface Predicate<OsmPrimitive>
p
- the primitivetrue
if this preset matches the primitivepublic boolean matches(Collection<TaggingPresetType> t, Map<String,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 String getToolbarString()