Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Add New Stereotyped Templates

Sometimes it is useful to define a specific code generation template for use with elements of a given stereotype. This enables different code to be generated for elements, depending on their stereotype. Enterprise Architect provides some default templates, which have been specialized for commonly used stereotypes in supported languages. For example the Operation Body template for C# has been specialized for the property stereotype, so that it automatically generates its constituent get and set methods. Users can override the default stereotyped templates as described in the Override Default Templates topic. Additionally users can define templates for their own stereotypes, as described below.

Access    Tools | Source Code Generation Templates ( Ctrl+Shift+P )

Add a new stereotyped template using the Code Template Editor

Step

Description

See also

1

Select the appropriate language, from the Language list.

 

 

2

Select one of the base templates, from the Templates list.

 

 

3

Click on the Add New Stereotyped Override button.

The New Template Override dialog displays.

 

 

4

Select the required Feature and/or Class stereotype.

Click on the OK button.

 

 

5

The new stereotyped template override displays in Stereotype Overrides list, marked as modified.

 

 

6

Make the required modifications in the Code Templates Editor.

 

 

7

Click on the Save button to store the new stereotyped template in the project file.

Enterprise Architect can now use the stereotyped template, when generating code for elements of that stereotype.

 

 

Notes

·Class and feature stereotypes can be combined to provide a further level of specialization for features; for example, if properties should be generated differently when the Class has a stereotype MyStereotype, then both property and MyStereotype should be specified in the New Template Override dialog