|
Re: Retrieving the parent siblings on an EObject [message #693234 is a reply to message #693186] |
Wed, 06 July 2011 04:49 |
|
Am 06.07.2011 03:15, schrieb Reinaldo Junior:
> This question is related to this problem: http://www.eclipse.org/forums/index.php/mv/msg/218366/692978/#msg_692978 but I think that here could be the right place to ask.
>
> How do I get the siblings of the parent of an object? Why I cant do a direct cast like in:
> (View) lp.eContainingFeature().eContainer()
Look at the JavaDoc for eContainingFeature(): "Returns the particular |feature <eclipse-javadoc:%E2%98%82=org.eclipse.emf.cdo/C:%5C/develop%5C/ws%5C/cdo%5C/_target%5C/plugins%5C/org.eclipse.emf.ecore_2.7.0.v20110605-0747.jar%3Corg.eclipse.emf.ecore%28EObject.class%E2%98%83EObject%7EeContainingFeature%E2%98%82EClass%E2%98%82getEAllContainments>| of the |container <eclipse-javadoc:%E2%98%82=org.eclipse.emf.cdo/C:%5C/develop%5C/ws%5C/cdo%5C/_target%5C/plugins%5C/org.eclipse.emf.ecore_2.7.0.v20110605-0747.jar%3Corg.eclipse.emf.ecore%28EObject.class%E2%98%83EObject%7EeContainingFeature%E2%98%82%E2%98%82eContainer>| that actually holds the object, or |null|, if there is no container."
The container of a feature is always an instance of EClass and not one of your modeled classes. Try:
(View) lp.eContainer().eContents()
Consider that eContainer() can be null, in which case you may want to check eResource().getContents().
Also note that you may want to remove lp from the results.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
>
> What is the right way of doing this?
>
> I'm searching for a long time but all material that I found on EMF is about creating the project, genmodels, etc and little info about the EMF runtime rules.
>
> Thank you!
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: Retrieving the parent siblings on an EObject [message #693235 is a reply to message #693234] |
Wed, 06 July 2011 04:50 |
|
Am 06.07.2011 06:49, schrieb Eike Stepper:
> Am 06.07.2011 03:15, schrieb Reinaldo Junior:
>> This question is related to this problem: http://www.eclipse.org/forums/index.php/mv/msg/218366/692978/#msg_692978 but I think that here could be the right place to ask.
>>
>> How do I get the siblings of the parent of an object? Why I cant do a direct cast like in:
>> (View) lp.eContainingFeature().eContainer()
> Look at the JavaDoc for eContainingFeature(): "Returns the particular |feature <eclipse-javadoc:%E2%98%82=org.eclipse.emf.cdo/C:%5C/develop%5C/ws%5C/cdo%5C/_target%5C/plugins%5C/org.eclipse.emf.ecore_2.7.0.v20110605-0747.jar%3Corg.eclipse.emf.ecore%28EObject.class%E2%98%83EObject%7EeContainingFeature%E2%98%82EClass%E2%98%82getEAllContainments>| of the |container <eclipse-javadoc:%E2%98%82=org.eclipse.emf.cdo/C:%5C/develop%5C/ws%5C/cdo%5C/_target%5C/plugins%5C/org.eclipse.emf.ecore_2.7.0.v20110605-0747.jar%3Corg.eclipse.emf.ecore%28EObject.class%E2%98%83EObject%7EeContainingFeature%E2%98%82%E2%98%82eContainer>| that actually holds the object, or |null|, if there is no container."
Should read: Returns the particular feature of the container that actually holds the object, or null, if there is no container.
>
> The container of a feature is always an instance of EClass and not one of your modeled classes. Try:
>
> (View) lp.eContainer().eContents()
>
> Consider that eContainer() can be null, in which case you may want to check eResource().getContents().
> Also note that you may want to remove lp from the results.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
>>
>> What is the right way of doing this?
>>
>> I'm searching for a long time but all material that I found on EMF is about creating the project, genmodels, etc and little info about the EMF runtime rules.
>>
>> Thank you!
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.02270 seconds