Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Automatic editor update
Automatic editor update [message #1763814] Sat, 20 May 2017 11:52 Go to next message
Carsten Wrobel is currently offline Carsten WrobelFriend
Messages: 9
Registered: May 2017
Junior Member
Hi,

We are currently designing a dsl for robot descriptions (URDF files) using xtext.

In our concrete syntax we would like to support that a user can make changes to the same object instance referred from multiple places in the editor/document. Example:

// create joint of type Revolute
UpperArm R-> LowerArm

.... other definitions ....

// change already created joint type to prismatic
UpperArm.LowerArm
Type = prismatic

Ideally we would like the editor to reflect such changes automatically, so that:
UpperArm R-> LowerArm automatically changes to: UpperArm P-> LowerArm (R changed to P)

Which feature in xtext should be used to update the editor based on changes in the AST?

I have looked in the direction of implementing af handler inspired by this post: koehnlein.blogspot.dk/2014/08/graphical-views-for-xtext-ctd.html and use the XtextDocument, but not sure if this is the right mechanism for this purpose.

Thanks,
Carsten
Re: Automatic editor update [message #1763892 is a reply to message #1763814] Mon, 22 May 2017 16:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Editor.getDocument().modify

Should work fine


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Automatic editor update [message #1769149 is a reply to message #1763892] Thu, 27 July 2017 06:30 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi Christian

How can I get the active editor from a non-ui project. I want to modify my xtext document when the user "saves" the xtext editor. How should I do it? Please help.

Regards
Puneet
Re: Automatic editor update [message #1769152 is a reply to message #1769149] Thu, 27 July 2017 07:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

please explain your exact usecase.
what do you mean by "non ui project"


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Automatic editor update [message #1769195 is a reply to message #1769152] Thu, 27 July 2017 13:36 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi

When we generate xtext project before v2.10 we get 2 projects. One is "Myproject.dsl" (non-UI project) and another is "Myproject.dsl.ui".
I want to modify and update my editor when a user presses ctrl+s (save). There are some concepts which are like EOpposite in EMF. So at "save" I want to create it programmatically. This is my usecase

Thanks
Re: Automatic editor update [message #1769199 is a reply to message #1769195] Thu, 27 July 2017 14:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you may have a look at XtextEditor.doSave

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Automatic editor update [message #1769236 is a reply to message #1769199] Fri, 28 July 2017 07:07 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi Christian

Thanks for the answer but let me explain you better of what I need. I do not want to call 'save' programmatically. I want to capture the event of "save" on xtext editor and modify my xtext model programmatically. I know I have to use XtextDocument.modify(new IUnitOfWork) but I do not know where to keep this code. For example, when we save the xtext editor the <MyDSLGenerator> gets called automatically. However the generator is in a non-ui project(MyDsLProject.dsl) and hence EditorUtils.getActiveXtextEditor.document does not work. So, how do I capture the "save" event in the UI project (MyDSLproject.dsl.ui) and call the modify method? Does this make sense? Is my understanding about the non-UI project correct? Please help me with my understanding.

Thanks in advance.
Puneet
Re: Automatic editor update [message #1769237 is a reply to message #1769236] Fri, 28 July 2017 07:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
XtextEditor.doSave is the point (the main one) where save is done.
=> subclass
you can call on the editor (this) get (Xtext) Document to obtain the document


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Automatic editor update [message #1769239 is a reply to message #1769237] Fri, 28 July 2017 07:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and no the generator is called by the eclipse builder infrastructure which
is triggered by the file change that is done by the editor save.

you can move and bind a generator in the ui module as well.
this will override the configuration the the runtime module.

but it might be a bad idea to do this in the generator


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Automatic editor update [message #1769243 is a reply to message #1769239] Fri, 28 July 2017 07:46 Go to previous message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Thanks for the immediate response. I will try to do it and get back. And also thanks for clarifying my understanding.

Puneet
Previous Topic:Collection of open source grammars
Next Topic:Ignore All text between a scope
Goto Forum:
  


Current Time: Tue Mar 19 04:13:18 GMT 2024

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

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

Back to the top