eaUtils

Utilities add-in for Sparx Systems Enterprise Architect

Section 7. Sort elements from a package according to their layout in a diagram

sort elements by their layout order in the diagram

This help article explains how to use eaUtils sort elements within a package according to their order or position in a selected diagram.

This feature runs from a diagram selected from the Project Browser.

Caution - important! this feature runs on the selected diagram from the Project Browser, hence a right click > eaUtils > Sort by... in a displayed diagram will not act on this diagram if it isn't selected in the project browser. Prior to run this feature, right click in the diagram > select Find in Project Browser so the diagram is selected in the browser.

Example

The following diagram shows various elements defined in the same package. The current feature can be illustrated by sorting elements according to their layout order from top to bottom, or from left to right.

eautils sorting example

External elements

External elements prevent this process (default setting)

By default, this sorting feature requires that all elements from the selected diagram belong to the same package so that only elements from a single package are sorted. If any external element is found, the following error message is displayed:

sort elements by diagram order in sparx enterprise architect project browser

This constraint has been applied to keep this feature simple, hence preventing any unplanned change to be committed in the modelling project. The following arguments also support this:

  • It makes sense to order only elements from the same context i.e. a package.
  • The locking control would be impacted and become overcomplicated.

Note: a specific diagram may have to be created solely to fit the purpose of sorting elements based on their layout (a diagram can be copied and all external elements removed).

External elements can be ignored

However, eaUtils settings let you update this rule so that external elements are ignored (see eaUtils Settings help). To achieve this, enable the "Ignore external elements in a diagram sorting" Sort By setting.

Example: when sorting a use case diagram that has actors maintained in a separate package, this setting makes it possible to sort use cases that belong to the current package, without having to remove actors from the diagram.

Sort elements within a package based on their layout in the selected diagram

Start by saving the diagram if you modified it.

Option 1: default settings

Select the diagram from the Project Browser and right click onto it (alternative: select the diagram from the Project Browser and right click from an empty zone on this diagram).

Open the menu Extensions > eaUtils > Sort elements in the Project Browser by their order in this diagram (top to bottom) (or select left to right)

sort elements by diagram layout from top to bottom

Confirm that you would like to proceed in the following dialog window:

eautils sort by diagram order in sparx enterprise architect addin

Note that the setting "Identify and sort integers within string values" is enabled by default. Important : this setting applies when elements with the same name are aligned on the same position. For instance if ELT1, EL02, and ELT10 are top aligned, the top to bottom sorting feature will produce the following order: ELT1, ELT02, ELT10. Whereas when this setting is disabled, the following order will be produced: ELT02, ELT1, ELT10. This case is illustrated below when sorting elements from top to bottom (see "Requirement9).

Name
Actor1
Actor2
Actor3
Actor4
ActorA
ActorB
ActorC
Use Case0
Use Case1
Use Case2
Use Case3
Class3
Class2
Class4
Class1
Interface1
Interface2
Interface3
Requirement9
Requirement1
Requirement2
Requirement3
Requirement5
Requirement6
Requirement7
Requirement8
Requirement09
Requirement4
Requirement9
Requirement10
Requirement11
Requirement12
Requirement12

Once confirmed, the elements are sorted in the package as illustrated below, matching the above expected results:

eautils sort by diagram order top to bottom sparx ea project browser result

Option 2: "Identify and sort integers within string values" setting disabled

When the option "Identify and sort integers within string values" is disabled in eaUtils settings, there is no attempt to extract integer values and sort them accordingly. Based on the previous data set, this option will impact Requirement9 which is top aligned with Requirement10, Requirement11 and Requirement12:

  • Requirement9 is sorted at the end of the list, whereas it was located before Requirement10/11/12 with the default setting.

The expected result is illustrated below.

Name
Actor1
Actor2
Actor3
Actor4
ActorA
ActorB
ActorC
Use Case0
Use Case1
Use Case2
Use Case3
Class3
Class2
Class4
Class1
Interface1
Interface2
Interface3
Requirement9
Requirement1
Requirement2
Requirement3
Requirement5
Requirement6
Requirement7
Requirement8
Requirement09
Requirement4
Requirement10
Requirement11
Requirement12
Requirement12
Requirement9

 

Last modified on Tuesday, 28 March 2017 14:26