Class UndoOperation<DATA>

java.lang.Object
icyllis.modernui.core.UndoOperation<DATA>
Type Parameters:
DATA -
All Implemented Interfaces:
Parcelable
Direct Known Subclasses:
Editor.EditOperation

public abstract class UndoOperation<DATA> extends Object implements Parcelable
A single undoable operation.
You must subclass this to implement the state and behavior for your operation.
Instances of this class are placed and managed in an UndoManager.
  • Constructor Details

    • UndoOperation

      public UndoOperation(UndoOwner owner)
      Create a new instance of the operation.
      Parameters:
      owner - Who owns the data being modified by this undo state; must be returned by UndoManager.getOwner.
    • UndoOperation

      protected UndoOperation(Parcel src, ClassLoader loader)
      Construct from a Parcel.
  • Method Details

    • getOwner

      public UndoOwner getOwner()
      Owning object as given to UndoOperation(UndoOwner).
    • getOwnerData

      public DATA getOwnerData()
    • matchOwner

      public boolean matchOwner(UndoOwner owner)
      Return true if this undo operation is a member of the given owner. The default implementation is owner == getOwner(). You can override this to provide more sophisticated dependencies between owners.
    • hasData

      public boolean hasData()
      Return true if this operation actually contains modification data. The default implementation always returns true. If you return false, the operation will be dropped when the final undo state is being built.
    • allowMerge

      public boolean allowMerge()
      Return true if this operation can be merged with a later operation. The default implementation always returns true.
    • commit

      public abstract void commit()
      Called when this undo state is being committed to the undo stack. The implementation should perform the initial edits and save any state that may be needed to undo them.
    • undo

      public abstract void undo()
      Called when this undo state is being popped off the undo stack (in to the temporary redo stack). The implementation should remove the original edits and thus restore the target object to its prior value.
    • redo

      public abstract void redo()
      Called when this undo state is being pushed back from the transient redo stack to the main undo stack. The implementation should re-apply the edits that were previously removed by undo().