-
I'm tinkering with the coffee demo and I am replacing its ecore model with one that is somewhat similar, still modeling a process flow, just not of brewing coffee of course. In this new application there are dynamic (based on the current state of the underlying model) constraints on what tasks can be connected by an edge ('flow' in the underlying model), so I need to politely reject certain actions being attempted in GLSP. I'll be honest, I'm not skilled in TypeScript plus I am still struggling to get a high-level view of the front-end logic. From what I've seen so far looking at the code it appears that my best bet is to put some hooks in workflow-sprotty/direct-task-editing/direct-task-editor.ts and call back to the model server (to establish the current model state) and then decide whether to let the action through. Am I even close, or am I missing some fundamentals? I see that direct-task-editor function that calls @eclipse-glsp/client/RequestEditValidationAction but I have absolutely no idea what that really does (but would love to find out). original thread by GaryKopp |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As you write the static node / edge type hints won't help if the logic of whether something is allowed or not is dynamic. So for those cases there are three approaches to deal with that:
We have been discussing to add support for dynamic node / edge hints but I'm not sure when we will get to it. If you need it sooner, please feel free to open an issue for this matter and vote/contribute/sponsor this feature. Thanks! |
Beta Was this translation helpful? Give feedback.
-
[GaryKopp] Thanks Philip. I would never have figured that out on my own :-) |
Beta Was this translation helpful? Give feedback.
As you write the static node / edge type hints won't help if the logic of whether something is allowed or not is dynamic. So for those cases there are three approaches to deal with that:
Reject the operation by not changing the model in the operation handler. If an operation handler doesn't do anything, the model won't be changed and the model update that is sent to the client will reset the model state on the client to the state before the operation.
Perform the action and add an error marker by registering and implementing a validator (overwrite
bindModelValidator()
in the server module)Overwrite the client-side create create edge mouse tool (https://github.com/eclipse-glsp/glsp-…