Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.pietschy.command.Command
org.pietschy.command.ActionCommand
handleExecute()
to provide command specific behaviour.
Field Summary | |
static String |
|
static String |
|
static String |
|
static String |
|
Fields inherited from class org.pietschy.command.Command | |
internalLog , listenerList , pcs |
Constructor Summary | |
| |
| |
| |
|
Method Summary | |
void |
|
void |
|
protected boolean |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
Action |
|
Action |
|
String |
|
ActionEvent |
|
Object |
|
Object |
|
Map |
|
Object |
|
Window |
|
int |
|
protected abstract void |
|
void |
|
void |
|
protected void |
|
protected boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public static final String HINT_ACTION_EVENT
The key for the action event hint. This hint will be present when ever the command is invoked from an attachedAbstractButton
.
public static final String HINT_INVOKER
The key for the invoker hint. This hint will be present when ever the command is invoked from an attachedAbstractButton
.
- See Also:
getInvoker()
public static final String HINT_INVOKER_WINDOW
The key for the invoker window hint. This hint will be present whenever the a Window parent can be found from the invoker.
- See Also:
getInvokerWindow()
public static final String HINT_MODIFIERS
The key for the modifiers hint. This hint will be present when ever the command is invoked from an attachedAbstractButton
.
- See Also:
getModifiers()
public ActionCommand()
Creates a new anonymous ActionCommand. Anonymous commands must be fully programatically generated and can only be added to groups manually by callinggroupCommand.installFace(myAnonymousCommand)
.
public ActionCommand(String id)
Creates a new command with the speicifed Id that is bound to theCommandManager.defaultInstance()
.
public ActionCommand(CommandManager commandManager)
Creates a new anonymous command bound to the specifiedCommandManager.defaultInstance()
.
public ActionCommand(CommandManager commandManager, String commandId)
Creates a new ActionCommand with the specified id that is bound to the specifiedCommandManager
.
public void addCommandListener(CommandListener l)
Deprecated. Use
addInterceptor(ActionCommandInterceptor)
instead.Adds aCommandListener
the the command. The listener will be notified when the command is executed.
- Parameters:
l
- theCommandListener
to register
public void addInterceptor(ActionCommandInterceptor interceptor)
Adds anActionCommandInterceptor
the the command. The interceptor will be invoked before and after the command is executed.
- Parameters:
interceptor
- theActionCommandInterceptor
to register
protected boolean areEqual(Object oldValue, Object newValue)
Checks if the the two values are equal. This method is null safe, that is either value may be null.
- Returns:
- true if oldValue equals newValue or if both values are null, false otherwise.
public void attach(AbstractButton button, String faceName)
Overrides the default implementation to also installFace anActionListener
to the button.
- Parameters:
button
- the button to attach to.faceName
- the face the button will be using.
protected void configureButtonStates(AbstractButton button)
This method is called to configure newly created buttons. Subclasses may override this method to perform special configuration if required.
- Overrides:
- configureButtonStates in interface Command
- Parameters:
button
- the button to configure.
public void detach(AbstractButton button)
Overrides the default implementation to remove theActionListener
installed byattach(javax.swing.AbstractButton, String)
.
- Parameters:
button
- the button to attach to.
public final void execute()
Causes the command to perform it's operation. Subclasses must implementhandleExecute()
to customize this commands behaviour.
public final void execute(Map hints)
Executes this command with the specified hints. The hints are added to any existing hints that have been configured usingputHint(Object,Object)
. The hints are only available for this execution of the command.
- Specified by:
- execute in interface ActionCommandExecutor
- Parameters:
hints
- the hints this command is to use.
- See Also:
putHint(Object,Object)
,getHint
public Action getActionAdapter()
Gets an action that mirrors the default face of this command. This is useful for use with the native cut and paste clipboard methods that require an action.
public Action getActionAdapter(String faceName)
Gets an action that mirrors this the specified face of this command. This is useful for use with the native cut and paste clipboard methods that require an action.
public String getActionCommand()
Gets the value of this commands actionCommand string. The actionCommand is provided for compatability with Swing actions. If it isn't explicity configured usingsetActionCommand(String)
it will be equal to theid
of the command.
- Returns:
- the 'actionCommand' value of this command.
public ActionEvent getActionEvent()
Convenience method forgetHint(ActionCommand.HINT_ACTION_EVENT)
.
public Object getHint(Object key)
Gets any hints that may have been specified by a call toexecute(java.util.Map)
or that have been explicitly set byputHint(Object,Object)
.
- Parameters:
key
- the name of the hint.
- Returns:
- the hint or null if the hint doesn't exist.
public Object getHint(Object key, Object defaultValue)
Gets any hints that may have been specified by a call toexecute(java.util.Map)
or that have been explicitly set byputHint(Object,Object)
.
- Parameters:
key
- the name of the hint.defaultValue
- a default to return if the hint wasn't provided.
- Returns:
- the hint or defaultValue if the hint wasn't specified exist.
- See Also:
putHint(Object,Object)
public Map getHints()
Gets any hints that may have been specified by a call toexecute(java.util.Map)
or that have been explicitly set byputHint(Object,Object)
.
- Returns:
- the hint or defaultValue if the hint wasn't specified exist.
- See Also:
putHint(Object,Object)
public Object getInvoker()
Convenience method to get the object that invoked the command. If the command was invoked from from a button (or menu) then the invoker will be that button.
- Returns:
- the
AbstractButton
that invoked to command. If the command was manually invoked this will return null unless the hintHINT_INVOKER
has been explicitly set.
public Window getInvokerWindow()
Convenience method to get the Window ancestor of the object that invoked the command. If the invoker is null, or doesn't decend fromComponent
then null is returned. Otherwise, an attempt to find the Window ancestor is made usingSwingUtilities.getWindowAncestor
or by traversing the ancestors and invokers of popup menus.
- Returns:
- null if the invoker is null, doesn't extend
Component
or doesn't have aWindow
ancestor. Otherwise the invokersWindow
ancestor is returned.
- See Also:
getInvoker()
public int getModifiers()
Convenience method to get any modifiers that were specified. Modifiers are always copied from any action event that triggers this command.
protected abstract void handleExecute()
Main entry point for command subclasses that must be implemented to provide command specific behaviour. This method should never be called directly to invoke a comand. All command invocation must be performed using theexecute()
andexecute(Map)
methods.
public void installShortCut(JComponent component, String faceName, int condition)
Installs a shortcut into the components input and action maps using the accelerator of the specified face.
- Parameters:
component
- The component to install the short cut in.faceName
- The face that defines the required accelerator.condition
- The condition as perjavax.swing.JComponent.getInputMap(int)
.
public void installShortCut(JComponent component, int condition)
Installs a shortcut into the components input and action maps using the accelerator specified by the default face.
- Parameters:
component
- The component to install the short cut in.condition
- The condition as perjavax.swing.JComponent.getInputMap(int)
.
protected void postExecute()
This method is called afterhandleExecute()
has been called. It simply calls firePostExecute to notify all the registerCommandListener
that the command has just completed.
protected boolean preExecute()
This method is called prior tohandleExecute()
being called. It simply calls firePreExecute to notify all the registerCommandListener
that the command is about to execute.
public void putHint(Object key, Object value)
Adds the specified hint to be available the next timeexecute
is called.
- Parameters:
key
- the name of the hint.value
- the hint value.
public void putHints(Map hints)
Adds the specified hints to be available the next timeexecute
is called.
- Parameters:
hints
- a list of hints to insert.
public void removeCommandListener(CommandListener l)
Deprecated. use
removeInterceptor(ActionCommandInterceptor)
instead.Removes aCommandListener
the the command.
- Parameters:
l
- theCommandListener
to removed
- See Also:
addCommandListener(CommandListener)
public void removeInterceptor(ActionCommandInterceptor interceptor)
Removes anActionCommandInterceptor
from the command.
- Parameters:
interceptor
- theActionCommandInterceptor
to remove
public void requestDefautIn(RootPaneContainer container)
This method will find the first button from this command in thejavax.swing.RootPaneContainer
and set it to be the default button by callingjavax.swing.JRootPane.setDefaultButton
.
- Parameters:
container
- the root pane container to check.
public void setActionCommand(String actionCommand)
Sets the value of this commands actionCommand string. The actionCommand is provided for compatability with Swing actions. If it isn't explicity configured it will be equal to theid
of the command.
- Parameters:
actionCommand
- the new value of the 'actionCommand'.
public void uninstallShortCut(JComponent component, String faceName, int condition)
Removes the short cut installed by a previous call toinstallShortCut(javax.swing.JComponent, String, int)
- Parameters:
component
- The component the short cut was installed on.condition
- The condition as perjavax.swing.JComponent.getInputMap(int)
.
public void uninstallShortCut(JComponent component, int condition)
Removes the short cut installed by a previous call toinstallShortCut(javax.swing.JComponent, int)
- Parameters:
component
- The component the short cut was installed on.condition
- The condition as perjavax.swing.JComponent.getInputMap(int)
.