This section demonstrates how to create a template and how to use it.
Follow these instructions from the first step consistently. If you do not, and if you do not define the template parameter, you will not be able to draw a template binding relationship. You can omit optional procedures only.
Info
title
Precondition
Let’s assume you already have an element to which you want to apply a template. This element is an actual element. The actual element can be a classifier, package, or operation.
To create and apply a template to an actual element, see the following procedures:
Change the property display mode to All, if it is not changed already. The Template Parameters property group appears in the property group list.
Click the Template Parameters property group.
To add a new template parameter, click the Create button. The Select Template Parameter Type dialog opens.
In the Model tree, select an existing or create a new type of the template parameter.
Note
title
Template Parameter
If you do not want to specify the concrete template parameter type, you can select the Class type (the Class from the UML metamodel). When the Class type is specified, type is not displayed on the diagram pane. Only the name of the template parameter is represented.
If you need to select one of the UML metamodel elements, such as Class, be sure to clear the Hide Uncommon Elements and Exclude Used Projects commands (as in the preceding figure). For more information, read Searching for elements in the Element Selection dialog.
Click OK. The template parameter is created. The name of the template parameter is defined automatically by compounding the T letter and the name of the template parameter type - T<type name>. For example, TInteger. You can change the name of the template parameter if you need to.
(Optional) Assign the default value to the created template parameter.
Tip
title
More Information
For more information about symbol representation properties, see Formatting Symbols.
Note
title
Value Specification
To assign a particular value of the value specification, you must specify a Value Specification first and then type its particular value in the Actual value cell. For more information about Value Specification, read Value Specification.
After the template is created, you can apply it to the actual element. The following procedures describe how to apply the template to the actual element.
Anchor
Apply
Apply
To apply a template to an actual element
Bind the actual element to the template element. In the diagram palette, click the Template Binding button or click the B shortcut key and draw a template binding relationship from the actual element to the template element.
Note
If the Template Binding button is not visible, change the the modeling tool's perspective to Full Featured or Software Architect. See the Customizing and Selecting Perspective page on how to change the perspective.
Define a template binding parameter substitution. Open the Template Binding Specification window and click the Template Binding Parameter Substitutions property group.
To add a new template binding parameter substitution, click the Create button. The Select Template Parameter dialog opens, listing the template parameters of the element to which the template binding relationship is connected.
Select one or more template parameters to add as template parameter substitutions. Click OK to return to the Template Binding Specification window.
(Optional) Assign the actual value for each template binding parameter substitution.
To assign a particular value of the value specification, you must specify a Value Specification first and then type its particular value in the Actual value cell. For more information about Value Specification, read Value Specification.