org.pietschy.command.delegate
Class DelegatingCommand
- ActionCommandExecutor, DelegateMediatorListener, EventListener
public class DelegatingCommand
Delegating commands allow a single command to delegate its behaviour to another object. This is most useful when
the commands actaul behaviour is dependant on the current context of the UI. A typical examples would be cut, paste
and print.
The behaviour of the command is provided by instances of
CommandDelegate
which are
automatically extracted from the
DelegateContainer
once
trackDelegateIn(String, java.awt.Window)
has been invoked.
DelegatingCommands are automatically bound to
delegates
whose id match their own.
addCommandListener , addInterceptor , areEqual , attach , configureButtonStates , detach , execute , execute , getActionAdapter , getActionAdapter , getActionCommand , getActionEvent , getHint , getHint , getHints , getInvoker , getInvokerWindow , getModifiers , handleExecute , installShortCut , installShortCut , postExecute , preExecute , putHint , putHints , removeCommandListener , removeInterceptor , requestDefautIn , setActionCommand , uninstallShortCut , uninstallShortCut |
addFace , addHoverListener , addNewFace , addNotify , addPropertyChangeListener , addPropertyChangeListener , attach , buttonIterator , configureButtonAppearance , configureButtonAppearances , configureButtonAppearances , configureButtonStates , createButton , createButton , createButton , createButton , createMenuItem , createMenuItem , createMenuItem , createMenuItem , detach , export , faceExists , fireHoverEnded , fireHoverStarted , getAccelerator , getAlternativeFaceNames , getButtonFactory , getButtonIn , getCommandManager , getDefaultFace , getDefaultFace , getDescription , getFace , getFace , getIcon , getId , getLongDescription , getMenuFactory , getMnemonic , getMnemonicIndex , getProperty , getProperty , getPropertyNames , getSelectedIcon , getText , getTextPosition , getToolbarFactory , initCommandManager , installFace , isAnonymous , isAttachedTo , isEnabled , isVisible , putProperty , removeHoverListener , removeNotify , removePropertyChangeListener , removePropertyChangeListener , requestFocusIn , setAccelerator , setButtonFactory , setDescription , setEnabled , setIcon , setLongDescription , setMenuFactory , setMnemonic , setMnemonicIndex , setSelectedIcon , setText , setTextPosition , setToolbarFactory , setVisible , toString |
DelegatingCommand
public DelegatingCommand(String id)
id
- the id of the command.
DelegatingCommand
public DelegatingCommand(CommandManager commandManager,
String commandId)
Creates a new DelegatingCommand with the specified id and that is bound to the
specifed
CommandManager
.
commandManager
- the CommandManager to which the command is bound.commandId
- the id of the command.
setDelegate
protected void setDelegate(ActionCommandExecutor newDelegate)
Sets the delegate for this command to use. This method is automatically called when
trackDelegateIn(String, java.awt.Window)
is invoked.
and should not normally be used.
newDelegate
- the delegate this command is to use.
trackDelegateIn(String, java.awt.Window)
setDelegateIdToTrack
protected void setDelegateIdToTrack(String delegateIdToTrack)
Sets the delegate id this command is to track.
delegateIdToTrack
- the id of the delegate that this command will invoke.
trackDelegateIn
public DelegatingCommand trackDelegateIn(String delegateId,
Window window)
This method configures the command to track delegates in the specified
java.awt.Window
. The implementation
simply adds the command as a listener to the
DelegateManager
of the specified window.
I.e.
DelegateManager manager = DelegateManager.getInstanceFor(window);
manager.addDelegateManagerListener(this);
delegateId
- the id of the delegate to track.window
- the window in which to track delegates.
this
as a convenience for creating a new commannd on one line, new DelegatingCommand(...).trackDelegatesIn(win).export();.