How do I integrate "Theia+DSL" with Sprotty for visualization? #9625
Replies: 23 comments
-
The Yang extension is a complete example using this stack: |
Beta Was this translation helpful? Give feedback.
-
sure thing, I will analyze that. Thank you. Please keep it open. |
Beta Was this translation helpful? Give feedback.
-
Hi All, I went through the above example and some conference videos of sprotty framework. I understood the basic architecture. But not getting how the Diagram server(DSL) is connecting to Diagram generator(sprotty client (Theia Widget)). I would really appreciate if someone can give me a guideline/ share some pointers. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I hope you're using Xtext for your LSP :-) We enhance the LSP with a few sprotty related methods (client, server), in order to connect the sprotty enhanced LS to the the sprotty enhanced client. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hi there, PS: I understand the examples, but what if I have to leverage these examples to build and understand sprotty + xtext(DSL) project of my own, which I am actually working upon. The package manager commands/ installations are for running the samples, but where can I find some information which states how it's being developed (Integration). Do I just have to put my LSP in some place or I can create a whole thing. I apologize if it's the repetitive question, but I am trying to understand how things are working. Question 2: If I want to create a new diagram in sprotty, which visualizes as an actor, is that possible? I am working on my thesis, which involves sprotty+theia+xtext as a base(root) and using these I have to create UML Goal / Scenario models. And in the end, put collaboration in place. I will thoroughly go through the entire sample and will see if it helps. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Sorry that the entire story is still a bit rough around the edges. I'd suggest you start with a plain, non-sprotty Xtext LS and integrate it with Theia, then add sprotty support in a second step.
The DSL has to be registered as a language contribution to the frontend of the theia extension
For development, I usually start the backend in debug mode from Eclipse using this main class
|
Beta Was this translation helpful? Give feedback.
-
Hi there, thank you very much for putting your time and sharing details! workdone: I have completed the (Xtext)DSL integration with Theia part, I am working on the second step, in which sprotty comes into frame. PS: I was just executing the yangster example, however it throws URI issue during yarn installation. Below: I tried few things with Request_promise but it did not work. Thank you! |
Beta Was this translation helpful? Give feedback.
-
This is likely because you haven't checked out the Git submodules. git clone --recursive https://github.com/theia-ide/yangster.git to clone the yangster repo. Background: As this is the reference project of integrating Theia and sprotty, we often need to apply changes to a couple of repos for a single issue. We use Git submodules to check out all relevant repos into the yangser root directory and then build them all together. |
Beta Was this translation helpful? Give feedback.
-
Hi there, Thank you again! Learning: I got a very good understanding of the sprotty part. And I have tried adding my own symbols and played around with existing example in yangster project. When it comes to "Server" part:
I am sharing the Xtext LSP generation link which I had followed. Appreciate your time and attention! |
Beta Was this translation helpful? Give feedback.
-
It started picking my LSP :) |
Beta Was this translation helpful? Give feedback.
-
Good to hear you're making progress.
|
Beta Was this translation helpful? Give feedback.
-
Hi there, thank you very much for sharing information. I had tried making changes in below files, namely: I tried to follow yang example for converting domain model to SModel. But it does not work somehow. May I please know, am I following the right set of files or am I missing any implementation here for connectivity.? Thank you for putting your time! |
Beta Was this translation helpful? Give feedback.
-
The YangGenerator is very complex as it deals with a pretty complicated language. What you have to know is that it generates an SModel (Sprotty) from the AST model (Xtext). In a client -server setting, things can go wrong in multiple places, so I'd start debugging and inspecting the logs. On the client side, it's usually good to put a breakpoint in diagram-server.ts (Chrome debugger) On the server, |
Beta Was this translation helpful? Give feedback.
-
Hi there, greetings :) Yea given example (yangDiagramGenerator.xtend)'s visualization is working perfectly fine. Thank you very much for guiding me through the process. |
Beta Was this translation helpful? Give feedback.
-
Hi there, good morning/evening! I am successfully able to generate the visualization of a module form my xtext grammar module. 👍 I have a question: is it possible if we can generate diagram view of individual resources. Like if the user wants to see the visualization of each resource individually instead of all at once, in a similar pattern as we get outline generated of our model. And if the user wants to visualize any of the resources can just generate a diagram. For Example, Screen Shot attached, the way outline gets generated. Thank you! |
Beta Was this translation helpful? Give feedback.
-
I am not sure what you mean. In EMF (and Xtext) a resource is equivalent to one file, and that's the scope that the diagram generator gets in. How much of that resource (and other cross-referenced ones) is visualized, is determined here and therefore up to you to implement. In yangster, we show the module (file) as well, and it's referenced modules only on demand. So yes, that's implemented, and available in the UI via contest menu entries in the editor on the files in the navigator. If resource for you means model element (one node in the outline, maybe a |
Beta Was this translation helpful? Give feedback.
-
@JanKoehnlein - Is it possible to customize the Outline-view-widget in order to create a menu for it so that separate diagram can be generated for each model element? Currently, we can only expand it as a tree and the model elements are not editable through any menu. |
Beta Was this translation helpful? Give feedback.
-
@Rijul5 That's possible, but it requires a bit of work. Add context menu for outline:Have a look at how we registered and populate the context menu in the navigator, namely Adapt open diagram commandThen add an appropriate open command that also contains the information on the symbol. Currently, different diagrams need different URIs. This is why I'd recommend to encode the symbol's location as the fragment of the URI. Adapt the server
That may not be the entire story, but it is how I would approach this task. BTW, just as you mentioned editing (=changing) an element in the outline by means of the context menu, I'd rather avoid that. |
Beta Was this translation helpful? Give feedback.
-
@JanKoehnlein - Thank you for explaining this in detail. Firstly, I only want to bind the menu to outline-widget and do not want to make it editable(=changing). I think the approach suggested by you will help us a lot in achieving the scenario where we can open different diagrams for model elements. I am currently trying the same and will update you shortly. Secondly, I would like to know that if I make the changes in Theia packages for outline-view in Theia project then how can I use the built packages/node modules in the Yangster project. Currently, I am using my own grammar and its Sprotty representation in the same Yangster project for experimental purposes. Please guide on this. |
Beta Was this translation helpful? Give feedback.
-
@Rijul5 This usually depends on what you want to change. In many scenarios, it's just OK to use dependency injection and rebind some service in the container module of your extension without applying changes to the original extension. The binding you would want to change is the one of So in the frontend module of your extension
For more details on DI, please refer to the documentation of Theia and InversifyJS. |
Beta Was this translation helpful? Give feedback.
-
@JanKoehnlein - Thank you for the detailed information on this step. Now, I am able to change the binding in outline view and can see the menu for outline view as well. PFB the screenshot for your reference. Using the command "Generate Diagram", I am able to open the diagram for the entire Xtext model(for the given URI). I am using something similar to OpenInDiagramHandler to generate the diagram for the URI. However, I want to access the model element information so that I can encode this as the URI as suggested by you. Therefore, can you please elaborate how can I get the symbol information and encode it as the URI. Also, which files/methods need to be changed for making IDiagramGenerator compatible to the version where we are generating a diagram for each model element? Finally, for developing is there a better way to see the changes on the client side. For the server, we can connect the running LSP through a socket and it is easy. However, for the client, I am not sure if there is any way similar to this because running yarn or yarn watch commands are expensive. Please guide on this. |
Beta Was this translation helpful? Give feedback.
-
Hi there, Query: can we create two SGraph's in one digramGenerator file. Example: If we want two child elements of the same type (Let's say Actor) under one diagram module. Actor One -> 2 Goals = A and B we want to create a dependency relation of one actor's goal on another actor in the same diagram module. Kindly suggest on this. |
Beta Was this translation helpful? Give feedback.
-
Hello, I am working on integrating my sprotty with theia and DSL language server. But I meet some problems. My sprotty does not show successfully. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I am successful in integrating my DSL language server with Theia, but now I would like to use sprotty to visualize the content.
I have gone through one example online: https://github.com/theia-ide/theia-sprotty-example
It executes well, but not so clear how one can use sprotty with (XText LSP into Theia).
I would appreciate your inputs.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions