Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Retrieving the parent siblings on an EObject
Retrieving the parent siblings on an EObject [message #693186] Wed, 06 July 2011 01:15 Go to next message
Reinaldo Junior is currently offline Reinaldo JuniorFriend
Messages: 36
Registered: March 2011
Member

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()


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!
Re: Retrieving the parent siblings on an EObject [message #693234 is a reply to message #693186] Wed, 06 July 2011 04:49 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
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!


Re: Retrieving the parent siblings on an EObject [message #693235 is a reply to message #693234] Wed, 06 July 2011 04:50 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
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!


Re: Retrieving the parent siblings on an EObject [message #693432] Wed, 06 July 2011 13:16 Go to previous message
Reinaldo Junior is currently offline Reinaldo JuniorFriend
Messages: 36
Registered: March 2011
Member

Thank you!
Previous Topic:[CDO] Migrating to RC2 - driver not found
Next Topic:[CDO] Prefix Table Names
Goto Forum:
  


Current Time: Fri Apr 19 09:26:01 GMT 2024

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

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

Back to the top