java.lang.Object
   ↳ com.pdftron.pdf.tools.UndoRedoManager

Class Overview

This class is responsible for managing the undo/redo chain and importing/exporting meta-data from/to each state of the chain

if you wish to add a new action to be handled in UndoRedoManager, make sure you will make necessary changes to #isValidAction(Context, String) and isEditPageAction(Context, String)

Summary

Nested Classes
interface UndoRedoManager.UndoRedoStateChangeListener Listener that gets notfied when the undo/redo stack has changed  
Public Constructors
UndoRedoManager(ToolManager toolManager)
Class constructor
Public Methods
void addUndoRedoStateChangeListener(UndoRedoManager.UndoRedoStateChangeListener listener)
Ads the undo redo state change listener.
void annotationsCouldNotBeAdded(String errorMessage)
The overloaded implementation of annotationsCouldNotBeAdded(String).
boolean canRedo()
boolean canUndo()
void clearUndoRedoStateChangeListener()
void destroy()
Cleans up resources.
JSONObject getAnnotSnapshot(Annot annot, int page)
String getNextRedoAction()
Returns the information attached to the next redo action
String getNextUndoAction()
Returns the information attached to the next undo action
static int getPageFrom(String info)
Returns the page number on which the page moved from.
static List<Integer> getPageList(String info)
Returns a list of page numbers that are involved in the given attached information.
static int getPageTo(String info)
Returns the page number on which the page moved to.
PDFViewCtrl getPdfViewCtrl()
static boolean isAddAnnotationAction(Context context, String info)
Checks if the information attached to an undo is related to adding annotations.
static boolean isAddPagesAction(Context context, String info)
Checks if the information attached to an undo is related to adding pages.
static boolean isDeletePagesAction(Context context, String info)
Checks if the information attached to an undo is related to deleting pages.
static boolean isEditContentAction(Context context, String info)
Checks if the information attached to an undo is related to editing pdf content.
static boolean isEditPageAction(Context context, String info)
Checks if the information attached to an undo is related to editing (adding, deleting, rotating, moving) pages.
static boolean isEditPageLabelsAction(Context context, String info)
Checks if the information attached to an undo is related to editing page labels.
static boolean isModifyAnnotationAction(Context context, String info)
Check if the information attached to an undo is related to modifying annotations
static boolean isMovePageAction(Context context, String info)
Checks if the information attached to an undo is related to moving a page.
static boolean isMovePagesAction(Context context, String info)
Checks if the information attached to an undo is related to moving multiple pages.
boolean isNextRedoEditPageAction()
Checks if the next redo action is an edit to page(s).
boolean isNextUndoEditPageAction()
Checks if the next undo action is an edit to page(s).
static boolean isRemoveAnnotationAction(Context context, String info)
Check if the information attached to an undo is related to removing annotations
static boolean isRotatePagesAction(Context context, String info)
Checks if the information attached to an undo is related to rotating pages.
static void jumpToUndoRedo(PDFViewCtrl pdfViewCtrl, String info, boolean isUndo)
Call this when PDFViewCtrl should be updated after undo/redo and jumped to the last modification.
void notifyUndoRedoStateChange()
void onAllAnnotationsRemoved()
This method should be called whenever all annotations in the document are removed.
void onAnnotationAction()
This method should be called whenever an action applies to an annotation.
void onAnnotationsAdded(Map<Annot, Integer> annots)
This method should be called whenever new annotations are added to the document.
void onAnnotationsModified(Map<Annot, Integer> annots, Bundle extra)
This method should be called whenever annotations in the document are modified.
void onAnnotationsPreModify(Map<Annot, Integer> annots)
This method should be called before modifying annotations in the document.
void onAnnotationsPreRemove(Map<Annot, Integer> annots)
This method should be called before removing annotations.
void onAnnotationsRemoved(Map<Annot, Integer> annots)
This method should be called whenever annotations are removed from the document.
void onAnnotationsRemovedOnPage(int pageNum)
This method should be called whenever all annotations in the page are removed.
void onBookmarkModified(List<UserBookmarkItem> bookmarkItems)
This method should be called whenever the bookmark is modified.
void onOutlineChanged()
void onPageLabelsChanged()
Called when page labels have been changed
void onPageMoved(int from, int to)
This method should be called whenever a page is repositioned.
void onPagesAdded(List<Integer> pageList)
This method should be called whenever new pages are added.
void onPagesCropped()
This method should be called whenever the pages are cropped.
void onPagesDeleted(List<Integer> pageList)
This method should be called whenever pages are deleted.
void onPagesMoved(List<Integer> pagesMoved, int to, int currentPage)
Called when pages have been moved.
void onPagesRotated(List<Integer> pageList)
This method should be called whenever pages are rotated.
void onPdfTextChanged()
void onRedaction(JSONObject jsonObj)
String redo()
Redo the last undo.
String redo(int locationId, boolean sendEvent)
Redo the last undo.
void removeUndoRedoStateChangeListener(UndoRedoManager.UndoRedoStateChangeListener listener)
Removes the undo redo state change listener.
void sendConsecutiveUndoRedoEvent()
static void setDebug(boolean debug)
void setEditToolbarImpl(EditToolbarImpl editToolbarImpl)
Sets the EditToolbarImpl to use for undo/redo ink strokes
void takeUndoSnapshotForSafety()
This should be called before saving to remove any potential unsafe undo snapshot
String undo()
Undo the last modification.
String undo(int locationId, boolean sendEvent)
Undo the last undo.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pdftron.pdf.tools.ToolManager.AnnotationModificationListener
From interface com.pdftron.pdf.tools.ToolManager.PdfDocModificationListener
From interface com.pdftron.pdf.tools.ToolManager.PdfOutlineModificationListener
From interface com.pdftron.pdf.tools.ToolManager.PdfTextModificationListener

