Rational Software Corp.

TOC PREV NEXT INDEX



Customizing Rational Rose Menus


Contents

This chapter is organized as follows:


Extending Rational Rose Menus

Using the Rational Rose Extensibility Interface, you may add your own menu options to one of Rose's menus (for example, File and Edit). You can also add your own menu options to the Rose shortcut menu (displayed when you right-click).

This chapter explains how to customize the:


Customizing Rose Main Menus

You can extend or customize Rose menus by updating the Rose menu file, which Rose reads during startup.

You can extend Rose menus by adding:

Note: You can add information to existing menus (for example, File and Edit); however, you cannot add new menus to the Rose menu bar.

The content of Rose menus is defined in the Rose.mnu file. If you want to customize Rose menus, you must edit this file.

While you cannot add new menus to the Rose menu bar, you can add commands to the existing Rose menus.

Use the procedures, commands, and syntax described in this chapter to add Rose menu commands that:

Procedure

The following procedure outlines the general steps for customizing Rose menus.

The subsections following the procedure provide information on command syntax, variables, and modifiers to use as you complete the procedure.

Check the sample menu file at the end of this chapter for a complete example that illustrates how to put the various menu elements together into a working menu file.

1 Using any text editor, open the Rose.mnu file. (The file resides in the directory where Rose is installed.)

2 Add entries to Rose.mnu for any or all of the following:

    Note: Pay close attention to the syntax rules that apply to your entries to the Rose menu file. For example, the syntax of the menu specifications includes opening and closing braces. You must include these braces in your specifications or they will not work properly. For complete details, see Syntax Rules for Rose Menu File Entries.

3 If the menu item executes a script, add or edit Rose's virtual path for scripts, unless one is already defined.

4 Save the file.

Adding Entries to a Rose Menu File

Using any text editor and the following information, you can add menu entries to the Rose menu file. The entries will appear on the Rose menu in the order in which you specify them.

As you add menu entries, you will specify:

Remember to follow all of the syntax rules as described in Syntax Rules for Rose Menu File Entries. For example, the syntax of the menu specifications includes opening and closing braces. You must include these braces in your specifications or they will not work properly. Remember that each opening brace ({) requires a corresponding closing brace (}).

Menu File Keywords

Table 1 describes the valid keywords for your entries in the Rose menu file.

Table 1 Menu File Keywords 
Keyword
Description
Menu RoseMenu
Enter the Menu keyword, followed by the Rose menu name to indicate the name of the menu being extended. For example, enter Menu Tools as the first line of an entry that extends the Tools menu.
Menu "Menu Text"
Enter the Menu keyword, followed by a text string to indicate the name of a submenu being added to the menu. Note that quotation marks are required if the text string contains spaces. For example, enter Menu "My Scripts" to add a submenu called My Scripts.
Separator
Enter the Separator keyword to add a separator to a list of menu options. Remember the placement of the Separator keyword controls the placement of the separator line on the menu.
Option "Command text"
Enter the Option keyword, followed by a text string to indicate the name of the menu command being added to the menu. Note that quotation marks are required if the text string contains spaces. For example, enter Option "Run My Script" to add a menu command called Run My Script.

Menu Actions

An action defines the result of activating a menu entry. The required arguments can be supplied as keywords, constants, variables, or variables with modifiers. Table 2 describes the valid menu actions for your entries in the Rose menu file.

