Book a Demo

Author Topic: Adding to Collections  (Read 5980 times)

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Adding to Collections
« on: August 22, 2009, 12:03:13 am »
Hi All

In the Object Model Collections (obtained via an Element property) are read only. However new items can be added by using the method AddNew.

When the Collection is refreshed, then the elements in the collection appear to sorted alphabetically by name. (This is also true using the EA GUI interface)

On the EA GUI interface there are Up Hand and Down Hand icons which you can use to modifiy the order of items in a Collection (for example changing the order of scenarios by name rather than alphabetcial)

Can this re-ordering of Collections be achived in the Object model for Add-Ins. If so how?

Models are great!
Correct models are even greater!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding to Collections
« Reply #1 on: August 22, 2009, 03:31:43 am »
What exactly are you trying to achieve?
Re-order the the elements in the collection to use them in your program, or reorder the elements so that they have a different order in the project browser?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Adding to Collections
« Reply #2 on: August 22, 2009, 03:34:25 am »
It depends on the collection involved. Many classes in the API have a Pos or Position attribute. Setting these (for all members of the collection) usually affects the order that members appear in. Note that EA does not consistently set these to any value, but seems to handle them correct when they are set (by EA or externally).

Also check the Tools | Options | General dialog. Make sure that the Allow Free Sorting box is checked (in the Project Browser group). This is a global setting which EA will thereafter remember.
No, you can't have it!

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Adding to Collections
« Reply #3 on: August 31, 2009, 10:11:48 pm »
Hi All

Time for an update.

What I was trying to do is this. I have an add-in that integrates EA with an external editor which maintains the textual part of use case scenarios.

I needed to preserve the order of the scenarios (as displayed in the Use Case Scenario Tab) between EA and this tool, so when the text steps have been modified externally the changes are then incorporated back into EA. The order of the Scenarios in the Scenarios tab of a Use Case element is not necessarily the same as the order of the Scenarios in the Scenarios collection. (I have confirmed this).

To access the position as displayed in the Scenarios tab, the Weight property of a Scenario element is used. (This is actually in the Use Guide, but I missed it on first reading).

Problem solved.

Models are great!
Correct models are even greater!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Adding to Collections
« Reply #4 on: September 01, 2009, 01:45:55 am »
Wow, that's a new twist. [Yes, I agree with you Paolo...]

Good eye Phil!
No, you can't have it!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Adding to Collections
« Reply #5 on: September 01, 2009, 11:11:34 am »
Quote
Wow, that's a new twist. [Yes, I agree with you Paolo...]

Good eye Phil!
Yes, you beat me to it,David!

But then I WAS asleep...  ;)

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Adding to Collections
« Reply #6 on: September 01, 2009, 09:13:23 pm »
No surprise there.

Sleeping all day. Standing around upside down. Christmas in the middle of Summer. It's no wonder you miss these things...

And don't give me the usual "But that's where Perth is" excuse. Perth is right where it's supposed to be, about 80 km West of here. Lovely place too; about 6000 lucky souls call it home.

Or perhaps you mean the big Perth. That would have to be the county west of Toronto rather than the town. [Why the town is nowhere near the county is anyone's guess...] Now that's a different matter. Great tracts of prime farmland, lots of lovely towns to visit. And of course the city of Stratford - at least geographically, if not politically.

Asleep indeed!
No, you can't have it!