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
ILcdUndoable
s. 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
ConstructorDescriptionTLcdCompositeUndoable
(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 TypeMethodDescriptionboolean
addUndoable
(ILcdUndoable aUndoable) Adds the givenILcdUndoable
to this composite undoable.final ILcdUndoableListener
Returns anILcdUndoableListener
instance that will add each receivedILcdUndoable
to this composite implementation.boolean
Returns whether or not this composite undoable can be redone.boolean
Returns whether or not this composite undoable can be undone.void
dieImpl()
Override this method with the actual die behavior.void
finish()
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.boolean
Returns false if thisILcdUndoable
is insignificant--for example one that maintains the user's selection, but does not change any model state.boolean
Returns whether the display name of the wrapped undoable is used.protected void
redoImpl()
Redoes allILcdUndoable
objects added to this composite in the order they were added.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.protected void
undoImpl()
Undoes all addedILcdUndoable
objects 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
-true
if you want the display name of the wrappedILcdUndoable
to be used,false
otherwise.- 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:ILcdUndoable
Returns the display name of thisILcdUndoable
. It can for example be used for logging purposes.- Specified by:
getDisplayName
in interfaceILcdUndoable
- Overrides:
getDisplayName
in classALcdUndoable
-
getUndoDisplayName
Description copied from class:ALcdUndoable
Takes the display name as defined in the constructorALcdUndoable(String)
and formats it with the appropriate format.- Specified by:
getUndoDisplayName
in interfaceILcdUndoable
- Overrides:
getUndoDisplayName
in classALcdUndoable
- See Also:
-
getRedoDisplayName
Description copied from class:ALcdUndoable
Takes the display name as defined in the constructorALcdUndoable(String)
and formats it with the appropriate format.- Specified by:
getRedoDisplayName
in interfaceILcdUndoable
- Overrides:
getRedoDisplayName
in classALcdUndoable
- Returns:
- The redo display name
-
undoImpl
Undoes all addedILcdUndoable
objects added to this composite in the reverse order they were added. This means theILcdUndoable
that was added last will be undone first.- Specified by:
undoImpl
in classALcdUndoable
- Throws:
TLcdCannotUndoRedoException
-
redoImpl
Redoes allILcdUndoable
objects added to this composite in the order they were added. This means theILcdUndoable
that was added first will be redone first.- Specified by:
redoImpl
in classALcdUndoable
- Throws:
TLcdCannotUndoRedoException
-
addUndoable
Adds the givenILcdUndoable
to 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:
addUndoable
in interfaceILcdUndoable
- Overrides:
addUndoable
in classALcdUndoable
- Parameters:
aUndoable
- The undoable to add.- Returns:
- Whether or not
aUndoable
was 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
TLcdUndoManager
callsaddUndoable(ILcdUndoable)
to provide multipleILcdUndoable
instances 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:ALcdUndoable
Override 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:
dieImpl
in classALcdUndoable
-
isSignificant
public boolean isSignificant()Description copied from class:ALcdUndoable
Returns false if thisILcdUndoable
is 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 whichILcdUndoable
s 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:
isSignificant
in interfaceILcdUndoable
- Overrides:
isSignificant
in classALcdUndoable
- Returns:
- Whether or not this
ILcdUndoable
is significant.
-
canRedoImpl
public boolean canRedoImpl()Returns whether or not this composite undoable can be redone.- Overrides:
canRedoImpl
in classALcdUndoable
- Returns:
- True if this composite undoables was finished and if there are any
ILcdUndoable
objects to be redone.
-
canUndoImpl
public boolean canUndoImpl()Returns whether or not this composite undoable can be undone.- Overrides:
canUndoImpl
in classALcdUndoable
- Returns:
- True if this composite undoables was finished and if there are any
ILcdUndoable
objects to be undone.
-
asListener
Returns anILcdUndoableListener
instance that will add each receivedILcdUndoable
to 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
ILcdUndoableListener
that adds the undoables to this composite implementation - Since:
- 2017.0
-