Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Content layer
id502685492
Content column
id502685495
Content block
id502685494

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
titlePrecondition

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:

In the following procedures, we will show you how to create a template with parameters and how to define these parameters. 


Anchor
Template
Template
To create a template


  1. Create or select a template element for which you will create template parameters.
  2. Open the element's Specification window.
  3. Change the property display mode to Allif it is not changed already. The Template Parameters property group appears in the property group list.

  4. Click the Template Parameters property group. 
  5. To add a new template parameter, click the Create button. The Select Template Parameter Type dialog opens. 
  6. In the Model tree, select an existing or create a new type of the template parameter.

    Note
    titleTemplate 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.

  7. 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. 
  8. (Optional) Assign the default value to the created template parameter.

    Tip
    titleMore Information

    For more information about symbol representation properties, see Formatting Symbols.

    Note
    titleValue 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


  1. 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.

  2. Define a template binding parameter substitution. Open the Template Binding Specification window and click the Template Binding Parameter Substitutions property group.
  3. 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.
  4. Select one or more template parameters to add as template parameter substitutions. Click OK to return to the Template Binding Specification window.
  5. (Optional) Assign the actual value for each template binding parameter substitution.

    Tip
    titleMore Information

    For more information about specifying property values, see Editing property values.

    Note
    titleValue 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.



Content block
id502685491

Related pages