How to invoke SelectAction and CenterAction while loading graph #569
-
I am using GLSP's vscode extension(https://github.com/eclipse-glsp/glsp-vscode-integration). For RequestModelAction from GLSP client, GLSP server will reply SetModelAction after creating/loading GGraph model. If we pass CenterAction/SelectAction(with node IDs) along with SetModelAction then it has no effect on the graph/diagram. My requirement is to highlight particular node in the graph after loading. If we create our own GGraph model then graph will be loaded at left top corner. So, I decided include Center Action along with SetModelAction as a reply for RequestModelAction. But CenterAction/SelectAction has no effect on the graph. Any alternate solution for these issues? When we reply SetModelAction to GLSP client, graph loading operation will be running. Any way to get feed back from server upon loading so that we can invoke CenterAction/SelectAction ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @sathya-1994, On the client side you can queue actions until the initial diagram model is loaded using the On the server side you can use the |
Beta Was this translation helpful? Give feedback.
Hi @sathya-1994,
in the workflow you described the
SetModelAction
has no effect because it is handled before the model updates is completed on the client side (i.e. it tries to select the node before its actually rendered in the diagram).To handle such use cases we have two different mechanisms in place:
On the client side you can queue actions until the initial diagram model is loaded using the
onceModelInitialized()
promise of the GLSPActionDispatcher. An example usage can e.g. found in the GLSPDiagramWidget class.On the server side you can use the
dispatchAfterNextUpdate
method of theActionDispatcher
to queue an action and it gets dispatched after the next model update has been comp…