Custom Templates

Custom templates enable you to generate an element in many different ways. Enterprise Architect enables you to define custom templates that are associated with given elements and call these templates from existing templates. You can even add stereotype overrides to your custom templates. For example, you might list all of your parameters and their notes in your method notes.

Access    Settings | Code Generation Templates ( Ctrl+Shift+P )

How to

To create a new custom template using the Code Templates Editor

Step

Description

See also

1

In the Language field, click on the drop-down arrow and select the appropriate language.

 

 

2

Click on the Add New Custom Template button.

The Create New Custom Template dialog displays.

 

 

3

In the Template Type field, click on the drop-down arrow and select the appropriate element.

The elements currently supported are:

Attribute
Class
Class Base
Class Interface
Class Parameter
Connector
Import
Linked Attribute
Linked Class Base
Linked Class Interface
Namespace
Operation
Parameter
 

<None> requires special treatment; it enables the definition of a function macro that doesn't actually apply to any of the types, but must be called as a function to define variables $parameter1, $parameter2 and so on for each value passed in.

 

 

4

In the Template Name field, type an appropriate name.

Click on the OK button.

 

 

5

On the Code Templates Editor tab, the new template displays in the Templates list with the value Yes in the Modified field.

The template is called <Template Type>_<Template Name>.

 

 

6

Select the appropriate template from the Templates list and edit the contents in the Template field to meet your requirements.

 

 

7

Click on the Save button.

This stores the new stereotyped template in the .EAP file. The template is now available from the list of templates and via direct substitution for use.