Table 2 Menu Actions 
Action
Result
Block
Displays a modal dialog box with `arg' as its prompt. Used following `exec' and an action such as the Roseload command to suspend the following action until the user chooses to continue.
RoseScript Script-Path-and-Name
Executes a source or compiled image of a script. You can specify the script name without its extension. The Rosescript command will search for the source script first and execute it if found. If not found, it will search for and execute the compiled script.
Exec program-name [arg2 [arg3 ...[arg10]]]
Executes the program or shell script contained in the file designated by program-name. (If the program is not located in the current directory, it must be in a directory in the execute path.) If the final argument is of the form '-F<filename>' then a file named <filename> is created (if it does not already exist). All arguments, except the last one are written to the file, and <filename> is passed as the sole argument to `program'.

Note:


Roseload ControlledUnit
Loads the designated controlled unit(s) from the associated file.
Rosesave ControlledUnit
Saves the designated controlled unit(s) to the associated file.
Updateaccess ControlledUnit
Sets the write protection for the controlled unit(s) to that of their corresponding files.
InterfaceEvent ToolDisplayName interface
Executes the specified interface in the specified add-in's registered COM object. You are not limited to Rose events. You may specify custom interfaces from your OLE server. Note that quotation marks are required if the ToolDisplayName contains spaces. Rose looks for the add-in whose registry key, ToolDisplayName, matches the ToolDisplayName argument. If the ToolDisplayName registry key is blank, Rose then looks for a match to the ToolName registry key. For more information on registry settings for Rose add-ins, see Updating the Registry. Examples:
  • InterfaceEvent C++ OnBrowseHeader

    When the user selects the menu option corresponding to this menu action, Rose executes the OnBrowseHeader method in the add-in's OLE server whose ToolDisplayName (or, if ToolDisplayName is blank, ToolName) registry key is "C++".

  • InterfaceEvent All OnBrowseHeader

    When the user selects the menu option corresponding to this menu action, Rose executes the OnBrowseHeader method in all active add-ins' OLE servers.

  • InterfaceEvent "My AddIn" CheckFormat

    When the user selects the menu option corresponding to this menu action, Rose executes the add-in's custom CheckFormat method in the add-in's OLE server whose ToolDisplayName (or, if ToolDisplayName is blank, ToolName) registry key is "My AddIn".


Menu File Variables and Modifiers

Rose provides a set of variables that correspond to various Rose model items. You can use these variables in conjunction with a set of modifiers to determine the conditions under which menu items are enabled or disabled, as well as to specify specific menu actions.

The format for specifying variables with modifiers is:

variable[:mod1[:mod2[...[:mod10]]]

Variables

Table 3 lists the set of variables that are valid for extending Rose menus.

Table 3 Menu File Variables 
Variable
Description
%all_units
List of controlled units in all models.
%current_diagram
Name of the current diagram.
%true
Boolean value TRUE.
%false
Boolean value FALSE.
%model
Name of the current model.
%selected_items
List of model elements selected in the current diagram.
%selected_units
List of controlled units selected in the current diagram.
%uname
Use in place of %selected_units:first:elide. See Modifiers for information on first and elide.
%ufile
Use in place of %selected_units:first:file. See Modifiers for information on first and file.

Modifiers

Table 4 lists the set of modifiers that are valid for use with variables to extend Rose menus.

Table 4 Menu File Modifiers 
Modifier
Description
allfiles
Applied to a unit or item name or a list of unit or item names, evaluates to a string that contains the list of the corresponding header and source file names.
basename
Applied to a path, evaluates to a string that contains the file name portion of the path. Applied to a list of paths, evaluates to a string that contains a list of file names. Each file name is extracted from its corresponding path.
codefile
Applied to a unit or item name or a list of unit or item names, does one of the following:
directory
Applied to a path which resolves to a file, evaluates to a string that contains the directory portion of the path. Applied to a path which resolves to a directory, evaluates to a string that contains that path--no modification is performed. Applied to a list of paths, evaluates to a string that contains a list of directories. Each directory is extracted from its corresponding path using the preceding rules.
elide
Applied to a unit or item name, evaluates to the first space-delimited word in the name. Applied to a list, equivalent to <list>:first:elide.
empty
Applied to a list, evaluates to a boolean, which is TRUE if the list is empty.
false
Applied to a boolean, evaluates to a boolean, which is the logical negation of its input.
file
Applied to a controlled unit name, evaluates to a string that contains the path of the file associated with (providing persistent storage for) that controlled unit. Applied to a list of controlled unit names, evaluates to a string that contains a list of paths using the preceding rule for each controlled unit name in the input list.
first
Applied to an empty list, evaluates to NULL. Applied to a non-empty list, evaluates to a string that contains the first element of the list.
headerfile
Applied to a unit or item name or a list of unit or item names, does one of the following:
home_unit
Applied to a model component name, evaluates to a string that contains the name of the controlled unit in which the item is located.
multiple
Applied to a list of unit, item, or file names, evaluates to a boolean, which is TRUE if list has more than one element.
not
A synonym (and preferred method) for false.
sourcefile
Applied to a unit or item name or to a list of unit or item names, does one of the following:
unary
Applied to a list, evaluates to a boolean, which is TRUE if the input list has exactly one element.
writeable
Applied to a path resolving to a file, evaluates to a boolean, which is TRUE if the file is writable. Applied to a controlled unit name, evaluates to a boolean, which is TRUE if the controlled unit is writable.

Syntax Rules for Rose Menu File Entries

Follow these rules when specifying menu text:

Adding Scripts to a Rose Menu

If you create a Rose script that you will use over and over again, you may want to add it to a Rose menu. For example, if you write a script to create a particular report based on the contents of a model, you will probably run that script periodically.

To add such scripts to a Rose menu:

1 Open the Rose Menu file, or create a new one to use in its place.

2 Edit the Path Map so that it includes a virtual script path. (See Adding or Editing the Virtual Path for Scripts.)

3 Modify the Rose menu file to add the script under the appropriate menu, being careful to follow all of the menu file syntax rules. To do this:

4 Save the updated menu file.

Adding or Editing the Virtual Path for Scripts

When you edit the Rose menu file to include script commands, you must include one of the following:

Defining a virtual path for scripts simplifies the process of editing the menu file by allowing you to specify the symbolic virtual path name instead of the complete file path.

To add or edit a virtual path for scripts:

1 Start Rose.

2 Click File > Edit Path Map to display the Virtual Path Map dialog box.

Figure 3 Adding Virtual Path for Scripts

.

3 Check for the $SCRIPT_PATH virtual symbol and do one of the following:

Sample Rose Menu File

The following figure shows a portion of a Rose menu file.

Figure 4 Sample Rose Menu File

Note the following entries as you examine the menu specifications that comprise this file:


Customizing Rose Shortcut Menus

When you or the user of your add-in to Rose right-clicks in Rose, a shortcut menu appears. The commands displayed on the shortcut menu are determined by where you or your add-in user clicks the mouse and what items are selected in the diagram or browser. You can take advantage of this feature in your add-in's functionality so that your add-in user sees your shortcut menu items when they right-click. If your add-in has features that you want to include on a shortcut menu, the shortcut menu Help topics explain how to add items to the Rose shortcut menu by using the Rose Extensibility Interface (REI).

Benefits

The REI exposure of Rose's shortcut menu interface provides the following benefits:

Limitations

The position on the shortcut menu where your menu item appears is controlled by Rose. If you have more than one item on the shortcut menu, however, you can control the order in which those items appear by adding the items (using the AddContextMenuItem method) in the order in which you want the menu items to appear.

Key Terms and Concepts

Language-Dependent

Rose model elements are language-dependent if they can be associated with a specific language add-in, especially for code generation. These language-dependent model elements are:

Language-Neutral

Rose model elements are language-neutral if they are not associated with a specific language. They are not generated into code (although model elements within them can be generated into code). These language-neutral model elements are:

Even though these model elements are language-neutral, a language add-in can work with them (except for DeploymentUnits, ExternalDocs, Models, and Properties) in the following ways. The language add-in can:

In other words, if your language add-in is the default language, when a user right-clicks on any of the above language-neutral model elements (except for DeploymentUnits, ExternalDocs, Models, and Properties), the user sees your language add-in's shortcut menu items for these model elements. If your language add-in is not the default language and the user right-clicks on one of the language-neutral model elements (except for DeploymentUnits, ExternalDocs, Models, and Properties), the user does not see your shortcut menu items for these model elements.

Language Add-In

A language add-in is an add-in whose Rose Registry setting for "LanguageAddIn" is set to Yes.

Non-Language Add-In

A non-language add-in is an add-in whose Rose Registry setting for "LanguageAddIn" is set to No.

Behind the Scenes of Shortcut Menus

When Rose is started, it issues the OnActivate event and gets shortcut menu items (ContextMenuItem) from each add-in.

When you or the user of your add-in right-clicks, Rose sends the OnEnableContextMenuItems event to the appropriate add-ins to get the applicable menu states for the add-in's ContextMenuItems. Rose then formats and displays the shortcut menu with appropriate add-in menu items depending on:

See How Rose Formats and Displays Shortcut Menu Items.

When the user selects a menu item from the shortcut menu, Rose sends the OnSelectedContextMenuItem to the appropriate add-ins. It is then up to the add-in to map the event and arguments to one of its methods.

The add-in then runs the method that corresponds to the selected shortcut menu item.

How Rose Formats and Displays Shortcut Menu Items

The methodology for determining which shortcut menu items appear and when they appear makes the add-in a smart, seamless part of Rose. Rose only displays your shortcut menu when it is appropriate to do so. For example, Rose displays your class shortcut items for a particular class if the following conditions are all true:

However, if your user creates a class with a different language add-in, Rose does not display your class shortcut menu items. (A menu item for C++ classes might not make sense for a Visual Basic class.) Because of the flexibility that Rose gives you through the REI to create shortcut menu items, it is also a complex concept. A shortcut menu item might not appear when expected. It is, therefore, important to understand the scenarios (explained later in this chapter) for the complete explanation of what is displayed and when it is displayed.

Shortcut menu items created by a non-language add-in are always displayed on the appropriate menu. Those items created by a language add-in are displayed when the selected items have that language assignment. Shortcut menu items created by a language add-in are also displayed when language-neutral items are selected and that language is the Default Language. Whether Rose displays a particular shortcut menu item is dependent on the following considerations:

See Shortcut Menu Scenarios for examples of how these issues affect shortcut menu items.

Shortcut Menu Scenarios

The following table describes all the possible scenarios for displaying shortcut menu items.

Table 5 Displaying Shortcut Menu Items 
Description
Example Selected Items
Displayed Shortcut Menu Items
Same language-
dependent types selected

Class 1 (Language A) (Any Default Language)
Language add-in A's rsClass shortcut menu items. All non-language add-in's rsClass shortcut menu items.

Class 1 (Language A) Class 2 (Language A) (Any Default Language)
Language add-in A's rsClass shortcut menu items. All non-language Add-in's rsClass shortcut menu items.

Class 1 (Language A) Class 2 (Language B) (Any Default Language)
Language add-in A's rsClass shortcut menu items. Language add-in B's rsClass shortcut menu items. All non-language Add-in's rsClass shortcut menu items.

Attribute 1 (Language A) Attribute 2 (Language B) (Any Default Language)
Language add-in A's rsAttribute shortcut menu items. Language add-in B's rsAttribute shortcut menu items. All non-language add-in's rsAttribute shortcut menu items.
Different language-
dependent types selected

Class 1 (Language A) Class 2 (Language B) Attribute 3 (Language A) Attribute 4 (Language C) (Any Default Language)
Language add-in A's rsDefault shortcut menu items. Language add-in B's rsDefault shortcut menu items. Language add-in C's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.

Operation 1 (Language A) Operation 2 (Language B) Role 3 (Language A) (Any Default Language)
Language add-in A's rsDefault shortcut menu items. Language add-in B's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.
Nothing selected
(Default Language set to Language A)
Language add-in A's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.

(Default Language set to Language B)
Language add-in B's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.
Same language-
neutral type selected

Diagram 1 (Created with any language) (Default Language set to Language A)
Language add-in A's rsDiagram shortcut menu items. All non-language add-in's rsDiagram shortcut menu items.

Diagram 1 (Created with any language) (Default Language set to Language B)
Language add-in B's rsDiagram shortcut menu items. All non-language add-in's rsDiagram shortcut menu items.

Diagram 1 (Created with any language) Diagram 2 (Created with any language) (Default Language set to Language A)
Language add-in A's rsDiagram shortcut menu items. All non-language add-in's rsDiagram shortcut menu items.
Same language-
neutral type selected, continued

Diagram 1 (Created with any language) Diagram 2 (Created with any language) (Default Language set to Language B)
Language add-in B's rsDiagram shortcut menu items. All non-language add-in's rsDiagram shortcut menu items.
Different language-
neutral types selected

Diagram 1 (Created with any language) Package 2 (Created with any language) Package 3 (Created with any language) (Default Language set to Language A)
Language add-in A's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.

Subsystem 1 (Created with any language) UseCase 2 (Created with any language) (Default Language set to Language B)
Language add-in B's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.
Combination of language-
dependent and language-
neutral types selected

Class 1 (Language A) Package 2 (Created with any language) (Default Language set to Language B)
Language add-in A's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.

Class 1 (Language A) Class 2 (Language B) Package 3 (Created with any language) Package 4 (Created with any language) (Default Language set to Language C)
Language add-in A's rsDefault shortcut menu items. Language add-in B's rsDefault shortcut menu items. All non-language add-in's rsDefault shortcut menu items.

Note: If you want a shortcut menu item to appear on more than one menu (for example, for classes and the default), you must create a separate ContextMenuItem for each item type (for example, one for rsClass and one for rsDefault). For examples, see Sample Shortcut Menu Implementation Code and Sample Rose Script Shortcut Menu Code.

For more information on rsClass, rsAttribute, rsDefault, or rsDiagram see ContextMenuItemType Enumeration in the online Help.

Shortcut Menu Design Considerations

To keep the shortcut menu from becoming too cluttered with many different add-in menu options, try to keep menu items on the main shortcut menu to a minimum. Use submenus as much as possible. However, put all the important menu options on the main shortcut menu. Put less important menu options on a submenu under a generic main shortcut menu option.

Generate Code and Browse Code are not standard Rose shortcut menu options. Each language add-in is responsible for creating and manipulating these options according to their needs. This gives you greater control and flexibility with these features. When creating menu items, make the caption specific to your language (for example, Generate C++ Code, Generate Visual Basic Code). This reduces confusion since the user of your add-in could be using more than one language add-in in Rose. Place Generate Code and Browse Code at the top level of the shortcut menu instead of in a submenu.

You could also place shortcut menu items that open a custom specification sheet at the top level of the shortcut menu. However, if your add-in supports the OnPropertySpecOpen event, do not add a custom specification menu item because it would be redundant. This is due to the fact that when Rose detects that the OnPropertySpecOpen event is supported for an item, Rose adds the Open Standard Specification shortcut menu item (which displays the standard Rose specification) immediately after the Open Specification shortcut menu item (which, in this context, displays the add-in's custom specification sheet).

Procedure

To customize the Rose shortcut menu:

1 In order to use this feature of the REI, you must register your product in the Rose Add-In Manager.

2 Determine the following:

3 Create the prototyped event methods, OnActivate, OnEnableContextMenuItems, and OnSelectedContextMenuItem customizing for your specific needs.

4 Create ContextMenuItem objects for each menu item by using the AddContextMenuItem method for each menu item. Use AddContextMenuItem in the order in which you want the menu items displayed on the shortcut menu.

5 Create your specific methods to support each ContextMenuItem (shortcut menu item) that maps to a specific function of your add-in. If the method already exists, update it as needed to take advantage of the Rose shortcut menu.

6 Create and incorporate menu state changes as needed for your add-in. Use the MenuState property of the ContextMenuItem to change menu states.

7 Determine if there are any additional steps necessary for your specific implementation and perform those steps.

Adding Menu Items to the Shortcut Menu

To create and add menu items to the shortcut menu, use the AddContextMenuItem Method.

Note: An add-in should add context menu items when it gets the OnActivate event.

Working with Shortcut Menu Items

When the user activates the shortcut menu with items selected in the browser or a diagram, Rose sends the OnEnableContextMenuItems event to the specified language add-in. The language add-in can then call GetSelectedItems at the model level to get all selected items, regardless of whether the user selected the items in the browser or in a diagram.

Working with the Shortcut Menu Item Collection

To work with a subset or the set of all shortcut menu items, use the GetContextMenuItems Method.

To enable, disable, check, or uncheck shortcut menu items:

1 Iterate through the collection of ContextMenuItem objects by using the GetAt method.

2 Set the MenuState property accordingly.

Editing Shortcut Menu Items

To change the properties of the shortcut menu item, see the ContextMenuItem class properties and methods.

Changing the State of a Shortcut Menu Item

To enable, disable, check, or uncheck a particular shortcut menu item, change the ContextMenuItem's MenuState property.

Sample Shortcut Menu Implementation Code

The following are sample pieces of code that you might use to add your menu items to Rose's shortcut menu.

`Customize OnActivate from the prototype
Sub OnActivate (LPDISPATCH pRoseApp)
. . .
`Create all shortcut menu items
Set myNewMenuItem1 =
Set myNewMenuItem2 = myAddIn.AddContextMenuItem (rsDefault, 
Set myNewMenuItem3 = myAddIn.AddContextMenuItem (rsDefault, 
Set myNewMenuItem4 = myAddIn.AddContextMenuItem (rsDefault, 
Set myNewMenuItem5 = myAddIn.AddContextMenuItem (rsDefault, 
Set myNewMenuItem6 = myAddIn.AddContextMenuItem (rsDefault, 
. . .
End Sub `OnActivate event

