Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » get EPackage from a EStructuralFeature
get EPackage from a EStructuralFeature [message #478843] Fri, 07 August 2009 08:31 Go to next message
Eclipse UserFriend
Originally posted by: aurelien.pupier.esial.net

Hi,

How can we get the Epackage from a EStructuralFeature?

I can get an EPackage by
EPackageImpl epackage = (EPackageImpl) structuralFeature.eContainer().eContainer();

But this one if the EContainer is not declare in the same .ecore, it will be the wrong EPackage.

I tried to get the correct EPackage via this EPackage but getEPackage and getESubPackages return null. In fact, subpackages must be declared in .ecore so it seems ok.
But how can we get the "loaded" Epackage from loaded .ecore?

Thanks for any hints

Aurelien Pupier
Re: get EPackage from a EStructuralFeature [message #478909 is a reply to message #478843] Fri, 07 August 2009 12:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30691
Registered: July 2009
Senior Member
Aurelien,

Comment below.

Aurelien Pupier wrote:
> Hi,
>
> How can we get the Epackage from a EStructuralFeature?
eStructuralFeature.getEContainingClass().getEPackage.
>
> I can get an EPackage by
> EPackageImpl epackage = (EPackageImpl)
> structuralFeature.eContainer().eContainer();
Why cast to an Impl? I see this casting to Impl classes often and I'm
always wondering why...
>
> But this one if the EContainer is not declare in the same .ecore, it
> will be the wrong EPackage.
Not sure I follow this comment. The containing class of the feature will
always have a package that also the feature. Of course a feature can be
among the eAllStructuralFeatures of a unbounded number of classes...
>
> I tried to get the correct EPackage via this EPackage but getEPackage
> and getESubPackages return null.
Again, I'm not following how that relates to the code you showed.
> In fact, subpackages must be declared in .ecore so it seems ok.
> But how can we get the "loaded" Epackage from loaded .ecore?
Is this a different question? Typically it's the root object of the
*.ecore resources...
>
> Thanks for any hints
>
> Aurelien Pupier
Re: get EPackage from a EStructuralFeature [message #479182 is a reply to message #478909] Mon, 10 August 2009 07:14 Go to previous message
Eclipse UserFriend
Originally posted by: aurelien.pupier.esial.net

Ed Merks a écrit :
> Aurelien,
>
> Comment below.
>
> Aurelien Pupier wrote:
>> Hi,
>>
>> How can we get the Epackage from a EStructuralFeature?
> eStructuralFeature.getEContainingClass().getEPackage.
>>
>> I can get an EPackage by
>> EPackageImpl epackage = (EPackageImpl)
>> structuralFeature.eContainer().eContainer();
> Why cast to an Impl? I see this casting to Impl classes often and I'm
> always wondering why...
My bad :s

>> But this one if the EContainer is not declare in the same .ecore, it
>> will be the wrong EPackage.
> Not sure I follow this comment. The containing class of the feature will
> always have a package that also the feature. Of course a feature can be
> among the eAllStructuralFeatures of a unbounded number of classes...

In fact, I want to create the EObject corresponding to the EStructuralFeature.
And it seems that I didn't get the right EPackage with structuralFeature.eContainer().eContainer() to do that.
(epackage.getEFactoryInstance().create(...))

>>
>> I tried to get the correct EPackage via this EPackage but getEPackage
>> and getESubPackages return null.
> Again, I'm not following how that relates to the code you showed.
>> In fact, subpackages must be declared in .ecore so it seems ok.
>> But how can we get the "loaded" Epackage from loaded .ecore?
> Is this a different question? Typically it's the root object of the
> *.ecore resources...
>>
>> Thanks for any hints
>>
>> Aurelien Pupier

Thanks for your help
Previous Topic:Delete elements in a model?
Next Topic:how to use instance of ecore as another metamodel?
Goto Forum:
  


Current Time: Thu Dec 12 02:51:14 GMT 2019

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

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

Back to the top