public class IcyUndoManager extends javax.swing.undo.AbstractUndoableEdit implements javax.swing.event.UndoableEditListener
Constructor and Description |
---|
IcyUndoManager(java.lang.Object owner) |
IcyUndoManager(java.lang.Object owner,
int limit) |
Modifier and Type | Method and Description |
---|---|
void |
addEdit(AbstractIcyUndoableEdit anEdit)
Adds an
AbstractIcyUndoableEdit to this UndoManager , if it's
possible. |
boolean |
addEdit(javax.swing.undo.UndoableEdit anEdit) |
void |
addListener(IcyUndoManagerListener listener)
Add the specified listener to listeners list
|
boolean |
canRedo()
Returns true if edits may be redone.
|
boolean |
canUndo()
Returns true if edits may be undone.
|
void |
discardAllEdits()
Empties the undo manager sending each edit a
die message
in the process. |
void |
discardEdits(java.lang.Object source)
Discard edits from specified source by sending each edit a
die message
in the process. |
void |
discardFutureEdits()
Remove future edits (the ones to redo) from the undo manager sending each edit a
die message in the process. |
void |
discardFutureEdits(int keep)
Remove future edits (the ones to redo) from the undo manager sending each edit a
die message in the process. |
void |
discardOldEdits()
Remove old edits (the ones to undo) from the undo manager sending each edit a
die message in the process. |
void |
discardOldEdits(int keep)
Remove previous edits (the ones to undo) from the undo manager sending each edit a
die message
in the process. |
java.util.List<AbstractIcyUndoableEdit> |
getAllEdits()
Retrieve all edits in the UndoManager
|
AbstractIcyUndoableEdit |
getEdit(int index)
Get edit of specified index
|
int |
getEditsCount()
Get number of edit in UndoManager
|
int |
getFirstEditIndex(java.lang.Object source)
Get index of first edit from specified source
|
int |
getIndex(AbstractIcyUndoableEdit e)
Get the index in list of specified edit
|
int |
getLastEditIndex(java.lang.Object source)
Get index of last edit from specified source
|
int |
getLimit()
Returns the maximum number of edits this
UndoManager holds. |
IcyUndoManagerListener[] |
getListeners()
Get listeners list
|
int |
getNextAddIndex()
Return the next insert index.
|
java.lang.Object |
getOwner() |
java.lang.String |
getRedoPresentationName()
Returns a description of the redoable form of this edit.
|
AbstractIcyUndoableEdit |
getSignificantEdit(int index)
Get significant edit of specified index
|
int |
getSignificantEditsCount()
Get number of significant edit in UndoManager
|
int |
getSignificantEditsCountBefore(int index)
Get number of significant edit before the specified position in UndoManager
|
int |
getSignificantIndex(AbstractIcyUndoableEdit e)
Get the index in list of specified significant edit
|
java.lang.String |
getUndoPresentationName()
Returns a description of the undoable form of this edit.
|
void |
noMergeForNextEdit()
Prevent the last edit inserted in the UndoManager to be merged with the next inserted edit
(even if they are compatible)
|
void |
redo()
Redo the appropriate edits.
|
void |
removeListener(IcyUndoManagerListener listener)
Remove the specified listener from listeners list
|
void |
setLimit(int l)
Sets the maximum number of edits this
UndoManager holds. |
void |
undo()
Undoes the appropriate edits.
|
void |
undoableEditHappened(javax.swing.event.UndoableEditEvent e) |
void |
undoAll()
Undoes all changes.
|
void |
undoOrRedoTo(AbstractIcyUndoableEdit edit)
Undo or redo all changes until the specified edit.
|
public IcyUndoManager(java.lang.Object owner, int limit)
public IcyUndoManager(java.lang.Object owner)
public java.lang.Object getOwner()
public int getLimit()
UndoManager
holds. A value less than 0
indicates the number of edits is not limited.UndoManager
holdsaddEdit(javax.swing.undo.UndoableEdit)
,
setLimit(int)
public void discardAllEdits()
die
message
in the process.AbstractUndoableEdit.die()
public void discardFutureEdits(int keep)
die
message in the process.keep
- number of future edits to keep (1 means we keep only the next edit)AbstractUndoableEdit.die()
public void discardFutureEdits()
die
message in the process.AbstractUndoableEdit.die()
public void discardOldEdits(int keep)
die
message
in the process.keep
- number of previous edits to keep (1 mean we keep only the last edit)AbstractUndoableEdit.die()
public void discardOldEdits()
die
message in the process.AbstractUndoableEdit.die()
public void setLimit(int l)
UndoManager
holds. A value less than 0
indicates the number of edits is not limited. If edits need to be discarded
to shrink the limit, die
will be invoked on them in the reverse
order they were added. The default is 100.l
- the new limitjava.lang.RuntimeException
- if this UndoManager
is not in progress
(end
has been invoked)addEdit(javax.swing.undo.UndoableEdit)
,
getLimit()
public void undoAll() throws javax.swing.undo.CannotUndoException
javax.swing.undo.CannotUndoException
- if one of the edits throws CannotUndoException
public void undo() throws javax.swing.undo.CannotUndoException
undo
on all edits between the
index of the next edit and the last significant edit, updating
the index of the next edit appropriately.undo
in interface javax.swing.undo.UndoableEdit
undo
in class javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CannotUndoException
- if one of the edits throws CannotUndoException
or there are no edits
to be undonecanUndo()
,
editToBeUndone()
public boolean canUndo()
editToBeUndone
returns non-null
).canUndo
in interface javax.swing.undo.UndoableEdit
canUndo
in class javax.swing.undo.AbstractUndoableEdit
editToBeUndone()
public void redo() throws javax.swing.undo.CannotRedoException
redo
on
all edits between the index of the next edit and the next
significant edit, updating the index of the next edit appropriately.redo
in interface javax.swing.undo.UndoableEdit
redo
in class javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CannotRedoException
- if one of the edits throws CannotRedoException
or there are no edits
to be redoneCompoundEdit.end()
,
canRedo()
,
editToBeRedone()
public boolean canRedo()
end
has
been invoked, this returns the value from super. Otherwise,
this returns true if there are any edits to be redone
(editToBeRedone
returns non-null
).canRedo
in interface javax.swing.undo.UndoableEdit
canRedo
in class javax.swing.undo.AbstractUndoableEdit
CompoundEdit.canRedo()
,
editToBeRedone()
public void undoOrRedoTo(AbstractIcyUndoableEdit edit) throws javax.swing.undo.CannotRedoException, javax.swing.undo.CannotUndoException
javax.swing.undo.CannotRedoException
javax.swing.undo.CannotUndoException
public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
addEdit
in interface javax.swing.undo.UndoableEdit
addEdit
in class javax.swing.undo.AbstractUndoableEdit
public void addEdit(AbstractIcyUndoableEdit anEdit)
AbstractIcyUndoableEdit
to this UndoManager
, if it's
possible. This
removes all edits from the index of the next edit to the end of the edits
list.anEdit
- the edit to be addedCompoundEdit.addEdit(javax.swing.undo.UndoableEdit)
public void noMergeForNextEdit()
public java.lang.String getUndoPresentationName()
UIManager
property "AbstractUndoableEdit.undoText".getUndoPresentationName
in interface javax.swing.undo.UndoableEdit
getUndoPresentationName
in class javax.swing.undo.AbstractUndoableEdit
undo()
,
CompoundEdit.getUndoPresentationName()
public java.lang.String getRedoPresentationName()
UIManager
property "AbstractUndoableEdit.redoText".getRedoPresentationName
in interface javax.swing.undo.UndoableEdit
getRedoPresentationName
in class javax.swing.undo.AbstractUndoableEdit
redo()
,
CompoundEdit.getRedoPresentationName()
public void addListener(IcyUndoManagerListener listener)
public void removeListener(IcyUndoManagerListener listener)
public IcyUndoManagerListener[] getListeners()
public java.util.List<AbstractIcyUndoableEdit> getAllEdits()
public int getEditsCount()
public int getIndex(AbstractIcyUndoableEdit e)
public int getSignificantIndex(AbstractIcyUndoableEdit e)
public int getSignificantEditsCountBefore(int index)
public int getSignificantEditsCount()
public AbstractIcyUndoableEdit getEdit(int index)
public AbstractIcyUndoableEdit getSignificantEdit(int index)
public int getNextAddIndex()
public int getFirstEditIndex(java.lang.Object source)
public int getLastEditIndex(java.lang.Object source)
public void discardEdits(java.lang.Object source)
die
message
in the process.public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
undoableEditHappened
in interface javax.swing.event.UndoableEditListener