Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Graphical view for Xtext(How to generate diagram from Xtext DSL?)
Graphical view for Xtext [message #1724858] Fri, 26 February 2016 15:13 Go to next message
Han Li Koay is currently offline Han Li KoayFriend
Messages: 25
Registered: February 2016
Junior Member
Hi,

I am developing DSL using Xtext and i am hoping to be able to generate graphical diagram/view based on my DSL code. (I do not want a graphical editor). However, the graphical view is not describing the AST itself instead it is based on some custom diagramming and layout algorithm.

MY DSL example code will looks like this:
create_domain domain1 {
     element: u1
}

create_domain domain2 {
    element: u1/u11
}

create_domain domain3{
   element: u1/u12
}

And my desired graphical view would looks like this:
http://i.imgur.com/1rTv9nw.png

From my code, "create_domain" will create a rectangle shape (it can be any custom shape, doesn't have to be rectangle) with its name above it. The hierarchy is based on the "element" defined for each domain. The "/" sign indicates the child of a parent domain. Thus, u11 and u12 is the child of u1 which is shown in the diagram above.

My problem now is that i do not know which kind of graphical framework or tools should i go for to achieve something like this as well as integrating with Xtext. I had been looking into Graphitti, GMF, JavaFx, Kieler and etc but i am still lost. So, I am hoping to get some guidance on what kind of approach or direction should i proceed.

I would really really appreciate for any guidance that is given to me considering i am still a newbie in this field. Thanks in advance.

Regards
Hanli

Re: Graphical view for Xtext [message #1724859 is a reply to message #1724858] Fri, 26 February 2016 15:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13164
Registered: July 2009
Senior Member
Hi i Found Fxdiagram quite handy for such a task. And of corse it uses
JavaFX and Kieler

https://github.com/JanKoehnlein/FXDiagram


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 26 February 2016 15:31]

Report message to a moderator

Re: Graphical view for Xtext [message #1725019 is a reply to message #1724859] Mon, 29 February 2016 07:50 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Congratulations you don't want a graphical editor. The latter would be pretty tedious to synchronize.

FXDiagram is a good fit, especially when you want the diagram to be shown in the same Eclipse workbench as the model.
For your case it boils down to creating and registering a diagram configuration with a node mapping, a label mapping and a connection mapping. More documentation on FXDiagram can be found here. Or feel free to ask specific questions on this thread.

The dumbest solution if the above is too complicated would be to generate a Graphviz dot file. This is fine for documenting but not integrated in the workbench.




---
Get professional support from the Xtext committers at www.typefox.io
Re: Graphical view for Xtext [message #1726417 is a reply to message #1725019] Sun, 13 March 2016 10:38 Go to previous messageGo to next message
Han Li Koay is currently offline Han Li KoayFriend
Messages: 25
Registered: February 2016
Junior Member
Hi Jan Koehnlein,

This may a dumb question but may i know how to or where to customize all the configuration needed to develop my own diagrams?

I installed everything properly but it seems now i can only use the FXdiagram and play around on the examples given. Am i missing something?

Thanks
Hanli Smile
Re: Graphical view for Xtext [message #1726617 is a reply to message #1725019] Tue, 15 March 2016 07:06 Go to previous messageGo to next message
Han Li Koay is currently offline Han Li KoayFriend
Messages: 25
Registered: February 2016
Junior Member
Another question, how do i use my own custom Xtext language together with the diagram configuration?

Thanks
Han Li Smile
Re: Graphical view for Xtext [message #1726712 is a reply to message #1726617] Tue, 15 March 2016 21:23 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
You have to implement your own mapping. See http://jankoehnlein.github.io/FXDiagram/hla.html
You can also have a look at the examples to get a deeper understanding, e.g.
https://github.com/JanKoehnlein/FXDiagram/blob/master/de.fxdiagram.xtext.domainmodel/src/de/fxdiagram/xtext/domainmodel/DomainmodelDiagramConfig.xtend
or
https://github.com/JanKoehnlein/FXDiagram/blob/master/de.fxdiagram.xtext.fowlerdsl/src/de/fxdiagram/xtext/fowlerdsl/StatemachineDiagramConfig.xtend


---
Get professional support from the Xtext committers at www.typefox.io
Re: Graphical view for Xtext [message #1808265 is a reply to message #1726712] Thu, 20 June 2019 18:53 Go to previous messageGo to next message
Layan Alwakeel is currently offline Layan AlwakeelFriend
Messages: 1
Registered: June 2019
Junior Member
Hi Hanli,

Do you find the solution for visualizing DSL code? I try to solve the same problem and I need some help.

Re: Graphical view for Xtext [message #1808281 is a reply to message #1808265] Fri, 21 June 2019 05:36 Go to previous message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 67
Registered: February 2016
Member
Hi Layan,

you can convert your Xtext DSL into a Graphviz *.dot file and use the Eclipse GEF DOT Plugin to visualize the *.dot file on the Eclipse Workbench UI.
Some examples how to achieve that are available under:
- blog post: Eclipse GEF DOT Graphical Views on Xtext DSLs
- recorded talk on the EclipseCon Europe 2018: Eclipse GEF DOT Graphviz Authoring Environment in Eclipse

Best regards,
Tamas
Previous Topic:Classes responsible for Syntax Coloring
Next Topic:Saving AST of xText runtime model as an ecore model
Goto Forum:
  


Current Time: Tue Oct 22 19:14:45 GMT 2019

Powered by FUDForum. Page generated in 0.42547 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top