org.pietschy.command.undo
Class UndoableActionCommand

java.lang.Object
  extended by org.pietschy.command.Command
      extended by org.pietschy.command.ActionCommand
          extended by org.pietschy.command.undo.UndoableActionCommand
All Implemented Interfaces:
ActionCommandExecutor, UndoableEventSource

public abstract class UndoableActionCommand
extends ActionCommand
implements UndoableEventSource

UndoableActionCommands provide a default implementation for commands that can be undone. UndoableActionCommands implement UndoableEventSource and can be monitored by an UndoController

Version:
$Revision: 1.5 $
Author:
andrewp

Field Summary
 
Fields inherited from class org.pietschy.command.ActionCommand
HINT_ACTION_EVENT, HINT_INVOKER, HINT_INVOKER_WINDOW, HINT_MODIFIERS
 
Fields inherited from class org.pietschy.command.Command
internalLog, listenerList, pcs
 
Constructor Summary
UndoableActionCommand()
          Creates a new anonymous UndoableActionCommand.
UndoableActionCommand(CommandManager manager, java.lang.String commandId)
          Creates a new command with the specified id that is bound to the specified CommandManager.
UndoableActionCommand(java.lang.String commandId)
          Creates a new command with the speicifed Id that is bound to the CommandManager.defaultInstance().
 
Method Summary
 void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Adds a new UndoableEditListener to this command.
 javax.swing.event.UndoableEditListener[] getUndoableEditListeners()
          Gets the UndoableEditListeners regstered with this command.
protected  void handleExecute()
          Delegates to performEdit() and notifies any UndoableEditListeners of any edit that performEdit returns.
protected abstract  javax.swing.undo.UndoableEdit performEdit()
          Called by handleExecute() to perform the undoable edit.
protected  void postEdit(javax.swing.undo.UndoableEdit e)
          Notifies all the UndoableEditListeners of the undoable event.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Removes an UndoableEditListener from this command.
 
Methods inherited from class org.pietschy.command.ActionCommand
addCommandListener, addInterceptor, areEqual, attach, configureButtonStates, detach, execute, execute, getActionAdapter, getActionAdapter, getActionCommand, getActionEvent, getHint, getHint, getHints, getInvoker, getInvokerWindow, getModifiers, installShortCut, installShortCut, postExecute, preExecute, putHint, putHints, removeCommandListener, removeInterceptor, requestDefautIn, setActionCommand, uninstallShortCut, uninstallShortCut
 
Methods inherited from class org.pietschy.command.Command
addFace, addHoverListener, addNewFace, addNotify, addPropertyChangeListener, addPropertyChangeListener, buttonIterator, configureButtonAppearance, configureButtonAppearances, configureButtonAppearances, createButton, createButton, createButton, createButton, createMenuItem, createMenuItem, createMenuItem, createMenuItem, 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
 
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
 

Constructor Detail

UndoableActionCommand

public UndoableActionCommand()
Creates a new anonymous UndoableActionCommand. Anonymous commands must be fully programatically generated and can only be added to groups manually by calling groupCommand.installFace(myAnonymousCommand).


UndoableActionCommand

public UndoableActionCommand(java.lang.String commandId)
Creates a new command with the speicifed Id that is bound to the CommandManager.defaultInstance().


UndoableActionCommand

public UndoableActionCommand(CommandManager manager,
                             java.lang.String commandId)
Creates a new command with the specified id that is bound to the specified CommandManager.

Method Detail

performEdit

protected abstract javax.swing.undo.UndoableEdit performEdit()
Called by handleExecute() to perform the undoable edit. This method must return an undoable edit that can be used by an undo controller to reverse the effects of the command. This method may return null if nothing was done.

Returns:
an UndoableEdit that can be used to undo the effects of the command or null if no action was taken.

handleExecute

protected final void handleExecute()
Delegates to performEdit() and notifies any UndoableEditListeners of any edit that performEdit returns.

Specified by:
handleExecute in class ActionCommand

postEdit

protected void postEdit(javax.swing.undo.UndoableEdit e)
Notifies all the UndoableEditListeners of the undoable event.

Parameters:
e - the undoable event.

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Adds a new UndoableEditListener to this command.

Specified by:
addUndoableEditListener in interface UndoableEventSource
Parameters:
l - the listener to installFace.
See Also:
UndoController

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Removes an UndoableEditListener from this command.

Specified by:
removeUndoableEditListener in interface UndoableEventSource
Parameters:
l - the listener to remove.
See Also:
UndoController

getUndoableEditListeners

public javax.swing.event.UndoableEditListener[] getUndoableEditListeners()
Gets the UndoableEditListeners regstered with this command.

Specified by:
getUndoableEditListeners in interface UndoableEventSource
See Also:
UndoController