|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
public abstract class JosmAction
Base class helper for all Actions in JOSM. Just to make the life easier.
A JosmAction is a MapView.LayerChangeListener
and a SelectionChangedListener
. Upon
a layer change event or a selection change event it invokes updateEnabledState()
.
Subclasses can override updateEnabledState()
in order to update the AbstractAction.isEnabled()
-state
of a JosmAction depending on the getCurrentDataSet()
and the current layers
(see also getEditLayer()
).
destroy() from interface Destroyable is called e.g. for MapModes, when the last layer has
been removed and so the mapframe will be destroyed. For other JosmActions, destroy() may never
be called (currently).
Nested Class Summary | |
---|---|
private class |
JosmAction.LayerChangeAdapter
Adapter for layer change events |
private class |
JosmAction.SelectionChangeAdapter
Adapter for selection change events |
Field Summary | |
---|---|
private JosmAction.LayerChangeAdapter |
layerChangeAdapter
|
protected Shortcut |
sc
|
private JosmAction.SelectionChangeAdapter |
selectionChangeAdapter
|
Fields inherited from class javax.swing.AbstractAction |
---|
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
---|
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 Summary | |
---|---|
JosmAction()
|
|
JosmAction(boolean installAdapters)
|
|
JosmAction(java.lang.String name,
javax.swing.Icon icon,
java.lang.String tooltip,
Shortcut shortcut,
boolean registerInToolbar,
java.lang.String toolbarId,
boolean installAdapters)
Constructs a JosmAction . |
|
JosmAction(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut,
boolean register)
|
|
JosmAction(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut,
boolean register,
boolean installAdapters)
|
|
JosmAction(java.lang.String name,
java.lang.String iconName,
java.lang.String tooltip,
Shortcut shortcut,
boolean register,
java.lang.String toolbarId,
boolean installAdapters)
The new super for all actions. |
Method Summary | |
---|---|
void |
destroy()
Called when the object has been destroyed. |
protected static DataSet |
getCurrentDataSet()
Replies the current dataset |
protected static OsmDataLayer |
getEditLayer()
Replies the current edit layer |
Shortcut |
getShortcut()
|
protected void |
initEnabledState()
Override in subclasses to init the enabled state of an action when it is created. |
protected void |
installAdapters()
|
private void |
setHelpId()
|
void |
setTooltip(java.lang.String tooltip)
|
protected void |
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. |
protected void |
updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
Override in subclasses to update the enabled state of the action if the collection of selected primitives changes. |
Methods inherited from class javax.swing.AbstractAction |
---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.event.ActionListener |
---|
actionPerformed |
Field Detail |
---|
protected Shortcut sc
private JosmAction.LayerChangeAdapter layerChangeAdapter
private JosmAction.SelectionChangeAdapter selectionChangeAdapter
Constructor Detail |
---|
public JosmAction(java.lang.String name, javax.swing.Icon icon, java.lang.String tooltip, Shortcut shortcut, boolean registerInToolbar, java.lang.String toolbarId, boolean installAdapters)
JosmAction
.
name
- the action's text as displayed on the menu (if it is added to a menu)icon
- the icon to usetooltip
- a longer description of the action that will be displayed in the tooltip. Please note
that html is not supported for menu actions on some platforms.shortcut
- a ready-created shortcut object or null if you don't want a shortcut. But you always
do want a shortcut, remember you can always register it with group=none, so you
won't be assigned a shortcut unless the user configures one. If you pass null here,
the user CANNOT configure a shortcut for your action.registerInToolbar
- register this action for the toolbar preferences?toolbarId
- identifier for the toolbar preferences. The iconName is used, if this parameter is nullinstallAdapters
- false, if you don't want to install layer changed and selection changed adapterspublic JosmAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean register, java.lang.String toolbarId, boolean installAdapters)
name
- the action's text as displayed on the menu (if it is added to a menu)iconName
- the filename of the icon to usetooltip
- a longer description of the action that will be displayed in the tooltip. Please note
that html is not supported for menu actions on some platforms.shortcut
- a ready-created shortcut object or null if you don't want a shortcut. But you always
do want a shortcut, remember you can always register it with group=none, so you
won't be assigned a shortcut unless the user configures one. If you pass null here,
the user CANNOT configure a shortcut for your action.register
- register this action for the toolbar preferences?toolbarId
- identifier for the toolbar preferences. The iconName is used, if this parameter is nullinstallAdapters
- false, if you don't want to install layer changed and selection changed adapterspublic JosmAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean register, boolean installAdapters)
public JosmAction(java.lang.String name, java.lang.String iconName, java.lang.String tooltip, Shortcut shortcut, boolean register)
public JosmAction()
public JosmAction(boolean installAdapters)
Method Detail |
---|
public Shortcut getShortcut()
public void destroy()
Destroyable
destroy
in interface Destroyable
private void setHelpId()
public void setTooltip(java.lang.String tooltip)
protected static OsmDataLayer getEditLayer()
protected static DataSet getCurrentDataSet()
protected void installAdapters()
protected void initEnabledState()
updateEnabledState()
updateEnabledState()
,
updateEnabledState(Collection)
protected void updateEnabledState()
updateEnabledState(Collection)
to respond to changes in the collection
of selected primitives.
Default behavior is empty.
updateEnabledState(Collection)
,
initEnabledState()
protected void updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
selection
- the collection of selected primitives; may be empty, but not nullupdateEnabledState()
,
initEnabledState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |