-
I have a DiagramWidget which extends GLSPDiagramWidget (very similar or same to ecore-glsp EcoreDiagramWidget, code below). After the creation of the DiagramWidget I want to access the elements of the diagram as example a specific node. I've been looking quite a while now and can't find where the nodes labels and edges are stored.
Now I would expect that I can find all instances of LabeledNode or ClassNodeView (or both) for my diagram somewhere.
} original thread by Leo Knoll |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hi, the diagram widget does not store any SModel or sprotty-view specific elements. This widget is only resposible for rendering the SVG element that corresponds to your SModel. |
Beta Was this translation helpful? Give feedback.
-
If you want to access/manipulate specific elements of your SModel this is typically handled via action/command. In some corner cases, you can also use the `ModelSourceProvider' (e.g. https://github.com/eclipse-glsp/glsp-client/blob/master/packages/client/src/base/editor-context.ts#L39). However, this is discouraged and should only be used with care. If you elaborate a bit on what you want to achieve I can explain the intended approach here |
Beta Was this translation helpful? Give feedback.
-
[Leo Knoll] Thank you for the answer, my goal is to highlite elements in the model with colors. The colors shows differences to another model and will be added based on the id. This could be done by adding css classes to the element. |
Beta Was this translation helpful? Give feedback.
-
If you already can do this on the server-side I'd recommend to do that. In fact, the server and the client modify the SModel in the same fashion so even if you would add the css-classes on the client side you would run into the mentioned overwrite issues. These overwriting issues are most likely caused by misconfigured css rules. |
Beta Was this translation helpful? Give feedback.
-
I'd recommend to use rather strict rules with a narrow-scope e.g if you want to style nodes blue use |
Beta Was this translation helpful? Give feedback.
-
[Leo Knoll] thank you for the input and the tips, I will work on the implementation on the server side :) |
Beta Was this translation helpful? Give feedback.
If you want to access/manipulate specific elements of your SModel this is typically handled via action/command. In some corner cases, you can also use the `ModelSourceProvider' (e.g. https://github.com/eclipse-glsp/glsp-client/blob/master/packages/client/src/base/editor-context.ts#L39). However, this is discouraged and should only be used with care.
If you elaborate a bit on what you want to achieve I can explain the intended approach here