Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to synchronize the EObject underneath the Xtext editor with another editor?
How to synchronize the EObject underneath the Xtext editor with another editor? [message #1209207] Mon, 25 November 2013 11:43 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
I have an Xtext editor to edit an EObject A. This object references an EObject B which is serialized with another method (currently via XMI, later using another Xtext grammar). The reference is non-containment. The B is used as an input to validate the consistency of the A. Now, when the B is edited and saved, the validation in the Xtext editor is still carried out on the "old" B before the save.
The problem is, my custom B editor edits another instance of the same B than what is referenced from the A the Xtext editor shows.
How can I synchronize these two B instances? Searching the web brought me to EMF Transaction and TransactionalEditingDomains, but I cannot find a way to hook an editing domain into an Xtext editor.

My first guess would be to use IResourceChangeListeners and use them to figure out if an object has to be reloaded, and on a change of the relevant file, do myB.eResource().unload() and myB.eResource().load().

Is there a more elegant solution?
Re: How to synchronize the EObject underneath the Xtext editor with another editor? [message #1213313 is a reply to message #1209207] Wed, 27 November 2013 07:26 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You don't need EMF Transactions for that.
If you work with namespace imports and references it should work out-of-the-box.
With Xtext editors on both sides it would even automatically update the referenced objects without saving.

How do you look up those EObjects B?
Re: How to synchronize the EObject underneath the Xtext editor with another editor? [message #1213372 is a reply to message #1213313] Wed, 27 November 2013 07:58 Go to previous messageGo to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
Can you give me some hints on how to get started with namespace imports? Does this also work with the custom editor which uses editing domains?

EDIT: Currently, I reference the B by its full URI, like so:

refToB "platform:/resource/SomeProject/somefolder/SomeB.b#/"

[Updated on: Wed, 27 November 2013 08:01]

Report message to a moderator

Re: How to synchronize the EObject underneath the Xtext editor with another editor? [message #1213843 is a reply to message #1213372] Wed, 27 November 2013 12:18 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
I guess this problem gets solved when you back up the second language with an Xtext grammar as well and change to referring to elements by their name.
Using names for cross references is the default linking mechanism provided by Xtext.

You should read the sections on linking and scoping in the docs:
- http://www.eclipse.org/Xtext/documentation.html#linking
Previous Topic:Xtext/EMF resource file handlers
Next Topic:When loading Xtext resources at start, encodingProvider of XtextResource is null.
Goto Forum:
  


Current Time: Sat Apr 20 00:33:20 GMT 2024

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

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

Back to the top