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.
To create a new custom template, follow the steps below:
- Select the Settings | Code Generation Templates menu option, or press [Ctrl]+[Shift]+[P]. The Code Templates Editor tab opens.
- In the Language field, click on the drop-down arrow and select the appropriate language.
- Click on the Add New Custom Template button. The Create New Custom Template dialog displays.
- In the Template Type field, click on the drop-down arrow and select the appropriate element. The elements currently supported are:
- Class Base
- Class Interface
- Class Parameter
- Linked Attribute
- Linked Class Base
- Linked Class Interface
<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.
- In the Template Name field, type an appropriate name, then click on the OK button.
- 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>.
- Select the appropriate template from the Templates list and edit the contents in the Template field to meet your requirements.
- 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.