com.pietschy.command
Class ProxyCommand

java.lang.Object
  extended by com.pietschy.command.Command
      extended by com.pietschy.command.ActionCommand
          extended by com.pietschy.command.ProxyCommand
All Implemented Interfaces:
ActionCommandExecutor, Bindable, Identifiable

public class ProxyCommand
extends ActionCommand

A utility command that locates and executes a command in the CommandContainer heirarchy. This is a replacement for manually using CommandContainer.findCommand(String). The proxy automatically monitors changes to the container heirarchy and updates accordingly.

This command will automatically update its enabled and visible properties to track the actual command. Please note that the proxy doesn't track programmatic changes to the faces of the real command.


Field Summary
 
Fields inherited from class com.pietschy.command.ActionCommand
PARAMETER_ACTION_EVENT, PARAMETER_INVOKER, PARAMETER_INVOKER_WINDOW, PARAMETER_MODIFIERS
 
Fields inherited from class com.pietschy.command.Command
internalLog, PROPERTY_ENABLED, PROPERTY_VISIBLE
 
Constructor Summary
ProxyCommand(java.lang.String id)
          Creates a new instance with the specified id.
 
Method Summary
protected  void bindToContainer(CommandContainer container)
          Invoked to bind this instance to the specified container.
protected  void handleExecute()
          Executes the real command.
protected  void registerBoundProperty(java.lang.String property)
          Registers a property that will be monitored in the real command.
protected  void unbindFromContainer(CommandContainer container)
          Invoked to unbind this instance to the specified container.
protected  void updateState()
          Invoked to update the proxy state when ever the real command or one of it's registred properties change.
 
Methods inherited from class com.pietschy.command.ActionCommand
addActionCommandListener, addInterceptor, createButton, createButton, createButton, createButton, createMenuItem, createMenuItem, createMenuItem, createMenuItem, doButtonAttachments, doButtonDetachments, execute, execute, getActionAdapter, getActionAdapter, getActionEvent, getInvoker, getInvokerWindow, getModifiers, getParameter, getParameter, getParameters, installShortCut, installShortCut, postExecute, preExecute, putParameter, putParameters, removeActionCommandListener, removeInterceptor, requestDefaultIn, uninstallShortCut, uninstallShortCut
 
Methods inherited from class com.pietschy.command.Command
addContainerPropertyListener, addFace, addHoverListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, attach, bind, bind, bind, buttonIterator, configureAppearance, configureAppearances, configureButtonAppearances, configureButtonStates, configureButtonStates, createButton, createButton, createButton, createButton, createComponent, createMenuItem, createMenuItem, createMenuItem, createMenuItem, detach, faceExists, findBestFace, fireHoverEnded, fireHoverStarted, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlternativeFaceContexts, getButtonFactory, getButtonIn, getCommandContainer, getContainerProperty, getContainerPropertySupport, getDefaultFace, getDefaultFace, getFace, getFace, getId, getMenuFactory, getProperty, getProperty, getPropertyNames, getToolbarFactory, isAnonymous, isAttachedTo, isBound, isEnabled, isVisible, loadConfiguration, notifyCommandContainerHierarchyChanged, putProperties, putProperty, rebind, removeContainerPropertyListener, removeHoverListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, requestFocusIn, setButtonFactory, setEnabled, setMenuFactory, setToolbarFactory, setVisible, toString, unbind, validateId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.pietschy.command.ActionCommandExecutor
addPropertyChangeListener, addPropertyChangeListener, isEnabled, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.pietschy.command.Identifiable
getId
 

Constructor Detail

ProxyCommand

public ProxyCommand(java.lang.String id)
Creates a new instance with the specified id. This command will search for and activate the first command in the container heirarchy with the same id.

Parameters:
id - the id of the command to proxy.
Method Detail

registerBoundProperty

protected void registerBoundProperty(java.lang.String property)
Registers a property that will be monitored in the real command. updateState() will be called when ever the real command or the named property changes.

Parameters:
property - the property to monitor.

bindToContainer

protected void bindToContainer(CommandContainer container)
Description copied from class: ActionCommand
Invoked to bind this instance to the specified container. This method will add itself to the container if Command.isAnonymous() is false.

Subclasses may override this method to perform additional configuration such as adding a listener to the container. In this case subclasses must also override ActionCommand.unbindFromContainer(CommandContainer).

Overrides:
bindToContainer in class ActionCommand
Parameters:
container - the container to bind to.
See Also:
ActionCommand.unbindFromContainer(CommandContainer)

unbindFromContainer

protected void unbindFromContainer(CommandContainer container)
Description copied from class: ActionCommand
Invoked to unbind this instance to the specified container. This method will remove itself to the container if Command.isAnonymous() is false.

Overrides:
unbindFromContainer in class ActionCommand
Parameters:
container - the container to unbind from.
See Also:
ActionCommand.bindToContainer(CommandContainer)

updateState

protected void updateState()
Invoked to update the proxy state when ever the real command or one of it's registred properties change.

See Also:
registerBoundProperty(String)

handleExecute

protected void handleExecute()
Executes the real command.

Specified by:
handleExecute in class ActionCommand


Copyright © 2006 - 2007 Andrew Pietsch