Class. Command Stack
protected
modelFactory:IModelFactory
Defined in: packages/sprotty/src/base/commands/command-stack.ts:106
protected
optional
modelViewer:IViewer
Defined in: packages/sprotty/src/base/commands/command-stack.ts:114
protected
offStack:ICommand
[] =[]
Defined in: packages/sprotty/src/base/commands/command-stack.ts:138
System commands should be transparent to the user in undo/redo operations. When a system command is executed when the redo stack is not empty, it is pushed to offStack instead.
On redo, all commands form this stack are undone such that the redo operation gets the exact same model as when it was executed first.
On undo, all commands form this stack are undone as well as system ommands should be transparent to the user.
protected
options:CommandStackOptions
Defined in: packages/sprotty/src/base/commands/command-stack.ts:110
protected
optional
popupModelViewer:IViewer
Defined in: packages/sprotty/src/base/commands/command-stack.ts:116
protected
redoStack:ICommand
[] =[]
Defined in: packages/sprotty/src/base/commands/command-stack.ts:119
protected
stoppableCommands:Map
<string
,IStoppableCommand
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:124
Map which holds the last stoppable command for certain action kinds.
protected
syncer:AnimationFrameSyncer
Defined in: packages/sprotty/src/base/commands/command-stack.ts:109
protected
undoStack:ICommand
[] =[]
Defined in: packages/sprotty/src/base/commands/command-stack.ts:118
protected
viewerProvider:IViewerProvider
Defined in: packages/sprotty/src/base/commands/command-stack.ts:107
get
protected
currentModel():Promise
<SModelRootImpl
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:158
Promise
<SModelRootImpl
>
protected
createContext(currentModel
):CommandExecutionContext
Defined in: packages/sprotty/src/base/commands/command-stack.ts:427
Assembles the context object that is passed to the commands execution method.
execute(
command
):Promise
<SModelRootImpl
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:174
Executes the given command on the current model and returns a Promise for the new result.
Unless it is a special command, it is pushed to the undo stack such that it can be rolled back later and the redo stack is cleared.
Promise
<SModelRootImpl
>
executeAll(
commands
):Promise
<SModelRootImpl
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:164
Executes all of the given commands. As opposed to calling execute() multiple times, the Viewer is only updated once after the last command has been executed.
ICommand
[]
Promise
<SModelRootImpl
>
protected
handleCommand(command
,operation
,beforeResolve
):void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:215
Chains the current promise with another Promise that performs the given operation on the given command.
(context
) => CommandReturn
(command
, context
) => void
a function that is called directly before resolving the Promise to return the new model. Usually puts the command on the appropriate stack.
void
protected
initialize():void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:141
void
protected
isBlockUndo(command
):boolean
Defined in: packages/sprotty/src/base/commands/command-stack.ts:446
boolean
protected
isPushToOffStack(command
):boolean
Defined in: packages/sprotty/src/base/commands/command-stack.ts:438
boolean
protected
isPushToUndoStack(command
):boolean
Defined in: packages/sprotty/src/base/commands/command-stack.ts:442
boolean
protected
mergeOrPush(command
,context
):void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:348
Handling of commands after their execution.
Hidden commands are not pushed to any stack.
System commands are pushed to the offStack
when the redo
stack is not empty, allowing to undo the before a redo to keep the chain
of commands consistent.
Mergable commands are merged if possible.
void
protected
pushToUndoStack(command
):void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:274
void
redo():
Promise
<SModelRootImpl
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:194
Takes the topmost command from the redo stack, redoes its changes and pushes it ot the undo stack. Returns a Promise for the changed model.
Promise
<SModelRootImpl
>
protected
redoFollowingSystemCommands():void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:412
System commands should be transparent to the user, so this method
is called from redo()
to re-execute all system commands
at the top of the redoStack.
void
protected
thenUpdate():Promise
<SModelRootImpl
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:284
Notifies the Viewer to render the new model and/or the new hidden model and returns a Promise for the new model.
Promise
<SModelRootImpl
>
undo():
Promise
<SModelRootImpl
>
Defined in: packages/sprotty/src/base/commands/command-stack.ts:180
Takes the topmost command from the undo stack, undoes its changes and pushes it ot the redo stack. Returns a Promise for the changed model.
Promise
<SModelRootImpl
>
protected
undoOffStackSystemCommands():void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:381
Reverts all system commands on the offStack.
void
protected
undoPreceedingSystemCommands():void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:395
System commands should be transparent to the user, so this method
is called from undo()
to revert all system commands
at the top of the undoStack.
void
update(
model
,cause?
):void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:310
Notify the ModelViewer
that the model has changed.
Action
void
updateHidden(
model
,cause?
):void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:320
Notify the HiddenModelViewer
that the hidden model has changed.
Action
void
updatePopup(
model
,cause?
):void
Defined in: packages/sprotty/src/base/commands/command-stack.ts:330
Notify the PopupModelViewer
that the popup model has changed.
Action
void