Public Constructors

public UndoRedoManager (ToolManager toolManager)

Class constructor

Parameters
toolManager The ToolManager

Public Methods

public void addUndoRedoStateChangeListener (UndoRedoManager.UndoRedoStateChangeListener listener)

Ads the undo redo state change listener.

Parameters
listener to add

public void annotationsCouldNotBeAdded (String errorMessage)

The overloaded implementation of annotationsCouldNotBeAdded(String).

Parameters
errorMessage The error message

public boolean canRedo ()

Returns
  • True if there is any action to redo in the stack of undo/redo

public boolean canUndo ()

Returns
  • True if there is any action to undo in the stack of undo/redo

public void clearUndoRedoStateChangeListener ()

public void destroy ()

Cleans up resources.

public JSONObject getAnnotSnapshot (Annot annot, int page)

public String getNextRedoAction ()

Returns the information attached to the next redo action

Returns
  • The information attached to the next redo action

public String getNextUndoAction ()

Returns the information attached to the next undo action

Returns
  • The information attached to the next undo action

public static int getPageFrom (String info)

Returns the page number on which the page moved from.

Index starts from 1.

Parameters
info The information attached to an undo
Returns
  • The page number

public static List<Integer> getPageList (String info)

Returns a list of page numbers that are involved in the given attached information.

Index starts from 1.

Parameters
info The information attached to an undo
Returns
  • A list of pages

public static int getPageTo (String info)

Returns the page number on which the page moved to.

Index starts from 1.

Parameters
info The information attached to an undo
Returns
  • The page number

public PDFViewCtrl getPdfViewCtrl ()

Returns
  • The PDFViewCtrl

public static boolean isAddAnnotationAction (Context context, String info)

Checks if the information attached to an undo is related to adding annotations.

Returns
  • True if the information attached to an undo is related to adding annotations; False otherwise

public static boolean isAddPagesAction (Context context, String info)

Checks if the information attached to an undo is related to adding pages.

Returns
  • True if the information attached to an undo is related to adding pages; False otherwise

public static boolean isDeletePagesAction (Context context, String info)

Checks if the information attached to an undo is related to deleting pages.

Returns
  • True if the information attached to an undo is related to deleting pages; False otherwise

public static boolean isEditContentAction (Context context, String info)

Checks if the information attached to an undo is related to editing pdf content.

Returns
  • True if the information attached to an undo is related to editing content; False otherwise

public static boolean isEditPageAction (Context context, String info)

Checks if the information attached to an undo is related to editing (adding, deleting, rotating, moving) pages.

Returns
  • True if the information attached to an undo is related to editing pages; False otherwise

public static boolean isEditPageLabelsAction (Context context, String info)

Checks if the information attached to an undo is related to editing page labels.

Returns
  • True if the information attached to an undo is related to editing page labels; False otherwise

public static boolean isModifyAnnotationAction (Context context, String info)

Check if the information attached to an undo is related to modifying annotations

Returns
  • True if the information attached to an undo is related to modifying annotations; False otherwise

public static boolean isMovePageAction (Context context, String info)

Checks if the information attached to an undo is related to moving a page.

Returns
  • True if the information attached to an undo is related to moving a page; False otherwise

public static boolean isMovePagesAction (Context context, String info)

Checks if the information attached to an undo is related to moving multiple pages.

Returns
  • True if the information attached to an undo is related to moving pages; False otherwise

public boolean isNextRedoEditPageAction ()

Checks if the next redo action is an edit to page(s).

Returns
  • True if the next redo action is an edit to page(s); False otherwise

public boolean isNextUndoEditPageAction ()

Checks if the next undo action is an edit to page(s).

Returns
  • True if the next undo action is an edit to page(s); False otherwise

public static boolean isRemoveAnnotationAction (Context context, String info)

Check if the information attached to an undo is related to removing annotations

Returns
  • True if the information attached to an undo is related to removing annotations; False otherwise

public static boolean isRotatePagesAction (Context context, String info)

Checks if the information attached to an undo is related to rotating pages.

