Package icyllis.modernui.core
Class UndoOperation<DATA>
java.lang.Object
icyllis.modernui.core.UndoOperation<DATA>
- Type Parameters:
DATA
-
- All Implemented Interfaces:
Parcelable
- Direct Known Subclasses:
Editor.EditOperation
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
You must subclass this to implement the state and behavior for your operation.
Instances of this class are placed and managed in an
UndoManager
.-
Nested Class Summary
Nested classes/interfaces inherited from interface icyllis.modernui.util.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>, Parcelable.WriteFlags
-
Constructor Summary
ModifierConstructorDescriptionUndoOperation
(UndoOwner owner) Create a new instance of the operation.protected
UndoOperation
(Parcel src, ClassLoader loader) Construct from a Parcel. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if this operation can be merged with a later operation.abstract void
commit()
Called when this undo state is being committed to the undo stack.getOwner()
Owning object as given toUndoOperation(UndoOwner)
.Synonym forgetOwner()
.UndoOwner.getData()
.boolean
hasData()
Return true if this operation actually contains modification data.boolean
matchOwner
(UndoOwner owner) Return true if this undo operation is a member of the given owner.abstract void
redo()
Called when this undo state is being pushed back from the transient redo stack to the main undo stack.abstract void
undo()
Called when this undo state is being popped off the undo stack (in to the temporary redo stack).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface icyllis.modernui.util.Parcelable
writeToParcel
-
Constructor Details
-
UndoOperation
Create a new instance of the operation.- Parameters:
owner
- Who owns the data being modified by this undo state; must be returned byUndoManager.getOwner
.
-
UndoOperation
Construct from a Parcel.
-
-
Method Details
-
getOwner
Owning object as given toUndoOperation(UndoOwner)
. -
getOwnerData
Synonym forgetOwner()
.UndoOwner.getData()
. -
matchOwner
Return true if this undo operation is a member of the given owner. The default implementation isowner == 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 byundo()
.
-