Class DelegatedCommand
- java.lang.Object
-
- javax.swing.AbstractAction
-
- ca.cgjennings.apps.arkham.commands.AbstractCommand
-
- ca.cgjennings.apps.arkham.commands.DelegatedCommand
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action
public class DelegatedCommand extends AbstractCommand
Delegated commands are commands that are normally handled by aCommandable, such as aStrangeEonsEditor, instead of being handled by the command itself.- Since:
- 3.0
- Author:
- Chris Jennings
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class ca.cgjennings.apps.arkham.commands.AbstractCommand
BUTTON_ID_KEY
-
-
Constructor Summary
Constructors Constructor Description DelegatedCommand()DelegatedCommand(java.lang.String nameKey)DelegatedCommand(java.lang.String nameKey, java.lang.String iconResource)DelegatedCommand(java.lang.String nameKey, java.lang.String iconResource, java.lang.String acceleratorKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)Executes the delegated command by finding a command handler to delegate to; if noCommandableis found, and a default action is applicable, then the default action is performed by callingperformDefaultAction(java.awt.event.ActionEvent).booleanisDefaultActionApplicable()Returnstrueif a default action is applicable.voidperformDefaultAction(java.awt.event.ActionEvent e)Performs a default action for this delegated command.voidupdate()Updates the command's state.-
Methods inherited from class ca.cgjennings.apps.arkham.commands.AbstractCommand
getAccelerator, getCommandString, getIcon, getName, setAccelerator, setIcon, setIcon, setName, setNameKey, toString
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Constructor Detail
-
DelegatedCommand
public DelegatedCommand()
-
DelegatedCommand
public DelegatedCommand(java.lang.String nameKey)
-
DelegatedCommand
public DelegatedCommand(java.lang.String nameKey, java.lang.String iconResource)
-
DelegatedCommand
public DelegatedCommand(java.lang.String nameKey, java.lang.String iconResource, java.lang.String acceleratorKey)
-
-
Method Detail
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Executes the delegated command by finding a command handler to delegate to; if noCommandableis found, and a default action is applicable, then the default action is performed by callingperformDefaultAction(java.awt.event.ActionEvent).- Parameters:
e- the action event that describes the command activation, ornull- See Also:
Commands.findCommandable(ca.cgjennings.apps.arkham.commands.AbstractCommand),isDefaultActionApplicable(),performDefaultAction(java.awt.event.ActionEvent)
-
performDefaultAction
public void performDefaultAction(java.awt.event.ActionEvent e)
Performs a default action for this delegated command. If no relevantCommandablewishes to handle a command, and ifisDefaultActionApplicable()returnstrue, then this method is called to handle the command. (The base class implementation does nothing.)- Parameters:
e- the event that caused the command to activate- See Also:
Commands.findCommandable(ca.cgjennings.apps.arkham.commands.AbstractCommand),actionPerformed(java.awt.event.ActionEvent),isDefaultActionApplicable()
-
isDefaultActionApplicable
public boolean isDefaultActionApplicable()
Returnstrueif a default action is applicable. (The base class implementation returnsfalse.)- Returns:
trueif there is a default action and it is currently applicable
-
update
public void update()
Updates the command's state. This method is called to update the command's internal state. It is typically called just before a menu containing the a menu item whose action is set to the command is displayed. (The default implementation does nothing.)For delegated commands, this method updates the command's enabled state based on whether a
Commandableis currently available to handle the command and whether a default action is currently applicable.- Overrides:
updatein classAbstractCommand
-
-