Returns
  • True if the information attached to an undo is related to rotating pages; False otherwise

public static void jumpToUndoRedo (PDFViewCtrl pdfViewCtrl, String info, boolean isUndo)

Call this when PDFViewCtrl should be updated after undo/redo and jumped to the last modification. The transition is shown using an animation.

Parameters
pdfViewCtrl The PDFViewCtrl
info The attached information to undo
isUndo Whether the action is undo (true) or redo (false)

public void notifyUndoRedoStateChange ()

public void onAllAnnotationsRemoved ()

This method should be called whenever all annotations in the document are removed. Preferably call this only from raiseAllAnnotationsRemovedEvent()

public void onAnnotationAction ()

This method should be called whenever an action applies to an annotation. Preferably call this only from raiseAnnotationActionEvent()

public void onAnnotationsAdded (Map<Annot, Integer> annots)

This method should be called whenever new annotations are added to the document. Preferably call this only from raiseAnnotationsAddedEvent(Map)

Parameters
annots The annotation that are added

public void onAnnotationsModified (Map<Annot, Integer> annots, Bundle extra)

This method should be called whenever annotations in the document are modified. Preferably call this only from raiseAnnotationsModifiedEvent(Map, Bundle)

Parameters
annots The annotations that are modified

public void onAnnotationsPreModify (Map<Annot, Integer> annots)

This method should be called before modifying annotations in the document. This will let undo/redo operation know the region of annotation before and after modification (for example, it can be used to animate between changes) Preferably call this only from raiseAnnotationsPreModifyEvent(Map)

Parameters
annots The annotations that are going to be modified

public void onAnnotationsPreRemove (Map<Annot, Integer> annots)

This method should be called before removing annotations. Preferably call this only from raiseAnnotationsPreRemoveEvent(Map)

Parameters
annots The annotations that are going to be removed

public void onAnnotationsRemoved (Map<Annot, Integer> annots)

This method should be called whenever annotations are removed from the document. Preferably call this only from raiseAnnotationsRemovedEvent(Map)

Parameters
annots The annotation that are removed

public void onAnnotationsRemovedOnPage (int pageNum)

This method should be called whenever all annotations in the page are removed. Preferably call this only from raiseAnnotationsRemovedEvent(int)

Parameters
pageNum The page number where the annotations are on

public void onBookmarkModified (List<UserBookmarkItem> bookmarkItems)

This method should be called whenever the bookmark is modified. Preferably call this only from raiseBookmarkModified(List)

Parameters
bookmarkItems the new bookmarks after modification

public void onOutlineChanged ()

public void onPageLabelsChanged ()

Called when page labels have been changed

public void onPageMoved (int from, int to)

This method should be called whenever a page is repositioned.

Parameters
from The position on which the page moved from
to The position on which the page moved to

public void onPagesAdded (List<Integer> pageList)

This method should be called whenever new pages are added. Preferably call this only from raisePagesAdded(List)

Parameters
pageList The list of added pages

public void onPagesCropped ()

This method should be called whenever the pages are cropped. Preferably call this only from raisePagesCropped()

public void onPagesDeleted (List<Integer> pageList)

This method should be called whenever pages are deleted. Preferably call this only from raisePagesDeleted(List)

Parameters
pageList The list of deleted pages

public void onPagesMoved (List<Integer> pagesMoved, int to, int currentPage)

Called when pages have been moved.

Parameters
pagesMoved The page numbers which the pages moved from
to The page number on which the page moved to
currentPage The current page the viewer is on

public void onPagesRotated (List<Integer> pageList)

This method should be called whenever pages are rotated. Preferably call this only from raisePagesRotated(List)

Parameters
pageList The list of rotated pages

public void onPdfTextChanged ()

public void onRedaction (JSONObject jsonObj)

public String redo ()

Redo the last undo.

Returns
  • The information attached to the last undo

public String redo (int locationId, boolean sendEvent)

Redo the last undo.

Parameters
locationId The location ID of where this is called from. It will be used in Analytics Handler.
sendEvent Whether it sends analytics event
Returns
  • The information attached to the last undo

public void removeUndoRedoStateChangeListener (UndoRedoManager.UndoRedoStateChangeListener listener)

Removes the undo redo state change listener.

Parameters
listener to remove

public void sendConsecutiveUndoRedoEvent ()

public static void setDebug (boolean debug)

public void setEditToolbarImpl (EditToolbarImpl editToolbarImpl)

Sets the EditToolbarImpl to use for undo/redo ink strokes

public void takeUndoSnapshotForSafety ()

This should be called before saving to remove any potential unsafe undo snapshot

public String undo ()

Undo the last modification.

Returns
  • The information attached to the last modification

public String undo (int locationId, boolean sendEvent)

Undo the last undo.

Parameters
locationId The location ID of where this is called from. It will be used in Analytics Handler.
sendEvent Whether it sends analytics event
Returns
  • The information attached to the last modification