Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Index of model element with in a container
Index of model element with in a container [message #1779432] Sun, 07 January 2018 18:49 Go to next message
Manoj Keshavaprakash is currently offline Manoj KeshavaprakashFriend
Messages: 4
Registered: October 2017
Junior Member
Hi,

I am working on EMF for a couple of months now. I have a small concern regarding the index of the element position within a container.

Eg.

Company ABC
-------Employee 1
-------Employee 2

Now I want to know the index of Employee 2. I am working on a scenario of handling the movement of elements within a container and I need to know the index of the element to capture the move.

Appreciate your help in advance.

Regards,
Manoj

[Updated on: Sun, 07 January 2018 18:50]

Report message to a moderator

Re: Index of model element with in a container [message #1779442 is a reply to message #1779432] Mon, 08 January 2018 05:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29594
Registered: July 2009
Senior Member
Assuming there are no feature maps involved in the model, then for any EObject x, if x.eContainer() != null && x.eContainerFeature() .isMany() you can get the index via ((List<?>)x.eContainer().eGet(x.eContainmentFeature())).indexOf(x) to compute its index within the container's containment feature that contains the object. Note that a move notification has the information about the old and the new index of any moves you might do...
Previous Topic:Generator: Generate Imported-Package Dependency instead of Required Plugin
Next Topic:Hide a password attribute content
Goto Forum:
  


Current Time: Thu Oct 18 23:59:18 GMT 2018

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

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

Back to the top