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 
Constructors
Constructor
Description
TLcdCompositeUndoable(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 Type
Method
Description
boolean
addUndoable(ILcdUndoable aUndoable)
Adds the given ILcdUndoable
to this composite undoable.
final ILcdUndoableListener
Returns an ILcdUndoableListener
instance that will add each received
ILcdUndoable
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 this ILcdUndoable
.
Takes the display name as defined in the constructor ALcdUndoable(String)
and formats
it with the appropriate format.
Takes the display name as defined in the constructor ALcdUndoable(String)
and formats
it with the appropriate format.
boolean
Returns false if this ILcdUndoable
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 all ILcdUndoable
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 added ILcdUndoable
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 
-
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 wrapped
ILcdUndoable
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 this ILcdUndoable
. It can for example be used for
logging purposes.
- Specified by:
getDisplayName
in interface ILcdUndoable
- Overrides:
getDisplayName
in class ALcdUndoable
-
getUndoDisplayName 
Description copied from class: ALcdUndoable
Takes the display name as defined in the constructor ALcdUndoable(String)
and formats
it with the appropriate format.
- Specified by:
getUndoDisplayName
in interface ILcdUndoable
- Overrides:
getUndoDisplayName
in class ALcdUndoable
- See Also:
-
-
getRedoDisplayName 
Description copied from class: ALcdUndoable
Takes the display name as defined in the constructor ALcdUndoable(String)
and formats
it with the appropriate format.
- Specified by:
getRedoDisplayName
in interface ILcdUndoable
- Overrides:
getRedoDisplayName
in class ALcdUndoable
- Returns:
- The redo display name
-
undoImpl 
Undoes all added ILcdUndoable
objects added to this composite in the reverse order
they were added. This means the ILcdUndoable
that was added last will be undone
first.
- Specified by:
undoImpl
in class ALcdUndoable
- Throws:
TLcdCannotUndoRedoException
-
redoImpl 
Redoes all ILcdUndoable
objects added to this composite in the order they were
added. This means the ILcdUndoable
that was added first will be redone first.
- Specified by:
redoImpl
in class ALcdUndoable
- Throws:
TLcdCannotUndoRedoException
-
addUndoable 
Adds the given ILcdUndoable
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 if finish()
has not yet been called.
- Specified by:
addUndoable
in interface ILcdUndoable
- Overrides:
addUndoable
in class ALcdUndoable
- Parameters:
aUndoable
- The undoable to add.
- Returns:
- Whether or not
aUndoable
was accepted by this ILcdUndoable
.
-
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
calls addUndoable(ILcdUndoable)
to provide multiple ILcdUndoable
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 by die()
when it is allowed to do so. The default implementation is an empty implementation.
- Overrides:
dieImpl
in class ALcdUndoable
-
isSignificant 
public boolean isSignificant()
Description copied from class: ALcdUndoable
Returns false if this ILcdUndoable
is insignificant--for example one that
maintains the user's selection, but does not change any model state. This status can be used by
an ILcdUndoableListener
(like TLcdUndoManager) when deciding which
ILcdUndoable
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 interface ILcdUndoable
- Overrides:
isSignificant
in class ALcdUndoable
- 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 class ALcdUndoable
- 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 class ALcdUndoable
- Returns:
- True if this composite undoables was finished and if there are any
ILcdUndoable
objects to be undone.
-
asListener 
Returns an ILcdUndoableListener
instance that will add each received
ILcdUndoable
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