Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Cross Reference in Ecore Editor
Cross Reference in Ecore Editor [message #1805687] Sun, 21 April 2019 20:11 Go to next message
TheEMF User is currently offline TheEMF UserFriend
Messages: 71
Registered: August 2018
Member
Hello,

I have two models, ModelA and ModelB.

ModelA has one classe : ClassY.

One of ModelB classes say ClassX has an attribute that references ClassY.

I made these models using Ecore.

Now, when I open the Ecore Editor and create a dynamic instance of ModelB, I need to give it the reference to ClassY. But as it does not belong to the same class the editor does not retrieve it. How can achieve that ?

Do you think that we can reference class from an external model in the Ecore Editor ?

Thank you for your help
Re: Cross Reference in Ecore Editor [message #1805690 is a reply to message #1805687] Mon, 22 April 2019 03:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30687
Registered: July 2009
Senior Member
Well normally ClassX would have an EReference that references ClassY, not an EAttribute, but maybe that's what you mean? The serialized *.ecore would look like this:
    <eStructuralFeatures xsi:type="ecore:EReference" name="something" eType="ecore:EClass ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EObject"/>
I.e., it would use a relative reference to the resource containing ClassY and that would automatically be resolved to platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore during loading and then the proxy, when accessed would load that resource and locate the referenced EClass.

So yes, definitely you can reference classes from other models and this is very common use case.
Re: Cross Reference in Ecore Editor [message #1805821 is a reply to message #1805690] Wed, 24 April 2019 19:49 Go to previous messageGo to next message
TheEMF User is currently offline TheEMF UserFriend
Messages: 71
Registered: August 2018
Member
Hi,

Thank you for your response.

Actually I have a problem when I make an instance of a model. In my model I say that I am referencing that class just as you mentioned. But now I want to give my instance this instance of a class in Ecore Editor and I don't know how I can achieve that ?

Thank you a lot.
Re: Cross Reference in Ecore Editor [message #1805826 is a reply to message #1805821] Thu, 25 April 2019 03:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30687
Registered: July 2009
Senior Member
To make a *.ecore model's classifiers available for use in another *.ecore model, you must use Load Resource... in the Sample Ecore Editor's context menu to, in your example, load ModelA.ecore into the editor you are using to edit ModelB.ecore. Once you do that, the cell editors will offer choices from ModelA.ecore while editing ModelB.ecore. Once you actually use ModelA.ecore in ModelB.ecore, i.e., add a EReference foo to EClass ClassX that references EClass ClassY from ModelA, then when you open ModelB.ecore in the editor, ModelA.ecore will automatically be loaded (when the cross reference is resolved). If you enable Live Validation from the context menu or the menu bar (which is always a good idea to have enabled), all cross references will automatically be resolved by the validator whenever you load ModelB.ecore (or any other model).
Re: Cross Reference in Ecore Editor [message #1806540 is a reply to message #1805826] Fri, 10 May 2019 09:14 Go to previous messageGo to next message
TheEMF User is currently offline TheEMF UserFriend
Messages: 71
Registered: August 2018
Member
Thanks for your reply.

Actually I want to retrieve a cross reference in a dynamic instance, how can I achieve that ?
Re: Cross Reference in Ecore Editor [message #1806554 is a reply to message #1806540] Fri, 10 May 2019 10:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30687
Registered: July 2009
Senior Member
Drag the resource of the other instance you want to reference into the editor so that the other instance is in the resource set and then those objects will be available in the cell editors.
Previous Topic:When running genmodel, different developers get different results
Next Topic:[Eclipse 2019-03 EMF.Editor] : regression ?
Goto Forum:
  


Current Time: Tue Dec 10 02:00:51 GMT 2019

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

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

Back to the top