Author Topic: Setting the tree position on elements  (Read 6078 times)

Paul Krcma

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Setting the tree position on elements
« on: January 24, 2012, 09:12:35 am »
Are there any automated interface examples on how to add embedded elements to an element and set the tree position on the embedded element? EA version 8.0.

I'm using the API to create new elements, and some elements have embedded elements, and EA is putting them in alphabetical order. I wish to have the elements appear in the browser in the order in which they were created.

Thanks,
Paul Krcma

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting the tree position on elements
« Reply #1 on: January 24, 2012, 05:42:28 pm »
Use Element.TreePos and make sure you allow free sorting in the General Options.

Geert

Paul Krcma

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Setting the tree position on elements
« Reply #2 on: January 25, 2012, 03:22:18 am »
Thanks for the tip on the Allow Free Sorting, Geert.
I've activated the Free Sorting.  Then, for an example, I create new elements, update the element, set TreePos = 1, update the element, refresh the package. I would expect the last element to be added, be the first in the tree view. But instead, it's the tree as the alphabetic order.

I must be missing something.

-Paul

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Setting the tree position on elements
« Reply #3 on: January 25, 2012, 04:15:11 am »
You have to additionally refresh some stuff. I never remember which where and when. Try a manual reload of the model to see whether the order had changed.

q.

Sunil Sah

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Setting the tree position on elements
« Reply #4 on: January 30, 2012, 10:45:28 pm »
The following steps worked for me when creating and ordering elements with API:

EA.Package.TreePos = ...;
EA.Package.Update();
EA.Repository.RefreshModelView(...);

Then I could use created elements to generate RTF documentation with elements in the right order.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Setting the tree position on elements
« Reply #5 on: January 31, 2012, 08:48:40 am »
Also worth checking the TPos values for all other elements owned by the same package. They get cleared by the "Contents > Reset Sort Order" command so you may find they all need to be set.
« Last Edit: January 31, 2012, 08:59:21 am by KP »
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Setting the tree position on elements
« Reply #6 on: January 31, 2012, 06:41:53 pm »
Quote
Also worth checking the TPos values for all other elements owned by the same package. They get cleared by the "Contents > Reset Sort Order" command so you may find they all need to be set.
You must be kidding! Switching an option will clobber the whole database structure? I mean the order which might potentially been set for many elements is wiped out when a single user switches that option???? Please tell me that's not the case.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting the tree position on elements
« Reply #7 on: January 31, 2012, 07:01:54 pm »
q.

Its not really an option (as in Tools|Options) but a context dependent action (right click on package).
It might potentially cause havoc, but it's not as bad as you thought.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Setting the tree position on elements
« Reply #8 on: February 01, 2012, 12:20:04 am »
There's also a global option "Sort features alphabetically". I thought Neil was talking about that option. I wasn't aware of that context specific one.

q.
« Last Edit: February 01, 2012, 12:26:24 am by qwerty »