Class HistoryManager

java.lang.Object
com.myscript.iink.HistoryManager
All Implemented Interfaces:
AutoCloseable

public class HistoryManager extends Object implements AutoCloseable
A HistoryManager allows managing changesets for undo/redo. It is associated with an offscreen editor.
Since:
3.0
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • isClosed

      public final boolean isClosed()
      Tells whether the close() method has been called. Once an object is closed any method will throw IllegalStateException.
      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 by undo 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 by getUndoStackIndex().

      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 equal getUndoStackIndex()).

      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

      @NotNull public final @NotNull String getUndoRedoIdAt(int stackIndex)
      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 - when stackIndex is invalid.
    • getUndoChangesetTo

      @NotNull public final @NotNull ChangesetOperation[] getUndoChangesetTo(@NotNull @NotNull String id)
      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.