|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pietschy.command.Command
org.pietschy.command.ActionCommand
public abstract class ActionCommand
ActionCommands provide the base for all executable commands. Subclasses must
implement handleExecute()
to provide command specific behaviour.
Field Summary | |
---|---|
static java.lang.String |
HINT_ACTION_EVENT
The key for the action event hint. |
static java.lang.String |
HINT_INVOKER
The key for the invoker hint. |
static java.lang.String |
HINT_INVOKER_WINDOW
The key for the invoker window hint. |
static java.lang.String |
HINT_MODIFIERS
The key for the modifiers hint. |
Fields inherited from class org.pietschy.command.Command |
---|
internalLog, listenerList, pcs |
Constructor Summary | |
---|---|
ActionCommand()
Creates a new anonymous ActionCommand. |
|
ActionCommand(CommandManager commandManager)
Creates a new anonymous command bound to the specified CommandManager.defaultInstance() . |
|
ActionCommand(CommandManager commandManager,
java.lang.String commandId)
Creates a new ActionCommand with the specified id that is bound to the specified CommandManager . |
|
ActionCommand(java.lang.String id)
Creates a new command with the speicifed Id that is bound to the CommandManager.defaultInstance() . |
Method Summary | |
---|---|
void |
addCommandListener(CommandListener l)
Deprecated. Use addInterceptor(ActionCommandInterceptor) instead. |
void |
addInterceptor(ActionCommandInterceptor interceptor)
Adds an ActionCommandInterceptor the the command. |
protected boolean |
areEqual(java.lang.Object oldValue,
java.lang.Object newValue)
Checks if the the two values are equal. |
void |
attach(javax.swing.AbstractButton button,
java.lang.String faceName)
Overrides the default implementation to also installFace an ActionListener to the button. |
protected void |
configureButtonStates(javax.swing.AbstractButton button)
This method is called to configure newly created buttons. |
void |
detach(javax.swing.AbstractButton button)
Overrides the default implementation to remove the ActionListener installed by
attach(javax.swing.AbstractButton, String) . |
void |
execute()
Causes the command to perform it's operation. |
void |
execute(java.util.Map hints)
Executes this command with the specified hints. |
javax.swing.Action |
getActionAdapter()
Gets an action that mirrors the default face of this command. |
javax.swing.Action |
getActionAdapter(java.lang.String faceName)
Gets an action that mirrors this the specified face of this command. |
java.lang.String |
getActionCommand()
Gets the value of this commands actionCommand string. |
java.awt.event.ActionEvent |
getActionEvent()
Convenience method for getHint(ActionCommand.HINT_ACTION_EVENT) . |
java.lang.Object |
getHint(java.lang.Object key)
Gets any hints that may have been specified by a call to execute(java.util.Map) or that have been explicitly set by putHint(java.lang.Object, java.lang.Object) . |
java.lang.Object |
getHint(java.lang.Object key,
java.lang.Object defaultValue)
Gets any hints that may have been specified by a call to execute(java.util.Map) or that have been explicitly set by putHint(java.lang.Object, java.lang.Object) . |
java.util.Map |
getHints()
Gets any hints that may have been specified by a call to execute(java.util.Map) or that have been explicitly set by putHint(java.lang.Object, java.lang.Object) . |
java.lang.Object |
getInvoker()
Convenience method to get the object that invoked the command. |
java.awt.Window |
getInvokerWindow()
Convenience method to get the Window ancestor of the object that invoked the command. |
int |
getModifiers()
Convenience method to get any modifiers that were specified. |
protected abstract void |
handleExecute()
Main entry point for command subclasses that must be implemented to provide command specific behaviour. |
void |
installShortCut(javax.swing.JComponent component,
int condition)
Installs a shortcut into the components input and action maps using the accelerator specified by the default face. |
void |
installShortCut(javax.swing.JComponent component,
java.lang.String faceName,
int condition)
Installs a shortcut into the components input and action maps using the accelerator of the specified face. |
protected void |
postExecute()
This method is called after handleExecute() has been called. |
protected boolean |
preExecute()
This method is called prior to handleExecute() being called. |
void |
putHint(java.lang.Object key,
java.lang.Object value)
Adds the specified hint to be available the next time execute(java.util.Map) is called. |
void |
putHints(java.util.Map hints)
Adds the specified hints to be available the next time execute(java.util.Map) is called. |
void |
removeCommandListener(CommandListener l)
Deprecated. use removeInterceptor(ActionCommandInterceptor) instead. |
void |
removeInterceptor(ActionCommandInterceptor interceptor)
Removes an ActionCommandInterceptor from the command. |
void |
requestDefautIn(javax.swing.RootPaneContainer container)
This method will find the first button from this command in the RootPaneContainer and set
it to be the default button by calling JRootPane.setDefaultButton(javax.swing.JButton) . |
void |
setActionCommand(java.lang.String actionCommand)
Sets the value of this commands actionCommand string. |
void |
uninstallShortCut(javax.swing.JComponent component,
int condition)
Removes the short cut installed by a previous call to installShortCut(javax.swing.JComponent, int) |
void |
uninstallShortCut(javax.swing.JComponent component,
java.lang.String faceName,
int condition)
Removes the short cut installed by a previous call to installShortCut(javax.swing.JComponent, String, int) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.pietschy.command.ActionCommandExecutor |
---|
addPropertyChangeListener, addPropertyChangeListener, isEnabled, removePropertyChangeListener, removePropertyChangeListener |
Field Detail |
---|
public static final java.lang.String HINT_ACTION_EVENT
AbstractButton
.
public static final java.lang.String HINT_MODIFIERS
AbstractButton
.
getModifiers()
,
Constant Field Valuespublic static final java.lang.String HINT_INVOKER
AbstractButton
.
getInvoker()
,
Constant Field Valuespublic static final java.lang.String HINT_INVOKER_WINDOW
getInvokerWindow()
,
Constant Field ValuesConstructor Detail |
---|
public ActionCommand()
groupCommand.installFace(myAnonymousCommand)
.
public ActionCommand(java.lang.String id)
CommandManager.defaultInstance()
.
public ActionCommand(CommandManager commandManager)
CommandManager.defaultInstance()
.
public ActionCommand(CommandManager commandManager, java.lang.String commandId)
CommandManager
.
Method Detail |
---|
protected abstract void handleExecute()
This method should never be called directly to invoke a comand. All
command invocation must be performed using the execute()
and
execute(Map)
methods.
public final void execute(java.util.Map hints)
putHint(java.lang.Object, java.lang.Object)
. The hints are only available for
this execution of the command.
execute
in interface ActionCommandExecutor
hints
- the hints this command is to use.putHint(java.lang.Object, java.lang.Object)
,
getHint(java.lang.Object)
public final void execute()
handleExecute()
to customize this commands behaviour.
public void requestDefautIn(javax.swing.RootPaneContainer container)
RootPaneContainer
and set
it to be the default button by calling JRootPane.setDefaultButton(javax.swing.JButton)
.
container
- the root pane container to check.public void putHint(java.lang.Object key, java.lang.Object value)
execute(java.util.Map)
is called.
key
- the name of the hint.value
- the hint value.public void putHints(java.util.Map hints)
execute(java.util.Map)
is called.
hints
- a list of hints to insert.public java.lang.Object getHint(java.lang.Object key)
execute(java.util.Map)
or that have been explicitly set by putHint(java.lang.Object, java.lang.Object)
.
key
- the name of the hint.
public java.lang.Object getHint(java.lang.Object key, java.lang.Object defaultValue)
execute(java.util.Map)
or that have been explicitly set by putHint(java.lang.Object, java.lang.Object)
.
key
- the name of the hint.defaultValue
- a default to return if the hint wasn't provided.
putHint(java.lang.Object, java.lang.Object)
public java.util.Map getHints()
execute(java.util.Map)
or that have been explicitly set by putHint(java.lang.Object, java.lang.Object)
.
putHint(java.lang.Object, java.lang.Object)
public int getModifiers()
public java.lang.Object getInvoker()
AbstractButton
that invoked to command. If the command was manually
invoked this will return null unless the hint HINT_INVOKER
has been
explicitly set.public java.awt.Window getInvokerWindow()
Component
then null is returned.
Otherwise, an attempt to find the Window ancestor is made using
SwingUtilities.getWindowAncestor(java.awt.Component)
or by traversing the ancestors and invokers of
popup menus.
Component
or
doesn't have a Window
ancestor. Otherwise the invokers Window
ancestor is
returned.getInvoker()
public java.awt.event.ActionEvent getActionEvent()
getHint(ActionCommand.HINT_ACTION_EVENT)
.
public void attach(javax.swing.AbstractButton button, java.lang.String faceName)
ActionListener
to the button.
attach
in class Command
button
- the button to attach to.faceName
- the face the button will be using.public void detach(javax.swing.AbstractButton button)
ActionListener
installed by
attach(javax.swing.AbstractButton, String)
.
detach
in class Command
button
- the button to attach to.protected void configureButtonStates(javax.swing.AbstractButton button)
configureButtonStates
in class Command
button
- the button to configure.public javax.swing.Action getActionAdapter()
public javax.swing.Action getActionAdapter(java.lang.String faceName)
public java.lang.String getActionCommand()
setActionCommand(java.lang.String)
it will be equal to the id
of the command.
public void setActionCommand(java.lang.String actionCommand)
id
of the command.
actionCommand
- the new value of the 'actionCommand'.protected boolean areEqual(java.lang.Object oldValue, java.lang.Object newValue)
protected boolean preExecute()
handleExecute()
being called. It simply
calls firePreExecute to notify all the register CommandListener
that
the command is about to execute.
protected void postExecute()
handleExecute()
has been called. It simply
calls firePostExecute to notify all the register CommandListener
that
the command has just completed.
public void addCommandListener(CommandListener l)
addInterceptor(ActionCommandInterceptor)
instead.
CommandListener
the the command. The listener will be notified when
the command is executed.
l
- the CommandListener
to registerremoveCommandListener(org.pietschy.command.CommandListener)
public void removeCommandListener(CommandListener l)
removeInterceptor(ActionCommandInterceptor)
instead.
CommandListener
the the command.
l
- the CommandListener
to removedaddCommandListener(org.pietschy.command.CommandListener)
public void addInterceptor(ActionCommandInterceptor interceptor)
ActionCommandInterceptor
the the command. The interceptor will be invoked
before and after the command is executed.
interceptor
- the ActionCommandInterceptor
to registerremoveInterceptor(ActionCommandInterceptor)
public void removeInterceptor(ActionCommandInterceptor interceptor)
ActionCommandInterceptor
from the command.
interceptor
- the ActionCommandInterceptor
to removeaddInterceptor(ActionCommandInterceptor)
public void installShortCut(javax.swing.JComponent component, int condition)
component
- The component to install the short cut in.condition
- The condition as per JComponent.getInputMap(int)
.public void installShortCut(javax.swing.JComponent component, java.lang.String faceName, int condition)
component
- The component to install the short cut in.faceName
- The face that defines the required accelerator.condition
- The condition as per JComponent.getInputMap(int)
.public void uninstallShortCut(javax.swing.JComponent component, int condition)
installShortCut(javax.swing.JComponent, int)
component
- The component the short cut was installed on.condition
- The condition as per JComponent.getInputMap(int)
.public void uninstallShortCut(javax.swing.JComponent component, java.lang.String faceName, int condition)
installShortCut(javax.swing.JComponent, String, int)
component
- The component the short cut was installed on.condition
- The condition as per JComponent.getInputMap(int)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |