Add Stereotypes and Metaclasses using Profile Helpers

Stereotypes defined in a Profile can either extend Core UML objects (Metaclasses) defined by Enterprise Architect, or extend non-UML objects (Stereotypes) defined by other existing profiles and technologies.

Stereotypes can extend Metaclasses in several ways:

One Stereotype extending one Metaclass, for a specific definition of one object type
One Stereotype extending more than one Metaclass, where the definition applies to more than one object type - such as modifying both a Class and an Object in the same way
Several Stereotypes extending one Metaclass, where you are creating several variations of the same base object type; for example, to define types of Association connector, representing Parent, Sibling, Grandparent, Uncle/Aunt and Cousin relationships
 

Add Metaclasses and Stereotypes to a Profile

Step

Description

See also

1

In the Project Browser, locate the package with the <<profile>> stereotype and open its child diagram.

Create UML Profiles using Profile Helpers

 

2

Drag the Add Stereotype icon from the Profile Helpers page of the Diagram Toolbox onto the diagram.

The Add Stereotype dialog displays.

 

 

3

In the Name field, type the stereotype name  (which will also be the name of the new modeling object).

 

 

4

In the Type field, click on the drop-down arrow and select an object group; select from:

Element Extension - to create a stereotype that extends an element
Connector Extension - to create a stereotype that extends a connector
Abstract Metaclass - to create a stereotype that extends a structural or behavioral modifier
Metaclass Extension - to create a stereotype that extends a Metaclass that already exists within your model (and most likely within the diagram you are currently working in)

 

 

5

Click on the Add Metaclass button.  The Extend Metaclass dialog displays, showing a list of object types within the object group selected in step 4. Select the Metaclass to be extended from the list and click on the OK button.

If you selected Metaclass Extension in step 4, the Select a Profile Element browser/search dialog displays; search for and select the existing Metaclass element to extend with this Stereotype.

The Metaclass name is added to the Extensions field.

If you are extending a non-UML object defined by another existing profile or technology, do not specify any extensions at this time.

 

 

 

 

 

 

Create Stereotypes Extending non-UML Objects

6

If you want to extend more than one Metaclass with the Stereotype, click on the Add Metaclass button again and select the next object type to extend. You can repeat this for as many Metaclasses as you want to extend with this Stereotype.

Conversely, if you want to delete a selected Metaclass from the Extensions list, click on the Metaclass  name and click on the Remove button. The Metaclass name is immediately removed from the list.

 

 

7

Review the available Properties in the Stereotype panel.  These properties modify the behaviour of the stereotype.  To apply a property, click in the Value field and type or select the appropriate value.

When selecting a property field, a description of the property's effect will be displayed at the bottom of the Stereotype panel.

Do not provide values for any properties that you do not want to apply to this Stereotype.

 

 

8

Click on the name of a Metaclass in the Extensions field and review the available properties in the Metaclass panel.  These properties further modify the behaviour of the stereotype based on options specific to the Metaclass being extended.  To apply a property, click in the Value field and type or select the appropriate value.

When selecting a property field, a description of the property's effect will be displayed at the bottom of the Metaclass panel.

Do not provide values for any properties that you do not want to apply to this Stereotype.

If you are extending more than one Metaclass, click on the next Metaclass name in the Extensions field and review the properties for that object type.

 

 

9

Click on the Next button. The Define Tagged Values page displays.

 

 

10

Right-click in the Property panel. A context menu displays, listing options for creating and grouping Tagged Values of different types:

Add Tagged Value: Create a simple Tagged Value - a prompt displays for the Tagged Value name, and when you provide this and click on the OK button, the name displays in the Property column; if you want to set a default value, type it in to the Default Value field
Add Specialized Tagged Value :
Enumeration: create an enumeration Tagged Value, based on an existing Enumeration element
Predefined: select a Predefined Tagged Value Type from a list and, in the Default Value field, type or select an initial value if necessary
Structured: create a Structured Tagged Value composed of several other Tagged Values, typed by an existing Class element
Reference: create a Tagged Value that the user can use to locate and reference an element created with a specified stereotype (a form of RefGUID Tagged Value); in creating this, you need to select the existing Stereotype element that defines the stereotype
Reference List: create a Tagged Value that the user can use to locate and reference a list of elements created with a specified stereotype (a form of RefGUIDList Tagged Value); in creating this, you need to select an existing Stereotype element that defines the stereotype
 
Edit Tagged Value Name: displays a simple prompt in which you overtype the current name to correct or change it
Create Tag Group: create Tag Groups in the Metaclass element, through which to organize the Tagged Values you have created in the Stereotype element
Move Tag to Group (displayed when you right-click on an existing Tagged Value): displays the Move Tag to Group dialog, on which you can select an existing Tag Group to contain the selected Tagged Value
Remove Grouping: remove the selected Tag Group, leaving its member Tagged Values listed at the end of the Property column
Delete: Remove the selected Tagged Value from the list and from the Stereotype
 

 

 

 

 

 

Add an Enumeration to a Stereotype

Create Tagged Value Type from Predefined Types

Add a Structured Tagged Value to a Stereotype

RefGUID Tagged Value

 

 

RefGUIDList Tagged Value

 

 

 

 

Define Tag Groupings

 

11

Click on the Next button. The Define a Shape Script page displays.

If you want to create a Shape Script to define the appearance of each model object created from the stereotype, click on the Edit button.

The Shape Editor window displays. Write your Shape Script using this editor.

When you have finished creating the Script, click on the OK button to return to the Define a Shape Script page. The image defined by the Shape Script is shown in the Preview panel. This shape will be applied to every modeling object created with this stereotype.

For this attribute to take effect, you need to check the Alternate Image option when you save the Profile.

Alternatively, you can define a simple default appearance (background color, line color) for the model object, after you have created the Stereotype element.

 

Shape Scripts

 
 

Shape Editor

 

12

Click on the Finish button. The dialog closes; the Stereotype element and Metaclass element(s) you have generated are displayed on the Profile Diagram.

 

 

13

You can now:

Repeat steps 2 to 12 for each of the other Stereotype elements you want to create
Edit the Stereotype (and through it, the Metaclass) element properties you defined above, using the Profile Helper
Add Constraints to your Stereotype element:
(If you are not setting the object's appearance using a Shape Script) Define the simple default appearance of the object
Set up the Quick Linker definitions for the stereotyped elements and connectors in the Profile
 

 

 

Edit a Stereotype Element

Define Stereotype Constraints

Set Default Appearance

Quick Linker

 

Notes

If you intend to extend a large number of model elements, rather than putting all of them on one diagram you can create additional child Class diagrams under the <<profile>> package and add different types of Metaclass elements to different diagrams; in this case you save the package as the Profile, not the individual diagrams
Stereotype elements must have unique names, but Metaclass elements can have the same name (for example, there can be several Action Metaclasses, each with a different ActionKind attribute)
If you have a number of Tagged Values in the Stereotype element, and you have assigned them to groups, you can define which of those groups default to expanded (open) in the Tagged Values window, and which default to closed; open the Attributes dialog for the metaclass and add the attribute _tagGroupStates with the initial value <groupname>=closed;<groupname>=closed;<groupname>=open;...

Learn more