public abstract class AbstractAction extends Object implements Action
Action
interface.
Standard behaviors like the get and set methods for Action
object
properties (icon, caption, enabled, ...) are defined here. The developer need
only subclass this abstract class and define the
ActionListener.actionPerformed(ActionEvent)
method.
CAPTION_PROPERTY, DESCRIPTION_PROPERTY, ENABLED_PROPERTY, ICON_PROPERTY, SHORTCUT_PROPERTY
Constructor and Description |
---|
AbstractAction(XdevUI ui)
Creates an
Action . |
AbstractAction(XdevUI ui,
Resource icon)
Creates an
Action with the specified icon. |
AbstractAction(XdevUI ui,
String caption)
Creates an
Action with the specified caption. |
AbstractAction(XdevUI ui,
String caption,
Resource icon)
Creates an
Action with the specified caption and icon. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChange listener. |
String |
getCaption()
Returns the caption of this action, used e.g.
|
String |
getDescription()
Returns the caption of this action, used e.g.
|
Resource |
getIcon()
Returns the icon of this action.
|
Shortcut |
getShortcut()
Returns the associated shortcut of this action.
|
XdevUI |
getUI()
Returns the UI object which this action is associated with.
|
boolean |
isEnabled()
Returns the enabled state of the
Action . |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChange listener. |
void |
setCaption(String caption)
Sets the caption of this action, used e.g.
|
void |
setDescription(String description)
Sets the description of this action, used e.g.
|
void |
setEnabled(boolean enabled)
Sets the enabled state of the
Action . |
void |
setIcon(Resource icon)
Returns the icon of this action.
|
void |
setShortcut(Shortcut shortcut)
Sets the shortcut for this action.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
actionPerformed
public AbstractAction(XdevUI ui)
Action
.public AbstractAction(XdevUI ui, String caption)
Action
with the specified caption.public AbstractAction(XdevUI ui, Resource icon)
Action
with the specified icon.public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChange
listener. Containers and attached
components use these methods to register interest in this
Action
object. When its enabled state or other property
changes, the registered listeners are informed of the change.addPropertyChangeListener
in interface Action
listener
- a PropertyChangeListener
objectpublic void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChange
listener.removePropertyChangeListener
in interface Action
listener
- a PropertyChangeListener
objectAction.addPropertyChangeListener(java.beans.PropertyChangeListener)
public XdevUI getUI()
public String getCaption()
XdevButton
.getCaption
in interface Action
public void setCaption(String caption)
XdevButton
.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
setCaption
in interface Action
caption
- the new captionAction.CAPTION_PROPERTY
public Resource getIcon()
public void setIcon(Resource icon)
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
setIcon
in interface Action
icon
- the icon of this actionAction.ICON_PROPERTY
public String getDescription()
XdevButton
.getDescription
in interface Action
public void setDescription(String description)
XdevButton
.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
setDescription
in interface Action
description
- the new captionAction.DESCRIPTION_PROPERTY
public Shortcut getShortcut()
getShortcut
in interface Action
public void setShortcut(Shortcut shortcut)
ActionListener.actionPerformed(ActionEvent)
method will be triggered, given that this action is enabled.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
The change of the shortcut will not reflect to already created components.
setShortcut
in interface Action
shortcut
- the new shortcutAction.SHORTCUT_PROPERTY
public boolean isEnabled()
Action
. When enabled, any
component associated with this object is active and able to fire this
object's actionPerformed
method.public void setEnabled(boolean enabled)
Action
. When enabled, any
component associated with this object is active and able to fire this
object's actionPerformed
method.
If the value has changed, a PropertyChangeEvent
is sent to
listeners.
setEnabled
in interface Action
enabled
- true to enable this Action
, false to disable itAction.ENABLED_PROPERTY