Package com.myscript.iink
Class HistoryManager
java.lang.Object
com.myscript.iink.HistoryManager
- All Implemented Interfaces:
AutoCloseable
A HistoryManager allows managing changesets for undo/redo.
It is associated with an offscreen editor.
- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
protected void
finalize()
final int
Returns the number of changesets that can be redone.final int
Returns the number of changesets that can be undone (less than or equalgetUndoStackIndex()
).final @NotNull ChangesetOperation[]
getRedoChangesetFrom
(@NotNull String id) Returns the changeset corresponding to a redo from the given id.final @NotNull ChangesetOperation[]
getUndoChangesetTo
(@NotNull String id) Returns the changeset corresponding to an undo to the given id.final @NotNull String
getUndoRedoIdAt
(int stackIndex) Returns the id associated with an undo/redo stack index.final int
Returns the number of changesets performed on the part, since content part was opened.final boolean
isClosed()
Tells whether theclose()
method has been called.final void
redo()
Redo the last changeset reverted byundo
on part.final void
undo()
Undo the last changeset on part.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
-
isClosed
public final boolean isClosed()Tells whether theclose()
method has been called. Once an object is closed any method will throwIllegalStateException
.- Returns:
true
if this object is closed.
-
undo
public final void undo()Undo the last changeset on part.Note: this function will wait for pending gestures recognition.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when undo operations failed.
-
redo
public final void redo()Redo the last changeset reverted byundo
on part.Note: this function will wait for pending gestures recognition.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when redo operations failed.
-
getUndoRedoStackIndex
public final int getUndoRedoStackIndex()Returns the number of changesets performed on the part, since content part was opened.Note: this function will wait for pending gestures recognition. Note: the undo stack is partially purged from time to time to control memory consumption. The number of possible undo changesets at a given time is provided by
getPossibleUndoCount()
, while the total number of changesets since content part was opened is provided bygetUndoStackIndex()
.- Returns:
- the number of changesets performed on the part.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when editor is not associated with a part.
-
getPossibleUndoCount
public final int getPossibleUndoCount()Returns the number of changesets that can be undone (less than or equalgetUndoStackIndex()
).Note: this function will wait for pending gestures recognition.
- Returns:
- the number of changesets that can be undone.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when editor is not associated with a part.
-
getPossibleRedoCount
public final int getPossibleRedoCount()Returns the number of changesets that can be redone.Note: this function will wait for pending gestures recognition.
- Returns:
- the number of changesets that can be redone.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when editor is not associated with a part.
-
getUndoRedoIdAt
Returns the id associated with an undo/redo stack index. Valid stack index values range from (current stack index - possible undo count) to (current stack index + possible redo count - 1).Note: this function will wait for pending gestures recognition.
- Parameters:
stackIndex
- the index in the undo/redo stack.- Returns:
- the id associated with the undo/redo stack index.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when editor is not associated with a part.IllegalStateException
- whenstackIndex
is invalid.
-
getUndoChangesetTo
Returns the changeset corresponding to an undo to the given id.- Parameters:
id
- the id in the undo/redo stack.- Returns:
- the changeset if it exists, otherwise empty.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when editor is not associated with a part.
-
getRedoChangesetFrom
@NotNull public final @NotNull ChangesetOperation[] getRedoChangesetFrom(@NotNull @NotNull String id) Returns the changeset corresponding to a redo from the given id.- Parameters:
id
- the id in the undo/redo stack.- Returns:
- the changeset if it exists, otherwise empty.
- Throws:
IllegalStateException
- when this history manager is closed.IllegalStateException
- when associated editor has been destroyed.IllegalStateException
- when editor is not associated with a part.
-