Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » getting resource from model element
getting resource from model element [message #1070070] Wed, 17 July 2013 07:36 Go to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Hi,

I am opening a EMF model with a generated editor.
When I am selecting (by clicking) an element of this model, I would like to know which resource it comes from.

Using eContainer(), I can go up to the DocumentRoot but I have seen that when closing and opening back the editor, the DocumentRoot object's id changes so I cannot rely on this object to know which resource I am working on (I have a table mapping resources to DocumentRoot s).

So I'd like to get the resource's URI, which should not change, but I don't know how to get it from the model element.

Can someone give me a track ?

Thanks
Re: getting resource from model element [message #1070075 is a reply to message #1070070] Wed, 17 July 2013 07:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
From any EObject x (it doesn't have to be a root object) you can use
x.eResource() to get its containing resource and of course from that you
can get the URI.

On 17/07/2013 9:36 AM, Vincent De Bry wrote:
> Hi,
>
> I am opening a EMF model with a generated editor.
> When I am selecting (by clicking) an element of this model, I would
> like to know which resource it comes from.
>
> Using eContainer(), I can go up to the DocumentRoot but I have seen
> that when closing and opening back the editor, the DocumentRoot
> object's id changes so I cannot rely on this object to know which
> resource I am working on (I have a table mapping resources to
> DocumentRoot s).
>
> So I'd like to get the resource's URI, which should not change, but I
> don't know how to get it from the model element.
>
> Can someone give me a track ?
>
> Thanks


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getting resource from model element [message #1070096 is a reply to message #1070075] Wed, 17 July 2013 08:21 Go to previous message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
It was so simple...
Thank you very much Ed !
Previous Topic:noNamespaceSchemaLocation URI resolution with catalog entry
Next Topic:basePackage ignored when generating EMF classes with Ecore2Java ant task
Goto Forum:
  


Current Time: Thu Apr 25 14:17:54 GMT 2024

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

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

Back to the top