Packagecom.yworks.support
Classpublic class CompoundUndoUnit
InheritanceCompoundUndoUnit Inheritance Object
Implements IUndoUnit

A generic support class that can manage IUndoUnit instances to support undoability.



Public Properties
 PropertyDefined By
  disposed : Boolean
[read-only] Determines whether this instance has been disposed.
CompoundUndoUnit
  length : int
[read-only] The number of units that are contained in this compound unit.
CompoundUndoUnit
  redoName : String
Returns the name of the redo unit.
CompoundUndoUnit
  undoName : String
The name of the undo unit.
CompoundUndoUnit
Public Methods
 MethodDefined By
  
CompoundUndoUnit(undoName:String = null, redoName:String = null)
Creates a new instance using the provided names.
CompoundUndoUnit
  
Adds a new IUndoUnit to the queue.
CompoundUndoUnit
  
addUnit(unit:IUndoUnit):Boolean
This implementation will always yield false.
CompoundUndoUnit
  
canRedo():Boolean
Determines whether this instance can currently redo its work.
CompoundUndoUnit
  
canUndo():Boolean
Determines whether this instance can currently undo its work.
CompoundUndoUnit
  
clear():void
Clears the internal collection of units.
CompoundUndoUnit
  
dispose():void
Disposes this unit and all of its contents.
CompoundUndoUnit
  
redo():void
Redoes the next IUndoUnit.
CompoundUndoUnit
  
removeUnit(unit:IUndoUnit):Boolean
Tries to remove a given unit from this compound unit.
CompoundUndoUnit
  
replaceUnit(unit:IUndoUnit):Boolean
This implementation will always yield false.
CompoundUndoUnit
  
toString():String
CompoundUndoUnit
  
undo():void
Undoes the next IUndoUnit.
CompoundUndoUnit
Property Detail
disposedproperty
disposed:Boolean  [read-only]

Determines whether this instance has been disposed.

An instance that has been disposed cannot used anymore.


Implementation
    public function get disposed():Boolean
lengthproperty 
length:int  [read-only]

The number of units that are contained in this compound unit.


Implementation
    public function get length():int
redoNameproperty 
redoName:String

Returns the name of the redo unit.

Depending on the implementation and context this might be a human readable representation of the redo action or a symbolic name that needs localization.


Implementation
    public function get redoName():String
    public function set redoName(value:String):void
undoNameproperty 
undoName:String

The name of the undo unit.

Depending on the implementation and context this might be a human readable representation of the undo action or a symbolic name that needs localization.


Implementation
    public function get undoName():String
    public function set undoName(value:String):void
Constructor Detail
CompoundUndoUnit()Constructor
public function CompoundUndoUnit(undoName:String = null, redoName:String = null)

Creates a new instance using the provided names.

Parameters
undoName:String (default = null) — The name for the undo operation.
 
redoName:String (default = null) — The name for the redo operation.
Method Detail
addToQueue()method
public function addToQueue(unit:IUndoUnit):void

Adds a new IUndoUnit to the queue.

Parameters

unit:IUndoUnit — The unit of work to add.

addUnit()method 
public function addUnit(unit:IUndoUnit):Boolean

This implementation will always yield false. Allows for collapsing multiple units into one.

Implementation should try to incorporate the change of unit into this and if successful return true. This method will be called by the UndoEngine to collapse multiple events into single events. Typically this unit has been placed onto an undo stack and unit should be placed on top of it. Both units have been done and might be undone in an upcoming action. If this method yields true, the provided unit will not be placed onto the stack but will be IDisposable.disposed.

Parameters

unit:IUndoUnit — The unit to incorporate that happened after this unit.

Returns
Boolean — Whether the state change of unit has been incorporated into this unit and unit can be disposed of.
canRedo()method 
public function canRedo():Boolean

Determines whether this instance can currently redo its work.

Returns
Boolean — Whether a call to redo will succeed.
canUndo()method 
public function canUndo():Boolean

Determines whether this instance can currently undo its work.

Returns
Boolean — Whether a call to undo will succeed.
clear()method 
public function clear():void

Clears the internal collection of units.

dispose()method 
public function dispose():void

Disposes this unit and all of its contents.

This unit cannot be used anymore after this has been invoked.

redo()method 
public function redo():void

Redoes the next IUndoUnit.


Throws
IllegalOperationError — If an undo uperation is already in progress.
removeUnit()method 
public function removeUnit(unit:IUndoUnit):Boolean

Tries to remove a given unit from this compound unit.

This method will throw an error if this unit has been undone or an undo or redo is in progress or this unit has already been disposed. This method will not automatically dispose removed units.

Parameters

unit:IUndoUnit — The unit to remove.

Returns
Booleantrue if the unit has been removed from this instance.
replaceUnit()method 
public function replaceUnit(unit:IUndoUnit):Boolean

This implementation will always yield false. Allows for collapsing multiple units into one.

Implementation should try to incorporate the change of unit into this and if successful return true. This method will be called by the UndoEngine to collapse multiple events into single events. Typically unit has already been placed onto an undo stack and this should be placed on top of it. Both units have been done and might be undone in an upcoming action. If this method yields true, this unit will replace the unit on the top of the stack and unit will be IDisposable.Disposed.

Parameters

unit:IUndoUnit — The unit to incorporate that happened before this unit.

Returns
Boolean — Whether the state change of unit has been incorporated into this unit and unit can be disposed of.
toString()method 
public function toString():String

Returns
String
undo()method 
public function undo():void

Undoes the next IUndoUnit.


Throws
IllegalOperationError — If an undo uperation is already in progress.