com.pietschy.command.undo
Class AbstractUndoCommand

java.lang.Object
  extended by com.pietschy.command.Command
      extended by com.pietschy.command.ActionCommand
          extended by com.pietschy.command.undo.AbstractUndoCommand
All Implemented Interfaces:
ActionCommandExecutor, Bindable, Identifiable
Direct Known Subclasses:
RedoCommand, UndoCommand

public abstract class AbstractUndoCommand
extends ActionCommand

Base implementation for UndoCommand and RedoCommand. This implementation takes care of monitoring the parent CommandContainer and tracking the UndoContext. Subclasses must implement updateState() and ActionCommand.handleExecute().


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
AbstractUndoCommand()
          Creates a new anonymous instance.
AbstractUndoCommand(java.lang.String id)
          Creates a new instance with the specified id.
 
Method Summary
protected  void bindToContainer(CommandContainer container)
          Binds to the specified command container and updates the undo context.
protected  void containerStateChanged()
          Updates the current UndoContext whenever a change is detected in the current CommandContainer heirarchy.
 UndoContext getUndoContext()
          Gets the current UndoContext.
 void setUndoContext(UndoContext newContext)
          Sets the current UndoContext.
protected  void unbindFromContainer(CommandContainer container)
          Unbinds from the specified container and updates the undo context.
protected abstract  void updateState()
          Must be implemented by subsclasses to update this state based on the return value from getUndoContext().
 
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, handleExecute, 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, 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

AbstractUndoCommand

public AbstractUndoCommand()
Creates a new anonymous instance.


AbstractUndoCommand

public AbstractUndoCommand(java.lang.String id)
Creates a new instance with the specified id.

Parameters:
id - the command id.
Method Detail

bindToContainer

protected void bindToContainer(CommandContainer container)
Binds to the specified command container and updates the undo context.

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

unbindFromContainer

protected void unbindFromContainer(CommandContainer container)
Unbinds from the specified container and updates the undo context.

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

getUndoContext

public UndoContext getUndoContext()
Gets the current UndoContext. May return null.

Returns:
the current UndoContext or null if there is no undo context.

setUndoContext

public void setUndoContext(UndoContext newContext)
Sets the current UndoContext. This is typically updated automatically based on the current binding.

Parameters:
newContext - the new UndoContext.

containerStateChanged

protected void containerStateChanged()
Updates the current UndoContext whenever a change is detected in the current CommandContainer heirarchy.


updateState

protected abstract void updateState()
Must be implemented by subsclasses to update this state based on the return value from getUndoContext().



Copyright © 2006 - 2007 Andrew Pietsch