Customization > Extensibility Through Profiles, Stereotypes, Tag Definitions and Scripts > Advanced extensibility through stereotype scripts and script items > Extending diagram toolbars through stereotypes and scripts > Creating a toolbar button through a stereotype
  
Creating a toolbar button through a stereotype
Typically, you will want to create Stereotypes within a profile Package.
This topic documents creating a Stereotype through the Packages pane. For information about using a Profile Diagram to create a Stereotype, specify valid model item types and define Scripts, see Overview of profile diagrams.
To create a toolbar button through a stereotype:
1. Right-click the profile Package, point to New, point to UML, point to Profiles, and then click Stereotype.
2. Type a name for the Stereotype, and then press the Enter key.
If you want the display name of the Stereotype in Modeler to be different from its real name: on the General tab of the Stereotype's property pages, type the display name in the Name Alias box.
3. Open the Stereotype's Property Pages, and select valid diagram types for the Stereotype (the Stereotype can be applied only to diagrams whose type is valid):
a. Click the Items tab.
b. In the drop-down list box select Model Item Types, and then click the Link button.
c. In the middle or right pane, select the check boxes associated with valid diagram types.
d. In the middle or right pane, clear the check boxes associated with invalid diagram types.
e. Click
OK.
4. Click the Toolbar tab, and then click the New Item button.
5. Ensure that the new entry is selected, and then click the selected cell in the Diagram Toolbar Command column.
6. Select the diagram toolbar button on which you want to base the new customized toolbar button.
A diagram button is valid only for the diagram type it specifies. Toolbar buttons that do not include a diagram name are valid for all diagram types.
If you want only to add a standard toolbar button to a customized diagram toolbar, you can ignore the steps that follow.
7. If you want the customized toolbar button to be part of a group of toolbar buttons (split button), such as, the Dependency buttons on the Class Diagram toolbar.
a. Ensure that the new entry is selected, and then click the selected cell in the Group ID column.
b. Type the value of the group.
All toolbar buttons that appear on the toolbar and have the same group value will appear as buttons of the same split button.
8. Specify the text you want to appear as a ToolTip when you rest the mouse pointer over the button:
a. Ensure that the new entry is selected, and then click the selected cell in the ToolTip column.
b. Type the text you want to appear as a ToolTip.
If you want to use the ToolTip text of the toolbar button on which the customized toolbar button is based, leave the ToolTip box blank.
9. Specify the text you want to appear in the status bar when you rest the mouse pointer over the button:
a. Ensure that the entry is selected, and then click the selected cell in the Status Bar Text column.
b. Type the text you want to appear in the status bar.
If you want to use the status bar text of the toolbar button on which the customized toolbar button is based, leave the Status Bar Text box blank.
10. If you want a separator to the left of the customized toolbar button:
a. Ensure that the new entry is selected, and then click the Separator Before column.
b. Set the Separator Before property to Yes.
11. If you want the customized toolbar button to use a different icon to that of the toolbar button on which it is based, click the Select Icon button, and then select the icon you want to use.
12. Specify the script, which is run after the item has been added to a diagram:
a. Ensure that the new entry is selected, and then click the Edit Script button.
b. Type the script, click the Save button, and then close the window.
Write the script within the available functions for a Diagram Toolbar Command script. For more information about working with scripts, see:
Script functions, attributes and objects - diagram toolbar button script for adding links
Script functions, attributes and objects - diagram toolbar button script for adding nodes
Script functions, attributes and objects - overview
Script template for diagram toolbar button scripts for links
Script template for diagram toolbar button scripts for nodes
The customized toolbar button will be used by any diagram that is stereotyped directly by the Stereotype.