. . .
`Set initial state of each selectable shortcut menu item
myNewMenuItem2.MenuState = ENABLED
myNewMenuItem3.MenuState = ENABLED
myNewMenuItem4.MenuState = DISABLED
. . .

`Customize OnEnableContextMenuItems from the prototype
Function OnEnableContextMenuItems (LPDISPATCH pRoseApp, VT_I2 
itemType) As Boolean
. . .
End Function `OnEnableContextMenuItems event

. . .

`Create each routine that corresponds to a selectable shortcut 
`menu item
Sub DoMenuOption1 (argument1, argument 2, ...)
. . .
End Sub `DoMenuOption1 subroutine

Function DoMenuOption2 (argument1, argument2, º) As returnValue2
. . .
End Function `DoMenuOption2 function

. . .

`Customize OnSelectedContextMenuItem from the prototype to map
`selectable shortcut menu items to functionality in this 
`    add-in.
Function OnSelectedContextMenuItem (LPDISPATCH pRoseApp, BSTR 
internalName) As Boolean
Select Case internalName
End Select `internalName
. . .
End Function `OnSelectedContextMenuItem event

`Main program functionality
Sub Main
. . .
End Sub `Main Program

Sample Rose Script Shortcut Menu Code

The sample RoseScript code below produced the shortcut menu in Figure 5.

Figure 5 Sample Code for Shortcut Menus

`Subroutines to which the selectable shortcut menu items map
Sub internalName1

End Sub

Sub internalName2

End Sub

Sub internalName3

End Sub

Sub internalNameSub1

End Sub

Sub internalNameSub2

End Sub

Sub internalNameClass1

End Sub

Sub internalNameClass2

End Sub

Sub internalNameClass3

End Sub

Sub internalNameClassSub1

End Sub

Sub internalNameClassSub2

End Sub

Sub Main
`Create a sample shortcut menu
Dim myAddIn As RoseAddIn
Dim myMenuItem As ContextMenuItem 
Dim myMenuItem2 As ContextMenuItem
Dim myMenus As ContextMenuItemCollection 
Dim menuCount As Integer
Dim i As Integer
Dim classFound As Boolean
Dim myItems As ItemCollection
Dim itemCount As Integer
Dim anItem As RoseItem
Dim myModel As Model

`ContextMenuItemType enumeration
Const rsDefault As Integer = 0
Const rsClass As Integer = 4

`MenuState enumeration
Const rsDisabled As Integer = 0
Const rsEnabled As Integer = 1

Set myAddIn = ... `Get the add-in to which you want to add
        `shortcut menu items.

`Create shortcut menu items for rsDefault
Set myMenuItem = myAddIn.AddContextMenuItem(rsDefault, "Add-In 
Caption &1", "internalName1")
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, "Add-In 
Caption &2", "internalName2")
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, "Add-In 
Caption &3", "internalName3")
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, 
"Separator", "")
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, "Submenu 
&Main Add-In Menu Caption", "")
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, "&Caption 
1", "internalNameSub1")
Set myMenuItem2 = myAddIn.AddContextMenuItem (rsDefault, "C&aption 
2", "internalNameSub2")
Set myMenuItem2.MenuState = rsDisabled
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, 
"endsubmenu", "")
Set myMenuItem = myAddIn.AddContextMenuItem (rsDefault, 
"Separator", "")

`Create exact same shortcut menu items for rsClass
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "Add-In 
Caption &1", "internalNameClass1")
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "Add-In 
Caption &2", "internalNameClass2")
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "Add-In 
Caption &3", "internalNameClass3")
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "Separator", 
"")
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "Submenu &Main 
Add-In Menu Caption", "")
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "&Caption 1", 
"internalNameClassSub1")
Set myMenuItem2 = myAddIn.AddContextMenuItem (rsClass, "C&aption 2", 
"internalNameClassSub2")
Set myMenuItem2.MenuState = rsDisabled
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "endsubmenu", 
"")
Set myMenuItem = myAddIn.AddContextMenuItem (rsClass, "Separator", 
"")


`Check to see if the user has selected only Class items. If 
`so, enable the disabled shortcut menu option (Caption 2 
`on the submenu).
classFound = True
Set myItems = RoseApp.CurrentModel.GetSelectedItems ()
itemCount = myItems.Count
For i = 1 To itemCount
Next i

If classFound = True Then
End If

End Sub


Rational Software Corporation  http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2001, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX