Packageorg.robotlegs.utilities.undoablecommand
Classpublic class CommandHistory
InheritanceCommandHistory Inheritance Object

Provides an interface to manage undo/redo history and fires events on the eventDispatcher when history events occur.



Public Properties
 PropertyDefined By
  canStepBackward : Boolean
[read-only] True if there's a command to undo.
CommandHistory
  canStepForward : Boolean
[read-only] True if there's a command to redo.
CommandHistory
  currentCommand : IUndoableCommand
[read-only] Gets the command at the top of the history stack.
CommandHistory
  currentPosition : uint
Pointer to the current command in the history stack.
CommandHistory
  eventDispatcher : IEventDispatcher
Supplied event bus to fire events upon.
CommandHistory
  numberOfHistoryItems : uint
[read-only] Total number of items in history, irrespective of their undone/redone state.
CommandHistory
Public Methods
 MethodDefined By
  
CommandHistory
  
fastForward(numTimes:uint = 0):uint
Redo all or some number of commands.
CommandHistory
  
push(command:IUndoableCommand):uint
Push a new command into the current position on the history stack and execute it.
CommandHistory
  
rewind(numTimes:uint = 0):uint
Undo all or some number of commands.
CommandHistory
  
Undo the previous command on the history stack and set the currentCommand to the previous command.
CommandHistory
  
Redo/execute the next command on the history stack.
CommandHistory
Property Detail
canStepBackwardproperty
canStepBackward:Boolean  [read-only]

True if there's a command to undo.


Implementation
    public function get canStepBackward():Boolean
canStepForwardproperty 
canStepForward:Boolean  [read-only]

True if there's a command to redo.


Implementation
    public function get canStepForward():Boolean
currentCommandproperty 
currentCommand:IUndoableCommand  [read-only]

Gets the command at the top of the history stack. This command will have already been executed.


Implementation
    public function get currentCommand():IUndoableCommand

See also

currentPosition
numberOfHistoryItems
currentPositionproperty 
public var currentPosition:uint

Pointer to the current command in the history stack. First command starts at index 1. If this is 0, we are pointing to no command (null) at the start of the stack

eventDispatcherproperty 
public var eventDispatcher:IEventDispatcher

Supplied event bus to fire events upon.

numberOfHistoryItemsproperty 
numberOfHistoryItems:uint  [read-only]

Total number of items in history, irrespective of their undone/redone state.


Implementation
    public function get numberOfHistoryItems():uint
Constructor Detail
CommandHistory()Constructor
public function CommandHistory()



Method Detail
fastForward()method
public function fastForward(numTimes:uint = 0):uint

Redo all or some number of commands.

Parameters

numTimes:uint (default = 0) — number of positions to move forward. The default, 0, fast forwards to the last item in the history (most recent).

Returns
uint — position in history stack after the fastForward operation completes
push()method 
public function push(command:IUndoableCommand):uint

Push a new command into the current position on the history stack and execute it. If there are commands further forward in the history stack, those commands are removed and this command becomes the new top of the command stack.

Parameters

command:IUndoableCommand

Returns
uint — position in history stack after this operation
rewind()method 
public function rewind(numTimes:uint = 0):uint

Undo all or some number of commands.

Parameters

numTimes:uint (default = 0) — number of positions to move backward. The default, 0, rewinds to the start of the history (undoes all commands)

Returns
uint — position in history stack after the rewind operation completes
stepBackward()method 
public function stepBackward():uint

Undo the previous command on the history stack and set the currentCommand to the previous command.

Returns
uint — position in history stack after this operation
stepForward()method 
public function stepForward():uint

Redo/execute the next command on the history stack.

Returns
uint — position in history stack after this operation