Xtext Graphical View [message #1036534] |
Mon, 08 April 2013 14:01 |
d 627 Messages: 28 Registered: March 2013 |
Junior Member |
|
|
Hi there.
This is my problem: I'm working with xtext and I have to create a GRAPHICAL REPRESENTATION of the projects creating with my own language, I mean, once my dsl is creating I'm able to use it creating a "X" project and the idea is to be able to see the rappresentation of that project.
I've been searching for a good example, and for possible solutions, but is like a dead road. I've seen some posts about EUGENIA, GMF, SPRAY... but in any of those they explain what to do. There is also a video in xtext home page with the generic graphic view example, but once and again there is no the explanation about how to create the conexion beetwen my dsl and the results that I can obtain.
What do you suggest, what can I do, do you know a good example.....
Thanks a lot.
|
|
|
Re: Xtext Graphical View [message #1036537 is a reply to message #1036534] |
Mon, 08 April 2013 14:07 |
|
Hi Daniel,
I'm not sure I completely understand the problem you are describing. Is it the case that you already have an Xtext-based language and you need to visualise/edit models that conform to this language using a graphical editor?
Cheers,
Dimitris
|
|
|
|
Re: Xtext Graphical View [message #1036545 is a reply to message #1036538] |
Mon, 08 April 2013 14:19 |
|
You can try to annotate the Ecore metamodel produced from the Xtext grammar using the annotations provided by Eugenia [1] and then generate a GMF-based editor from it (don't go for the "Generate GMF Editor" option as you *only* want to generate the .diagram project). In your runtime workbench you should then be able to right-click on your models in the project explorer and select "Initialise XYZ diagram file".
Cheers,
Dimitris
[1] http://eclipse.org/epsilon/doc/articles/eugenia-gmf-tutorial/
|
|
|
Re: Xtext Graphical View [message #1036564 is a reply to message #1036545] |
Mon, 08 April 2013 14:49 |
|
Hi Daniel,
I've tried this and it works fine. Please find a list of steps below:
1. Create a new Xtext project (keep all the defaults)
2. Launch GenerateMyDsl.mwe2
3. Annotate MyDsl.ecore (org.xtext.example.mydsl/src-gen/org/xtext/example/mydsl/MyDsl.ecore)
4. Right-click on MyDsl.ecore and select Eugenia->Generate GMF tool, graph and map models
5. Open MyDsl.genmodel, right-click on its root and select Generate Edit Code
6. Right-click on MyDsl.gmfmap and select Create generator model... (keep all the defaults)
7. Right-click on MyDsl.gmfgen and select Eugenia-> Synchronize GMFGen
8. Right-click on MyDsl.gmfgen and select Generate diagram code
9. Launch a new Eclipse instance
10. Create a new .mydsl file and add some valid contents to it
11. Right-click on the file in the project explorer and select Initialise mysdsl diagram file (you should now also be able to edit your .mydsl file through the GMF editor)
The complete code for the scenario above is available in https://dl.dropbox.com/u/5636547/org.xtext.example.mydsl.eugenia.zip
Cheers,
Dimitris
|
|
|
|
|
|
|
|
Re: Xtext Graphical View [message #1037270 is a reply to message #1037262] |
Tue, 09 April 2013 11:08 |
|
Hi Claudio,
I suspect that the extension of the domain model files is somehow controlled by Xtext but I'm afraid my knowledge of Xtext is quite limited to be able to help with this. If you do find out (people in the Xtext forum may be able to help) it'd be great if you could post the answer here for completeness.
Cheers,
Dimitris
|
|
|
|
|
Re: Xtext Graphical View [message #1037315 is a reply to message #1037306] |
Tue, 09 April 2013 12:08 |
Claudio Heeg Messages: 75 Registered: April 2013 |
Member |
|
|
Hello,
sorry, I probably haven't expressed myself properly.
I was wondering where the file extension for files from which a diagram can be created is specified, "domainmodel" in this specific case.
It is likely an extension added to the context menu, applied to a specific file extension, as the menu entry "Initialize [...] diagram" (see picture) only appears in .domainmodel files. I believe if I can find out where that menu entry is registered I can figure out how to work with different extensions.
Edit:
Nevermind, I found it, it's in the popup menu extension of the diagram. Now to find out _why_ it's specified as *.domainmodel there.
Edit2:
Doesn't matter, just editing the nameFilter to *.dmodel does the trick.
Trivial solutions to annoying problems are nice.
It is, however, a little bit of a nuisance that I have to change this all the time when I generate the diagram code anew.
[Updated on: Tue, 09 April 2013 12:40] Report message to a moderator
|
|
|
Re: Xtext Graphical View [message #1037930 is a reply to message #1037315] |
Wed, 10 April 2013 07:31 |
|
Hi
I jump in here if that's ok
Dimitris, I tried to follow your steps but when I tried to generate the tool, graph, map thingies I got the following error message:
Method 'getContainmentReferences' not found (bundleresource://614.fwk1639539799/transformations/ECore2GMF.eol@189:38)
and when I run your zip folder i get the following errors when I try to make the mydsl_diagram file
"Premature end of file." and "java.lang.NullPointerException errors" so I end up with an empty diagram file I cant do much with.
So I don't seem to have much luck with making diagram files at the moment
But I was wondering what I should look at in your code to see the interaction between XText and GMF? I am working at the moment in Graphiti and I have an XText grammar and a Graphiti diagram plugin and I am looking at merging them and even though your code is using GMF I thought it could be a good help.
Am I on the right track if I think the connection is in the plugin.xml from your org.xtext.example.mydsl.diagram package and the files in your org.xtext.example.mydsl.myDsl.provider package?
|
|
|
Re: Xtext Graphical View [message #1037944 is a reply to message #1037930] |
Wed, 10 April 2013 07:51 |
Claudio Heeg Messages: 75 Registered: April 2013 |
Member |
|
|
Oh dear, I wrote up such a nice post and the forum ate it. Rude.
-
Anyway, I hope you don't mind if I answer to the best of my knowledge.
I'm by no means an expert on either Xtext or GMF-based tools, so take what I say with a grain of salt, but I gathered at least some knowledge during the last weeks.
As you probably know, Xtext relies on the EMF, i.e. creates an Ecore model for every grammar to then work with its nodes.
Eugenia (in this case, but other GMF tools too, as far as I know) also uses that model, but takes it in another direction to create a graphical view for it.
So I think the connection between Xtext and Eugenia is more or less only indirect via the Ecore model.
As for your error, I'll take a guess and say it's caused by an erroneous annotation.
|
|
|
Re: Xtext Graphical View [message #1037978 is a reply to message #1037944] |
Wed, 10 April 2013 08:45 |
|
Feeling responsible for eating your post so... sorry.
(I blame that I am new to forums find it easier to continue in an existing thread then beginning a new one )
-
Have no problem with you answering my question, it explains a lot of the structure so I don't mind.
And now I know a bit more what to look for so thanks for the reply, and if I get more questions I will start a new thread
|
|
|
|
|
|
Re: Xtext Graphical View [message #1041951 is a reply to message #1041684] |
Mon, 15 April 2013 20:18 |
d 627 Messages: 28 Registered: March 2013 |
Junior Member |
|
|
Ok I've been having all the possible problems to reproduce this example. I just follow all the steps that Dimitris wrote but for some reason, even when diagram package is creating correctly, when I launch the new Eclipse Application I don't see the option for initialize the diagram file.
I've been looking for all the possible explanation but nothing until now.
[Updated on: Tue, 16 April 2013 12:11] Report message to a moderator
|
|
|
Re: Xtext Graphical View [message #1041972 is a reply to message #1041951] |
Mon, 15 April 2013 20:52 |
|
Hi Daniel,
The file extension for the "Initialize XYZ Diagram" menu item is specified through an extension to the "org.eclipse.ui.popupMenus" extension point in plugin.xml of your .diagram project. To change it, you need to change the value of its nameFilter attribute.
Cheers,
Dimitris
|
|
|
|
|
|
|
|
|
|
|
|
Re: Xtext Graphical View [message #1844172 is a reply to message #1036564] |
Sat, 04 September 2021 11:03 |
Christoph Binder Messages: 13 Registered: September 2021 |
Junior Member |
|
|
Thank you, that looks quite good and that I can use it in the same runtime as the xtext editor is great. But before I start I need to be sure of some things:
The graphical view is needed to monitor the flow of a recipe (with parallel steps, I guess thats possible to view?), so I would therefore need to
1) update the view every other second ( I guess by triggering"getRenderingMetadata" more often so not only when the editor is saved or opened) and
2) beeing able to get color and an Integer from the xtext generator (NOT from the xtext editor but code behind) I guess it would be sufficient if the .egl file could call for it from the generator).
Do you think that tasks are somehow doable? Or do I need to look for some other software? Thanks for the help!
P.S. I tried the Picto example from Epsilon Git repo and in the Picto View there is just the tree visible, with a premature end of file message, so the Graphical view is missing, any suggestions?
[Updated on: Sat, 04 September 2021 11:38] Report message to a moderator
|
|
|
Re: Xtext Graphical View [message #1844176 is a reply to message #1844172] |
Sat, 04 September 2021 18:03 |
|
Hi Christoph,
Re #1, in your implementation of getRenderingMetadata you can add custom parameters to the EGX/EGL template using metadata.getParameters().add(...)
Re #2, to refresh your view programmatically you need to get hold of the PictoView (see [1]), and then call pictoView.render(pictoView.getEditor()); periodically.
I've tried the example again with the latest interim version of Epsilon and it works fine for me. Could you please provide a screencast that demonstrates the issue you're encountering?
Best,
Dimitris
[1] https://www.eclipse.org/forums/index.php/t/101546/
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Xtext Graphical View [message #1844303 is a reply to message #1844176] |
Wed, 08 September 2021 14:03 |
Christoph Binder Messages: 13 Registered: September 2021 |
Junior Member |
|
|
Hello Dimitris,
thank you very much reinstalling Graphviz did it for me, my project already looking quite good!
I have another question:
I dont know where to call pictoView.render(pictoView.getEditor()). Since xtext is a framework(IoC) its difficult to "enter" the control flow.
Thank you very much again, your help is extremely valuable!
[Updated on: Wed, 08 September 2021 14:07] Report message to a moderator
|
|
|
Re: Xtext Graphical View [message #1844309 is a reply to message #1844303] |
Wed, 08 September 2021 14:50 |
|
Hi Christoph,
It's good to hear that after reinstalling Graphviz you've managed to make good progress with Picto!
> I dont know where to call pictoView.render(pictoView.getEditor()). Since xtext is a framework(IoC) its difficult to "enter" the control flow.
This seems to be more of an Xtext question so my suggestion would be to post a message to https://www.eclipse.org/forums/index.php/f/27/
Best,
Dimitris
|
|
|
Re: Xtext Graphical View [message #1844310 is a reply to message #1844309] |
Wed, 08 September 2021 15:44 |
Christoph Binder Messages: 13 Registered: September 2021 |
Junior Member |
|
|
Solved
Thank you, I think I found a workaround (by simply starting a new thread via getRenderingMetadata() itself to render until I want it to stop).
Nonentheless, there is also a Picto question concerning this topic:
I would use
PictoView pview= (PictoView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.epsilon.picto.PictoView");
pview.render(view.getEditor());
to refresh my PictoView as suggested in the Post you recommended, but I get the error that "the return value of "org.eclipse.ui.IWorkbench.getActiveWorkbenchWindow()" is null". Have I made a mistake in calling the view? And I hope I am right that calling view.render() would again call getRenderingMetadata()?
Thanks again!
[Updated on: Thu, 09 September 2021 18:45] Report message to a moderator
|
|
|
Re: Xtext Graphical View [message #1844498 is a reply to message #1844310] |
Wed, 15 September 2021 09:02 |
|
> "the return value of "org.eclipse.ui.IWorkbench.getActiveWorkbenchWindow()" is null"
It's hard to guess what might be going wrong here from the error message alone. If you haven't solved this already, could you please put together a minimal example I can use to reproduce this?
Best,
Dimitris
|
|
|
|
|
|
|
|
|
|