org.pietschy.command.undo
Class UndoableToggleCommand
- ActionCommandExecutor, UndoableEventSource
public abstract class UndoableToggleCommand
UndoableToggleCommands provide a default implementation for toggle commands that can be undone.
UndoableToggleCommands implement
UndoableEventSource
and can be monitored by an
UndoController
.
Subclasses must implement
performEdit(boolean)
to handle the selection process.
void | addUndoableEditListener(UndoableEditListener l) - Adds a new
javax.swing.event.UndoableEditListener to this command.
|
UndoableEditListener[] | getUndoableEditListeners() - Gets the
javax.swing.event.UndoableEditListener s regstered with this command.
|
protected void | handleSelection(boolean selected) - Delegates to
performEdit(boolean)
|
protected abstract UndoableEdit | performEdit(boolean selected) - Subclasses must override to perform the actual edit.
|
protected void | postEdit(UndoableEdit e) - Notifies all the
javax.swing.event.UndoableEditListener s of the undoable event.
|
void | removeUndoableEditListener(UndoableEditListener l) - Removes an
javax.swing.event.UndoableEditListener from this command.
|
addNotify , applySelection , attemptSelection , configureButtonStates , createButton , createCheckBox , createCheckBox , createCheckBox , createCheckBox , createMenuItem , handleExecute , handleSelection , isSelected , removeNotify , requestDefautIn , setSelected |
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 |
UndoableToggleCommand
public UndoableToggleCommand()
Creates a new anonymous UndoableToggleCommand. Anonymous commands must be fully programatically
generated and can only be added to groups manually by calling
groupCommand.installFace(myAnonymousCommand)
.
UndoableToggleCommand
public UndoableToggleCommand(String commandId)
UndoableToggleCommand
protected UndoableToggleCommand(CommandManager commandManager,
String commandId)
Creates a new command with the specified id that is bound to the
specified
CommandManager
.
addUndoableEditListener
public void addUndoableEditListener(UndoableEditListener l)
Adds a new javax.swing.event.UndoableEditListener
to this command.
- addUndoableEditListener in interface UndoableEventSource
l
- the listener to installFace.
getUndoableEditListeners
public UndoableEditListener[] getUndoableEditListeners()
Gets the javax.swing.event.UndoableEditListener
s regstered with this command.
- getUndoableEditListeners in interface UndoableEventSource
performEdit
protected abstract UndoableEdit performEdit(boolean selected)
throws ToggleVetoException
Subclasses must override to perform the actual edit. This method behaves similar to
ToggleCommand.handleSelection(boolean)
in that it can throw a
ToggleVetoException
to cancel the edit.
Please note that the edit object should call
applySelection(boolean)
to update the state of this command
without causing a new UndoableEdit to be created. For example
class MyToggle.ToggleUndoableEdit extends UndoableEdit
{
public void undo()
{
// undo any command specific stuff...
...
// and reset our state without causeing any side effects..
applySelection(oldState);
}
}
selected
- the new selected state of the command.
- an UndoableEdit object that can undo and redo the commands action.
postEdit
protected void postEdit(UndoableEdit e)
Notifies all the javax.swing.event.UndoableEditListener
s of the undoable event.
removeUndoableEditListener
public void removeUndoableEditListener(UndoableEditListener l)
Removes an javax.swing.event.UndoableEditListener
from this command.
- removeUndoableEditListener in interface UndoableEventSource
l
- the listener to remove.