Packagecom.yworks.support
Classpublic class MementoUndoUnit
InheritanceMementoUndoUnit Inheritance AbstractUndoUnit Inheritance Object

A simple IUndoUnit implementation that uses a IMementoSupport to track, undo, and redo state changes on a given subject.



Public Properties
 PropertyDefined By
 InheritedredoName : String
[read-only] Returns the name of the redo unit.
AbstractUndoUnit
 InheritedundoName : String
[read-only] The name of the undo unit.
AbstractUndoUnit
Public Methods
 MethodDefined By
  
MementoUndoUnit(support:IMementoSupport, subject:Object, oldState:Object, undoName:String = null, redoName:String = null)
Initializes this unit using a given support instance, the subject and the state that to which this unit should undo initially.
MementoUndoUnit
  
addUnit(unit:IUndoUnit):Boolean
[override] Merges this unit if unit is of this type and they describe the same subject.
MementoUndoUnit
 Inherited
canRedo():Boolean
Determines whether this instance can currently redo its work.
AbstractUndoUnit
 Inherited
canUndo():Boolean
Determines whether this instance can currently undo its work.
AbstractUndoUnit
 Inherited
dispose():void
Frees all used resources.
AbstractUndoUnit
 Inherited
redo():void
Redoes the change that is represented by this unit.
AbstractUndoUnit
  
replaceUnit(unit:IUndoUnit):Boolean
[override] Replaces this unit if unit is of this type and they describe the same subject.
MementoUndoUnit
  
toString():String
MementoUndoUnit
 Inherited
undo():void
Undoes the change that is represented by this unit.
AbstractUndoUnit
Protected Methods
 MethodDefined By
  
redoImpl():void
[override] Stores the current state and applies the state saved in undoImpl.
MementoUndoUnit
  
undoImpl():void
[override] Reads the current state and applies the old one.
MementoUndoUnit
Constructor Detail
MementoUndoUnit()Constructor
public function MementoUndoUnit(support:IMementoSupport, subject:Object, oldState:Object, undoName:String = null, redoName:String = null)

Initializes this unit using a given support instance, the subject and the state that to which this unit should undo initially.

Parameters
support:IMementoSupport — The support that will be used to update and apply the state.
 
subject:Object — The instance that will be modified.
 
oldState:Object — The memento state object to which the subject will be rolled back upon the first undo operation.
 
undoName:String (default = null) — The name of the undo action.
 
redoName:String (default = null) — The name of the redo action.
Method Detail
addUnit()method
override public function addUnit(unit:IUndoUnit):Boolean

Merges this unit if unit is of this type and they describe the same subject.

Parameters

unit:IUndoUnit — The unit to add.

Returns
Booleantrue if the unit was added.
redoImpl()method 
override protected function redoImpl():void

Stores the current state and applies the state saved in undoImpl.

replaceUnit()method 
override public function replaceUnit(unit:IUndoUnit):Boolean

Replaces this unit if unit is of this type and they describe the same subject.

Parameters

unit:IUndoUnit — The unit to replace.

Returns
Booleantrue if the unit was replaced.
toString()method 
public function toString():String

Returns
String
undoImpl()method 
override protected function undoImpl():void

Reads the current state and applies the old one.