Customization > Extensibility Through Profiles, Stereotypes, Tag Definitions and Scripts > Advanced extensibility through stereotype scripts and script items > Extending diagram toolbars through stereotypes and scripts > Overview of extending diagram toolbars through stereotypes and scripts
  
Overview of extending diagram toolbars through stereotypes and scripts
Modeler displays a diagram specific toolbar for each diagram type. You can add customized toolbar buttons to a diagram's toolbar, or replace all the buttons of a diagram's toolbar with customized buttons. A customized toolbar button adds an item to a diagram, and then optionally runs a script.
You can create customized toolbar buttons through Stereotypes and Script items:
When created through Stereotypes:
The customized toolbar button appears on a diagram toolbar only when the Stereotype is applied to the diagram.
The standard buttons of the diagram toolbar can be replaced by the customized toolbar buttons that apply to the diagram, or you can add customized toolbar buttons to the standard buttons of the diagram toolbar. If you replace the standard toolbar buttons, you can recreate them as customized toolbar buttons.
* 
The 'Apply to All Objects of Associated Model Item Types' option does not apply a Stereotype's toolbar buttons to any diagrams. A Stereotype can create many customized toolbar buttons.
When created through Script items:
The customized toolbar button appears on the diagram toolbar of all diagrams that are of a valid type.
The customized toolbar buttons are added to the standard buttons of a diagram toolbar.
* 
A Script can create only one customized toolbar button.
Each customized toolbar button is based on an existing diagram toolbar button, the generic Custom Node button or the generic Custom Link button. For more information about the generic Custom Node or Custom Link buttons, see the Generic Custom Node and Custom Link Buttons section that follows.
Through the Diagram Toolbar Command property, you select the toolbar button on which a customized toolbar button is based. The toolbar button you select through the Diagram Toolbar Command property must be valid for the diagram type that is going to use the customized toolbar button. For example, if you are creating a customized toolbar button for a Class Diagram, you cannot base that button on a Composite Structure Diagram toolbar button, it must be based on a Class Diagram button. Note that buttons that do not include a diagram name are valid for all diagram types.
If after selecting a toolbar button through the Diagram Toolbar Command property you make no further changes to the customized toolbar button, the appearance and behavior of the customized toolbar button will be that of the button on which it is based; this is how you add standard toolbar buttons to a customized diagram toolbar.
You can change the appearance and behavior of a customized toolbar button through these properties:
Command Icon - specifies the icon that appears on the button.
ToolTip Text - specifies the text of the ToolTip that is displayed for the button.
Status Bar Text - specifies the text that is displayed in the Modeler status bar for the button
Script - specifies the script that Modeler runs after an item is added to a diagram through the button. The item that is added to the diagram is passed to the script as the current object. The script can use the Modeler automation interface to perform numerous tasks, such as, applying a Stereotype to the new item. For more information, see the following topics:
Script functions, attributes and objects — diagram toolbar scripts for adding links
Script functions, attributes and objects — diagram toolbar 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
Additive - specifies that the customized toolbar button is added to the standard buttons of a diagram toolbar, rather than replacing all the standard buttons of the diagram toolbar. Additive is available only for Script items, not Stereotypes.
Group - specifies whether the button is a standalone button or part of a group of buttons on the diagram toolbar.
Separator Before — specifies that a separator appears to the left of the button.
Stereotype applied buttons are displayed first, followed by Script applied buttons.
For customized toolbar buttons that are created through Stereotypes, you can control the order in which customized toolbar buttons are displayed in the toolbar. You can determine which Stereotype's buttons are displayed first through the order of the Stereotypes on the Items tab of the diagram's Property Pages. You can determine the order in which a Stereotype's buttons are displayed through the order of the toolbar command entries on the Toolbar tab of the Stereotype's Property Pages.
For customized toolbar buttons that are created through Scripts, you can control the order in which they appear through the Category and Command properties.
Generic custom node and custom link buttons
The generic Custom Node and Custom Link buttons can be used for adding nodes and links to a diagram. In addition, you can use the Custom Node button for running any script against an item on a diagram, for example, to set property values of an item on the diagram.
The Custom Node button assumes one item on the diagram is clicked; the Custom Link button assumes two items on the diagram are clicked.
The Custom Node and Custom Link buttons do not appear on any diagram toolbars and do not have any built in Modeler functionality. If you use these toolbar buttons you must write script to deal with all the behavior of the button. For example:
Script for any user interface required for selecting an item within the SelectObject function.
Script to deal with a right-click on the diagram after clicking the toolbar button.
Script to deal with any required validity checks.
Script to create the symbol on the diagram and return that symbol through the AddedSymbol script property.
Script to link the symbol to the diagram and its dictionary item, which the script might have to create if one is not selected.
The following script attributes and script objects can be used with the Custom Node and Custom Link toolbar buttons:
AddedSymbol script object
SelectedDictionaryItem script object
PasteAtX script attribute
PasteAtY script attribute
ReverseWaypoints script attribute (Custom Link only)
Note that the Custom Node and Custom Link buttons do not have icons assigned to their button.
For more information about the preceding script attributes and script objects, including within which script functions they can be used, see the following topics:
Script functions, attributes and objects — diagram toolbar scripts for adding links
Script functions, attributes and objects — diagram toolbar scripts for adding nodes