Add a Menu Item
Procedure
- Stop the IBM® Cognos® service.
- Open the file c10_location/templates/ps/qs/ui.xml in an XML editor.
- Locate the content between the <menuContent>...</menuContent> tags.
- For the menu to which you want to add a new item, add the
menu item ID under the <menu> element.
The following example shows how to do this for a menu item named Test when adding it to the edit menu.
<menu alias="edit"> <name> <xts:string id="MENU_EDIT_COLUMN"/> </name> ... <menuItem id="Test" > </menu>
- Locate the content between the <contextMenu>...</contextMenu> tags.
Each menu element in this section represents different menu context, such as the report or chart context.
- For the context in which you want the menu item to appear,
add a new <menuItem> element.
The following example shows how to add the Test menu item for the report context:
<menu alias="report"> <menuItem id="Test" > <label>"Test..."</label> <link>goApplicationManager.getFeatureManager().launchFeature("Test")</link> <icon useWebRoot="true">qs/images/toolbar/test.gif</icon> </menuItem> </menu>
The link element in this example specifies the JavaScript function defined in steps 11 and 12.
The test.gif graphic file referenced by the icon element must exist in the c10_location/webcontent/qs/images/toolbar directory.
- Save and close the ui.xml file.
- Open the file c10_location/templates/ps/qs/features.xml in an XML editor.
- Under the <included>…</included> tag of root element,
add a new feature element corresponding to the menu
item defined in the ui.xml file.
For example, for the Test menu item, add the following:
<feature name="Test" > <menuItem type="menuItem"> <label>"Test..."</label> <tooltip>"Test"</tooltip> <icon> <active useWebRoot="true">qs/images/toolbar/test.gif</active> </icon> <action> <parameters> <parameter type="string">Test</parameter> </parameters> </action> </menuItem> </feature>
Note: If you are adding a corresponding button for the same functionality, add the menu item under the same feature element as the button, as shown in the following example:
<feature name="Test"> <menuItem type="menuItem"> <... </menuItem> <toolbar buttonType="button"> <... </toolbar> </feature>
- Save and close the features.xml file.
- In the c10_location\webcontent\qs\classes directory,
create a new JavaScript file
named CFeatureID.js.
For example, for the Test menu item, the file name would be CTest.js.
Note: If you are adding a corresponding toolbar button for the same functionality, this file is used both by the menu item and the button.
- In the JavaScript file,
define a class named CFeatureID, for example CTest, and the
supporting functions, as shown in the following example:
function CTest() { //Initialize } CTest.prototype = new AFeatureObject(); CTest.prototype.setup = function (aFeatureParams) { //setup feature parameter }; CTest.prototype.processErrorState = function() { //Handle error and return error state }; CTest.prototype.proceedWithoutDialog = function() { return this.execute(); }; CTest.prototype.execute = function (aParameters) { //Execute Feature };
- Save the JavaScript file.
- Start the IBM Cognos service.
Results
To remove a menu item, delete the sections of code associated with the item from ui.xml and features.xml.