Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext + FormEditor
Xtext + FormEditor [message #903917] Mon, 27 August 2012 09:20 Go to next message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
Hi all,
I'm a java programmer with basic knowledge of model related stuff.

Problem:
I have a generic application (not written by me) that requires a dozen of text file as input (each row represent something, a pair name-value, comment, etc..), but can be imagined independent from each other.

To me, every file has its own DSL, I need to create the xtext editor for that but also a FormEditor on the same model to ease the user experience.


I have a MPE with form on one page (created with WindowBuilder plugin, and inserted as pure editor following another post) and xtext on another.

How can be this sync/glued together? Do I need to go down the same process as for GMF-Xtext integration?
Or maybe the whole thing is far more simple and I can't see it?


Thanks,
Ste

[Updated on: Mon, 27 August 2012 09:21]

Report message to a moderator

Re: Xtext + FormEditor [message #905412 is a reply to message #903917] Thu, 30 August 2012 10:43 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Hello, similar discussions happening internally on my end - how do you guys all do this - this must be a common use case?

So imagine an MultiPageEditorPart (note http://git.eclipse.org/c/tmf/org.eclipse.xtext.git/plain/tests/org.eclipse.xtext.ui.tests/src/org/eclipse/xtext/ui/tests/editor/mpe/MultiPageEditor.java), or even a MyEditor extends XtextEditor with an @Override createPartControl() { ... new SashForm... }, with some Widgets. What is the recommended pattern to keep these in sync, based on Eclipse (JFace) Data Binding? A friend pointed out koehnlein.blogspot.de/2010/06/semantic-model-access-in-xtext.html, but I understand "just" binding the Widgets to the underlying EMF model is not the way go - the Data Binding would have to go "through" the IXtextDocument? Or am I totally off track here?

Thanks!
Re: Xtext + FormEditor [message #905652 is a reply to message #905412] Thu, 30 August 2012 20:07 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
I've looked a little further into this, and started hacking a EMFXtextProperties, à la EMFEditProperties, but using an IReadAccess<XtextResource> & IWriteAccess<XtextResource> (= XtextDocument) instead of an EditingDomain.

Would much appreciate any comments from anybody if this direction seems right / of interest / worthwhile further exploring - tx!
Re: Xtext + FormEditor [message #905782 is a reply to message #905652] Fri, 31 August 2012 04:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Michael,

I've done something similar to that for Xcore. In that case I want to
allow editing of the GenModel properties (which is inferred along with
Ecore and JvmTypes from the Xcore model). I hook up an editing domain
so I can monitor changes to the properties and convert them to
annotations in Xcore. You can look at XcoreEditor for the details. If
you're editing editing properties of the main model, you might use a
simpler approach of a content adapter or a change recorder to detect
when properties change and use that to serialize the model back to
text. The user will lose all their formatting though so it might not be
a pleasant experience. In Xcore's case I use command stack notification
to hook up a content adapter and based on what changes them, convert
them to more fine grained textual updates that given a nice undo/redo
experience...


On 30/08/2012 10:07 PM, Michael Vorburger wrote:
> I've looked a little further into this, and started hacking a
> EMFXtextProperties, à la EMFEditProperties, but using an
> IReadAccess<XtextResource> & IWriteAccess<XtextResource> (=
> XtextDocument) instead of an EditingDomain.
>
> Would much appreciate any comments from anybody if this direction
> seems right / of interest / worthwhile further exploring - tx!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Xtext + FormEditor [message #927345 is a reply to message #905652] Sat, 29 September 2012 14:58 Go to previous messageGo to next message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
Hi Michael,
I'm reading your code from github right now. I'm trying to figure out how to give it a try on the project I'm working on.

Cheers,
Ste
Re: Xtext + FormEditor [message #927517 is a reply to message #927345] Sat, 29 September 2012 19:11 Go to previous messageGo to next message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
Ehi Michael,
your XtextProperties happen to work just fine here in my MPE. I see you have a PDE test implementation in your TODO list that should be basically what I'm trying to achieve.

I have one form on a page of the MPE and the source on another. They interact like a charm.

Now I give it a try to the list too.

Thank you for your effort

Cheers
Ste

Re: Xtext + FormEditor [message #927527 is a reply to message #927517] Sat, 29 September 2012 19:27 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Ciao!

grazie per l'interesse. Indeed I had made some progress (it's all on GitHub) after this post, see screencast on youtu.be/7RThXRyo3ik, but got stuck & lost in Data Binding API internals for List Bindings... I had to move on to something more urgent - if you manage to get Lists working, do send me a Pull Request you'd make my day! Wink

Ciao,
Michael

PS, just FTR: Also http://www.eclipse.org/forums/index.php/t/373080/0/unread/ => http://www.eclipse.org/forums/index.php/m/921679/#msg_921679.
Re: Xtext + FormEditor [message #986204 is a reply to message #927527] Mon, 19 November 2012 13:01 Go to previous messageGo to next message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
Hi Michael,
I'm back on this project after a while.
I've downloaded from your xtext-sandbox on github mydsl, mydsl.ui, mydsl.test but I'm unable to "generate" the projects. It complains about missing src-gen folder (that is actually missing) and stuff like that.

Sorry for the stupid question, but do you have any suggestion?

Cheers,
Ste
Re: Xtext + FormEditor [message #986225 is a reply to message #986204] Mon, 19 November 2012 14:07 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Ciao Ste, yes Xtext generates the code in the ch.voburger.xtext.sandbox.mydsl(.ui/.tests)/src-gen folder... so you have to run the "Generate Language Infrastructure (ch.voburger.xtext.sandbox.mydsl)" launch config... it shows up automatically in the Launch menu, because it's stored in the .launch/ dir. This is standard Xtext stuff of course, nothing to do with the Binding idea per se.
Re: Xtext + FormEditor [message #986286 is a reply to message #986225] Mon, 19 November 2012 18:16 Go to previous messageGo to next message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
yep, I'm aware of that.. maybe the question was not that stupid in the end.
Just for the record, launching the "Generate Language..." throw a bunch of errors; I had to manually remove "src-gen" folder from Project/Properties/Java Build Path/Source...
Then the generation process ended without errors. After that, manually, the generated "src-gen" should be added as source folder again.

But in .tests "src" folder (that's not automatically generated) is still missing... did you code some test there?

Ste


Re: Xtext + FormEditor [message #986411 is a reply to message #986286] Tue, 20 November 2012 10:58 Go to previous message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
Ciao Ste, thanks for the interest, it would be very cool if you could contribute to this! Yeah the initial project set-up is always bit of a pain... sorry (if you know how to do this better - I'd love to learn!).

You are right, I didn't code any tests in https://github.com/vorburger/xtext-sandbox/tree/master/XtextDocumentBinding/ch.voburger.xtext.sandbox.mydsl.tests yet, it's correct that there is no src/ folder in there - nothing missing or forgotten to commit.

There are however a few tests in https://github.com/vorburger/xtext-sandbox/tree/master/XtextDocumentBinding/ch.vorburger.xtext.databinding.tests/src - not all passing yet.

Where I left it off was with List binding support, "tested" (manually for now) by the ViewerSupport.bind line in MUIXtextEditor (as explained more in an older post on another thread).
Previous Topic:Getting a reference to the class we are working with fails
Next Topic:large project vs several small projects
Goto Forum:
  


Current Time: Thu Apr 18 23:20:12 GMT 2024

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

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

Back to the top