Section 8. Sort elements from a package according to their layout in a diagram
This help article explains how to use eaUtils to sort elements within a package according to their position in a diagram.
This feature runs 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 position in the diagram from top to bottom, or from left to right.
External elements
Process prevented by external elements (default setting)
By default, this sorting feature requires that all elements from the opened 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 and to prevent any unwanted updates. 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 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).
This setting can be changed directly on this screen by clicking on Edit Settings, enabling Ignore external elements in a diagram sorting checkbox, and click on Save Settings.
Example: this setting makes it possible to sort use cases in a diagram that also shows the actors maintained in a separate package, without having to remove actors from this diagram.
Sort elements within a package based on their layout in the selected diagram
Start by saving the diagram (Ctrl + S).
Option 1: default settings
Right click in the active diagram.
Open the menu Specialize > eaUtils > [Diagram] Sort elements (diagram position).
Select the direction (top to bottom or left to right), and confirm that you would like to proceed (click on OK):
Result:
The elements are sorted in the package as illustrated below, matching the position in the diagram:
Note: as illustrated above, elements are grouped by type in the Browser (actors, use cases, classes, etc.). This result can be changed by enabling EA "Free Sorting" Preference (Ctrl+F9), leading to the following result: