Book a Demo

Author Topic: How to group elements in the Project Browser?  (Read 2960 times)

palim

  • EA User
  • **
  • Posts: 31
  • Karma: +1/-0
    • View Profile
How to group elements in the Project Browser?
« on: March 04, 2010, 02:47:39 am »
Hello guys,

I`m importing requirements via a MS-Excel macro into EA.
Momentarily, every element is being imported into one package.

However, I`ve seen that elements can be grouped under an element.

Example:
There is an element "req1 - parent".
Also, there are elements named "req1 - sibling A", "req1- sibling B", and so forth.
On the Project Browser, it is possible to select "req1 - sibling A", "req1 - sibling B" and draw it under "req1- parent".
After that, the "plus" icon appears.

Is there any way to do this programmatically?

I checked the element`s reference and there is a method called "IsLeaf()". Can this be used for that?
Does anybody have a small code snippet?

Best regards,
palim

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: How to group elements in the Project Browser?
« Reply #1 on: March 04, 2010, 09:30:24 am »
Quote
Is there any way to do this programmatically?

Set the Element.ParentID value of "req1 - sibling A" to the Element.ElementID value of "req1 - parent".
The Sparx Team
[email protected]

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: How to group elements in the Project Browser?
« Reply #2 on: March 04, 2010, 09:47:51 am »
As KP said - To nest an existing element under another existing element, assign the ID of the parent element to Element.ParentID of the child.  NOTE: both elements should already be in the same package.  If not, you might also need to set the PackageID.

To browse items that are nested under the current context, you can use the Element.Elements collection.

E.g.
Code: [Select]
Requirement2.ParentID = Requirement1.ElementID
Requirement2.Update
Requirement1.Elements.Refresh
' Should now be able to access Requirement2 within the Elements collection of Requirement1.

palim

  • EA User
  • **
  • Posts: 31
  • Karma: +1/-0
    • View Profile
Re: How to group elements in the Project Browser?
« Reply #3 on: March 05, 2010, 01:12:51 am »
Hello KP and Aaron B,

it`s working.
Thank you very much :-)


Best regards,
palim