Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Editing XText DSL code from GUI?(Is this possible?)
Editing XText DSL code from GUI? [message #1711421] Thu, 15 October 2015 20:28 Go to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
I am considering using XText to create a DSL. However, I'd like certain aspects of my language to be editable from GUIS (JavaFX/Swing).

I came across an old thread claiming this was possible because of XText's EMF integration, but haven't been able to find much explanation of how.

For example, imagine a language file where numerical properties are modifiable via sliders imposing limited ranges.

Is this kid of thing possible on top of XText/Eclipse? Any pointers to help me wrap my head around this integration?

Thanks very much!
Re: Editing XText DSL code from GUI? [message #1711560 is a reply to message #1711421] Sat, 17 October 2015 09:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
you may have a look at http://de.slideshare.net/TomSchindl/java-fx-xtext

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Editing XText DSL code from GUI? [message #1711573 is a reply to message #1711560] Sat, 17 October 2015 16:04 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Larry,

you can programatically parse an Xtext model, query/modify the AST and save it again. The AST is basically just Java Beans, so any GUI technology will work.

The fact that the AST is EMF-based is only important if you integrate with other EMF-based technologies like Sirius graphical editors or EMF forms.

Cheers,
Stefan
Re: Editing XText DSL code from GUI? [message #1711585 is a reply to message #1711573] Sat, 17 October 2015 18:57 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
This is great news, thanks for letting me know!

However, I assume this creates issues with potential concurrent editing of the AST?

Is it possible to simultaneously be editing the AST from an external application and from the xtext natured eclipse application without getting them out of sync?

Also, I understand the notion of accessing the bean programmatically, but this must eventually bottom out as text in the grammar of the DC which is saved to disk, right? I suppose another route would be to have dsl code written in this way saved as a non-human-readable serialization of the AST created though this seems less desirable for a few reasons. Do the AST beans provide an API for either of these options?

Is there a good resource or example which demonstrates programmatic access of the AST beans from a separate application?

Thanks again, this is very exciting to learn about.
Re: Editing XText DSL code from GUI? [message #1711617 is a reply to message #1711585] Sun, 18 October 2015 12:28 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hi Larry,

why would you want to edit the file from two applications at the same time? Why not have your special (form based?) editor inside the IDE? If you edit from two applications, then of course they will go out of synch.

The AST is serialized as text that conforms to your grammar.

There is a nice, short blog post showing how to parse files in a standalone application. The second paragraph is the more interesting.

Apart from that you should just start coding a little, that will make things much clearer and will allow us to answer more concrete questions.

Cheers,
Stefan
Re: Editing XText DSL code from GUI? [message #1711634 is a reply to message #1711617] Sun, 18 October 2015 20:14 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Quote:
why would you want to edit the file from two applications at the same time? Why not have your special (form based?) editor inside the IDE?


Good point. I guess what I mean specifically is the idea of having the file accessible from both the eclipse textual interface and my special form simultaneously. It sounds like, if the special form is just inserting text, though, this won't be a problem.

So then, if I'm understandingly correctly, the idea would be that the special form is effectively just inserting and modifying text as if this were happening via the keyboard. I'm still wondering if there XText artifacts offer an API for this, or if I'd just need to roll that myself.

I am working my way through the tutorials now, so should be able to phrase this in a specific example soon Smile Thanks for the help!
Re: Editing XText DSL code from GUI? [message #1711665 is a reply to message #1711634] Mon, 19 October 2015 07:32 Go to previous messageGo to next message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Quote:
I'm still wondering if there XText artifacts offer an API for this.


You use the load/save methods of the Xtext resource. The parser/serializer do all the work for you. Your form just changes the AST like it were simple Java Beans.
Re: Editing XText DSL code from GUI? [message #1712049 is a reply to message #1711634] Wed, 21 October 2015 06:09 Go to previous messageGo to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Larry LeBron wrote on Sun, 18 October 2015 20:14
I am working my way through the tutorials now, so should be able to phrase this in a specific example soon Smile Thanks for the help!


Any new realizations? Could you post some links to tutorials, you are using? I am also interested in editing Xtext DSL code from GUI.
Re: Editing XText DSL code from GUI? [message #1712050 is a reply to message #1712049] Wed, 21 October 2015 06:19 Go to previous messageGo to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
I'm working my way through Lorenzo Bettini's "Implementing Domain-Specific Languages with Xtext and Xtend"

So far, it's a wonderful introduction to the language, and I highly recommend it!

I haven't seen specific mention of using a GUI to edit the DSL yet, but have just come across my first example of accessing and editing the EMF model. The code is just what you'd hope it would be. DSL nodes are accessible and editable via a straightforward Java API, which is generated based off of the language grammar.

For example, if your grammar has the rule:

DSLNode: 
	'node' name=ID
;


then, if you gain access to this node via the EMF, you'll be able to call a simple setName(String) method, which will then automatically update the text in your DSL file to match. Very cool stuff!
Re: Editing XText DSL code from GUI? [message #1712063 is a reply to message #1712050] Wed, 21 October 2015 07:45 Go to previous messageGo to next message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
Larry,

yes, I have the book in my bookshelf and it helped me a lot, finding the entry to DSL. Smile

It means, if I manipulate my EMF model, this will have effects to the Xtext code? Have you tried it out already? I will gibe it a try soon.

If you find something interesting, I would be very grateful if you could share it. I will post my results, if I find something, too.
Re: Editing XText DSL code from GUI? [message #1712738 is a reply to message #1712063] Tue, 27 October 2015 19:09 Go to previous message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
Sorry this took so long. Yes, this means that manipulating your EMF model will affect the Xtext code. The code is the serialization of the model, so it will be immediately updated if the model is altered. For an example, check out the section on "quick-fixes" in the book, which includes examples of programmatic access to the EMF model.
Previous Topic:How to get name from unlinked EOBject
Next Topic:Replacement for TypeReferences.isInstanceOf and SuperTypeCollector
Goto Forum:
  


Current Time: Thu Sep 19 03:32:44 GMT 2024

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

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

Back to the top