Package com.luciad.gui
Class TLcdCompositeUndoable
java.lang.Object
com.luciad.gui.ALcdUndoable
com.luciad.gui.TLcdCompositeUndoable
- All Implemented Interfaces:
ILcdUndoable,ILcdPropertyChangeSource
Implementation of
ILcdUndoable that is composed of several other
ILcdUndoables. Its undo/redo methods apply to all undoable's at once. All undoables
added to this composite undoable are undone in the reverse order in which they were added, and
redone in the order they were added.
Example:
TLcdCompositeUndoable undoable = new TLcdCompositeUndoable("composite undoable");
//Here add all necessary undoables
undoable.addUndoable(anUndoable);
undoable.addUndoable(anotherUndoable);
// indicate that all undoables have been added
undoable.finish();
-
Constructor Summary
ConstructorsConstructorDescriptionTLcdCompositeUndoable(String aDisplayName) This constructor calls the analogous superclass constructor.TLcdCompositeUndoable(String aDisplayName, ILcdStringTranslator aStringTranslator) This constructor calls the analogous superclass constructor.TLcdCompositeUndoable(String aDisplayName, Format aUndoFormat, Format aRedoFormat) This constructor calls the analogous superclass constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddUndoable(ILcdUndoable aUndoable) Adds the givenILcdUndoableto this composite undoable.final ILcdUndoableListenerReturns anILcdUndoableListenerinstance that will add each receivedILcdUndoableto this composite implementation.booleanReturns whether or not this composite undoable can be redone.booleanReturns whether or not this composite undoable can be undone.voiddieImpl()Override this method with the actual die behavior.voidfinish()Finishes this composite undoable so that no other undoables can be added to it.Returns the display name of thisILcdUndoable.Takes the display name as defined in the constructorALcdUndoable(String)and formats it with the appropriate format.Takes the display name as defined in the constructorALcdUndoable(String)and formats it with the appropriate format.booleanReturns false if thisILcdUndoableis insignificant--for example one that maintains the user's selection, but does not change any model state.booleanReturns whether the display name of the wrapped undoable is used.protected voidredoImpl()Redoes allILcdUndoableobjects added to this composite in the order they were added.voidsetUseWrappedDisplayName(boolean aUseWrappedDisplayName) Specifies whether the display name of the contained undoable should be used when only one undoable is wrapped in this composite undoable.protected voidundoImpl()Undoes all addedILcdUndoableobjects added to this composite in the reverse order they were added.Methods inherited from class com.luciad.gui.ALcdUndoable
addPropertyChangeListener, canRedo, canUndo, die, redo, removePropertyChangeListener, undo
-
Constructor Details
-
TLcdCompositeUndoable
This constructor calls the analogous superclass constructor.- See Also:
-
TLcdCompositeUndoable
This constructor calls the analogous superclass constructor.- See Also:
-
TLcdCompositeUndoable
This constructor calls the analogous superclass constructor.- See Also:
-
-
Method Details
-
setUseWrappedDisplayName
public void setUseWrappedDisplayName(boolean aUseWrappedDisplayName) Specifies whether the display name of the contained undoable should be used when only one undoable is wrapped in this composite undoable.- Parameters:
aUseWrappedDisplayName-trueif you want the display name of the wrappedILcdUndoableto be used,falseotherwise.- See Also:
-
isUseWrappedDisplayName
public boolean isUseWrappedDisplayName()Returns whether the display name of the wrapped undoable is used.- Returns:
- Whether the display name of the wrapped undoable is used.
- See Also:
-
getDisplayName
Description copied from interface:ILcdUndoableReturns the display name of thisILcdUndoable. It can for example be used for logging purposes.- Specified by:
getDisplayNamein interfaceILcdUndoable- Overrides:
getDisplayNamein classALcdUndoable
-
getUndoDisplayName
Description copied from class:ALcdUndoableTakes the display name as defined in the constructorALcdUndoable(String)and formats it with the appropriate format.- Specified by:
getUndoDisplayNamein interfaceILcdUndoable- Overrides:
getUndoDisplayNamein classALcdUndoable- See Also:
-
getRedoDisplayName
Description copied from class:ALcdUndoableTakes the display name as defined in the constructorALcdUndoable(String)and formats it with the appropriate format.- Specified by:
getRedoDisplayNamein interfaceILcdUndoable- Overrides:
getRedoDisplayNamein classALcdUndoable- Returns:
- The redo display name
-
undoImpl
Undoes all addedILcdUndoableobjects added to this composite in the reverse order they were added. This means theILcdUndoablethat was added last will be undone first.- Specified by:
undoImplin classALcdUndoable- Throws:
TLcdCannotUndoRedoException
-
redoImpl
Redoes allILcdUndoableobjects added to this composite in the order they were added. This means theILcdUndoablethat was added first will be redone first.- Specified by:
redoImplin classALcdUndoable- Throws:
TLcdCannotUndoRedoException
-
addUndoable
Adds the givenILcdUndoableto this composite undoable. This undoable will be undone and redone, along with the other undoables that have been added. All undoables added to this composite undoable are undone in the order in which they were added, and redone in the reverse order they were added. Will only succeed iffinish()has not yet been called.- Specified by:
addUndoablein interfaceILcdUndoable- Overrides:
addUndoablein classALcdUndoable- Parameters:
aUndoable- The undoable to add.- Returns:
- Whether or not
aUndoablewas accepted by thisILcdUndoable.
-
finish
public void finish()Finishes this composite undoable so that no other undoables can be added to it.
Do not forget to call this method when you have added all necessary undoables, as
TLcdUndoManagercallsaddUndoable(ILcdUndoable)to provide multipleILcdUndoableinstances with the option of collapsing into a single one if this is desired. For instance several keystrokes can be combined in one undoable when a user is typing text. -
dieImpl
public void dieImpl()Description copied from class:ALcdUndoableOverride this method with the actual die behavior. This method is called bydie()when it is allowed to do so. The default implementation is an empty implementation.- Overrides:
dieImplin classALcdUndoable
-
isSignificant
public boolean isSignificant()Description copied from class:ALcdUndoableReturns false if thisILcdUndoableis insignificant--for example one that maintains the user's selection, but does not change any model state. This status can be used by anILcdUndoableListener(like TLcdUndoManager) when deciding whichILcdUndoables to present to the user as Undo/Redo options, and which to perform as side effects of undoing or redoing other events.This default implementation always returns true.
- Specified by:
isSignificantin interfaceILcdUndoable- Overrides:
isSignificantin classALcdUndoable- Returns:
- Whether or not this
ILcdUndoableis significant.
-
canRedoImpl
public boolean canRedoImpl()Returns whether or not this composite undoable can be redone.- Overrides:
canRedoImplin classALcdUndoable- Returns:
- True if this composite undoables was finished and if there are any
ILcdUndoableobjects to be redone.
-
canUndoImpl
public boolean canUndoImpl()Returns whether or not this composite undoable can be undone.- Overrides:
canUndoImplin classALcdUndoable- Returns:
- True if this composite undoables was finished and if there are any
ILcdUndoableobjects to be undone.
-
asListener
Returns anILcdUndoableListenerinstance that will add each receivedILcdUndoableto this composite implementation. Each call of this method will return the same listener instance. A typical use-case of this method is if you want to combine multiple undoables (from a single or multiple sources) into one composite undoable, allowing the user to undo/redo multiple operations in one go:ILcdUndoableSource firstSource = ...; ILcdUndoableSource secondSource = ...; TLcdCompositeUndoable undoable = new TLcdCompositeUndoable("Undo changes"); firstSource.addUndoableListener(undoable.asListener()); secondSource.addUndoableListener(undoable.asListener()); makeChanges(firstSource, secondSource); firstSource.removeUndoableListener(undoable.asListener()); secondSource.removeUndoableListener(undoable.asListener()); undoable.finish(); fireUndoableHappened(undoable);- Returns:
- an
ILcdUndoableListenerthat adds the undoables to this composite implementation - Since:
- 2017.0
-