Creating Relationship Creation dialog
See the following procedures for custom Relationship Creation dialog and submenu creation.
Updating the Relationship Creation dialog/submenu
Once you have created the new Relationship Creation dialog/submenu, activate it via the (2026x Refresh1) Activating Relationship Creation dialog.
The default name for the Relationship Creation dialog's invocation command is Create Relation. If you create a dialog from scratch and do not set a new name for the command, the default name remains.
Creating a custom Relationship Creation dialog/submenu
To create a custom Relationship Creation dialog/submenu
- In the Containment tree, create a new root namespace.
- Open the Textual Editor for the new namespace.
- In the Textual Editor, create a package and name it.
- Within the body of the package, declare a part definition, specify the name for the dialog instance, subclassify the RelationshipCreationDialog definition from the DS_UIComponents::CoreUIComponents::Dialogs package, then, within the body of the definition:
- Click the Synchronize button.
package CustomRelationshipCreationDialogs {
part def CustomRelationshipCreationDialog :> DS_UIComponents::CoreUIComponents::Dialogs::RelationshipCreationDialog { // naming the new dialog instance and subclassifying the RelationshipCreationDialog
}
}
Managing the Relationship Creation dialog/submenu command categories
Creating relationship creation command categories for the Relationship Creation dialog/submenu
To create relationship creation command categories for the Relationship Creation dialog/submenu
- Within the body of the part definition element of the new Relationship Creation dialog instance, do the following:
- Create a category for outgoing relations:
- Declare a part usage, name it, then subset the itemCategories element.
- Subsetting the itemCategories element instantiates a category for outgoing relations, because the inherited isIncoming attribute is undefined. You can reverse it to incoming relations by setting the isIncoming attribute to true.
- It is not necessary to have both Outgoing and Incoming categories, as they perform the same function but in opposite directions. You may choose to have only one category.
- Declare a part usage, name it, then subset the itemCategories element.
- Create a category for incoming relations:
- Declare another part usage, name it (optional), then subset the part usage for the outgoing category. In its body, redefine the isIncoming attribute, setting it to true.
- Click the Synchronize button.
package CustomRelationshipCreationDialogs {
part def CustomRelationshipCreationDialog :> DS_UIComponents::CoreUIComponents::Dialogs::RelationshipCreationDialog {
part customSourceRelationshipsCategory :> itemCategories { // adding a command category for outgoing relations
attribute :>> isIncoming default false; // may be omitted since the inherited attribute's default value is undefined, resulting in outgoing direction
}
part customTargetRelationshipsCategory :> itemCategories { // adding a command category for incoming relations
attribute :>> isIncoming default true;
}
}
}
Specifying the relationship creation command category attributes for the Relationship Creation dialog/submenu
To specify the relationship creation command category attributes for the Relationship Creation dialog/submenu
- Place the cursor within the body of the new command category's element and redefine the inherited attributes that you want to modify with the needed values.
- Click the Synchronize button.
package CustomRelationshipCreationDialogs {
part def CustomRelationshipCreationDialog :> DS_UIComponents::CoreUIComponents::Dialogs::RelationshipCreationDialog {
part customSourceRelationshipsCategory :> itemCategories {
attribute :>> label default "Source"; // naming the relation creation command category
attribute :>> isCollapsed default false; // modified element creation command category default collapse state
// the isIncoming attribute is undefined, setting the category's commands to outgoing relations
}
part customTargetRelationshipsCategory :> itemCategories {
attribute :>> label default "Target"; // naming the relation creation command category
attribute :>> isIncoming default true; // setting the category's commands to incoming relations
}
}
}
Managing the Relationship Creation dialog/submenu commands
You can customize the Relationship Creation dialog/submenu content by specifying which relationship creation commands it should contain. The relationship creation commands are created by targeting one of the following:
- predefined relation metaclass. All predefined SysML v2 relations that already exist in the tool can be targeted via the OperationByMetaclass, targeting the relation's metaclass.
- custom relation template. Any custom-created relations can be targeted via the OperationFromTemplate, targeting the corresponding custom-created relation templates. For creating custom relation templates, see the Creating relationship templates for custom templated relationship creation commands procedure.
Adding relationship creation commands to the Relationship Creation dialog/submenu command categories
To add relationship creation commands to the Relationship Creation dialog/submenu command categories
- Within the body of the command category's element, declare a part usage defined by DS_UIComponents::CoreUIComponents::Dialogs::DialogItem and subset abstractItems. This element instantiates the new command.
- For creating a relation creation command for a metamodel-defined relation:
- Within the body of the new command's instance, declare a perform action usage defined by DS_UIComponents::CoreUIComponents::Operations::OperationByMetaclass and redefine operation. In the element's body, specify the in direction based on the relation you want to use for the command using a metadata access expression.
- For creating a relation creation command for a custom relation:
- Within the body of the new command's instance, specify the command's name by redefining the label attribute and specifying the command's name.
- Ensure a template for the custom relation is created. See the Creating relationship templates for custom templated relationship creation commands procedure.
- Within the body of the new command's instance, declare a perform action usage defined by DS_UIComponents::CoreUIComponents::Operations::OperationFromTemplate and redefine operation. In the element's body, specify the in direction based on the relation template you want to use for the command using a metaclassification expression.
- Click the Synchronize button.
package CustomRelationshipCreationDialogs {
part def CustomRelationshipCreationDialog :> DS_UIComponents::CoreUIComponents::Dialogs::RelationshipCreationDialog {
part customSourceRelationshipsCategory :> itemCategories {
attribute :>> label default "Source";
attribute :>> isCollapsed default false;
attribute :>> hasVisibleLabels default true;
// relation creation command targeting a metamodel-defined relation via its metaclass:
part interfaceUsageItem : DS_UIComponents::CoreUIComponents::Dialogs::DialogItem :> abstractItems {
perform action : DS_UIComponents::CoreUIComponents::Operations::OperationByMetaclass :>> operation { in ref = SysML::Systems::InterfaceUsage.metadata; }
}
// relation creation command targeting a custom relation via its template:
part safetyCriticalConnectionUsageItem : DS_UIComponents::CoreUIComponents::Dialogs::DialogItem :> abstractItems {
attribute :>> label default "safety critical connection";
perform action : DS_UIComponents::CoreUIComponents::Operations::OperationFromTemplate :>> operation { in ref = (safetyCriticalConnectionUsageTemplate meta KerML::Kernel::Package).ownedElement; }
}
}
}
}
Creating relationship templates for custom templated relationship creation commands
To create relationship templates for custom templated relationship creation commands
- Within the body of the new dialog instance's package, create a new package for the custom template.
- Within the package, specify the custom relation.
- Click the Synchronize button.
package CustomRelationshipCreationDialogs {
private import ScalarValues::*;
metadata def SafetyCritical { // the custom element definition
:> annotatedElement : SysML::ConnectionUsage;
attribute criticalityLevel : Integer;
attribute rationale : String;
}
package safetyCriticalConnectionUsageTemplate { // the new template's package, which you will have to target using the OperationFromTemplate to create a relation creation command for the custom element
# SafetyCritical connection;
}
}