Section 8. Sort elements from a package according to their layout in a 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 on a diagram selected from the Project Browser or from the active diagram.
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.
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:
This constraint has been applied to keep this feature simple, hence preventing any unwanted update. 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 can 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 following 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
Right click in the active diagram.
Open the menu Specialize or Extensions > eaUtils > [Diagram] Sort elements by their order.
Select the direction and confirm that you would like to proceed in the following dialog window:
Result:
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:
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 |