Custom Templates

Return to Introduction  Previous page  Next page

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 want to list all of your parameters and their notes in your method notes.

To create a new custom template, follow the steps below:

1.Select the Settings | Code Generation Templates menu option, or press [Ctrl]+[Shift]+[P]. The Code Templates Editor tab opens.
2.In the Language field, click on the drop-down arrow and select the appropriate language.
3.Click on the Add New Custom Template button. The Create New Custom Template dialog displays.
 
CreateNewCustomTemplate
 
4.In the Template Type field, click on the drop-down arrow and select the appropriate element. The elements currently supported are:
·Attribute
·Class
·Operation
·Parameter
5.In the Template Name field, type an appropriate name, then click on the OK button.
6.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 <Element Type>__<Template Name> - for example, Parameter__JavaDoc.
7.Select the appropriate template from the Templates list and edit the contents in the Template field to meet your requirements.
 
CodeTemplateEditor2
 
8.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.