get EPackage from a EStructuralFeature [message #478843] |
Fri, 07 August 2009 08:31 |
Eclipse User |
|
|
|
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 #479182 is a reply to message #478909] |
Mon, 10 August 2009 07:14 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06106 seconds