For nested modeling purposes on the Diagram View, an element with the 'Group element' behavior option enabled can be used to group together elements that have the 'Can belong to a group' behavior option enabled. When the group element is moved, all elements belonging to the group are also moved.
Adding Elements to a Group
An element that can belong to a group can be added to a group formed by a group element in the following ways:
|•||By dragging the element that can belong to a group inside a group element.|
|•||By resizing either the group element so that it covers the element that can belong to a group or by resizing the element that can belong to a group so that it is completely inside the group element.|
|•||By creating an element that can belong to a group inside a group element.|
Note that the bounding rectangle of the added element must be completely inside the bounding rectangle of the group element in order for the element to be added to the group.
Element 1 belongs to the Element 2 group since Element 1 is inside the bounding rectangle of Element 2.
Elements in Multiple Groups
An element can belong to multiple groups if:
|•||There are two group elements that are partially on top of each other, and an element that can belong to a group is moved to the overlapping area so that it is completely inside both of the overlapping group elements.|
Element 1 belongs to Group 1 and Group 2 since it is inside both group elements.
|•||The element is inside a group that contains another group.|
Element 1 belongs to Group 1 and Group 2
Removing Elements from a Group
An element can be removed from a group in the following ways:
|•||By dragging the element out of the group element.|
|•||By resizing the group element so that it doesn't cover the element completely anymore.|
|•||If an element belongs to multiple groups (see above), by moving a group element so that an element belonging to the group is moved outside of the other group element.|
Hiding and Showing Group Content
It is possible to hide and show the elements inside a group element instance by either right-clicking the group element and selecting "Hide Group Content" or "Show Group Content" or by opening the Graphical Properties Dialog of the group element and selecting or deselecting the "Hide group contents" check box on the Shape tab. The visibility of the elements can also be set in the diagram View Settings Properties Dialog.
If an element belongs to several groups and at least one of the groups is set to show the contents, the element will be shown.
Note that an element may drop out of the group, if the group element is resized. In addition, if a group is resized so that it covers elements that are hidden in some other group, the hidden elements will be added to the resized group.
When the group element has a relation type custom attributes and those attributes are selected in the Group Relations tab of the element type dialog, all selected relations between the group element and an element that is added to the group are set automatically when the element is added to the group.
If the cardinality of the relation custom attribute is 1 and the relation custom attribute already has a value, the existing value will be updated when an element is added to the group.
For the relation to be set automatically from the added element to the group element, a two-way custom relation attribute must be used.
When an element is moved out of the group, all the relations are cleared, except when an instance of the element still exists inside an instance of the group element or there is a relation connector between the element and the group element.
If the relation is removed manually, the element will still belong to the group. Recreating the relation can be done by moving the element out of the group and then back in the group.
If the relation definition is changed in the group element type dialog, the existing relations are not changed and new relations are not set for elements that already exist in the group.
Group Instance Synchronization
When a group element type has the 'Synchronize group instances' behavior option on and a new instance of the group element is created, instances of the elements belonging to the group will also be created inside the new group instance if the elements belonging to the original group can be instantiated.
Whenever a synchronized group is modified, all other instances of the group are also modified to match the modified group, that is:
|•||If element C is added to group A, an instance of element C is added to every instance of group A.|
|•||If element B is deleted from one instance of group A, it will be automatically deleted from all instances of group A.|
|•||If element B is moved out of an instance of group A, other instances of element B inside other instances of group A will be deleted automatically (note that they are not moved out of the other instances of group A, they are deleted).|
Note that the layout of the group is not synchronized, i.e. if the size of the group or the position of the elements inside the group are changed, these changes are not updated to the other synchronized group instances.