Add a Menu Item

You can customize the Query Studio menus by adding menu items.

Procedure

  1. Stop the IBM® Cognos® service.
  2. Open the file c10_location/templates/ps/qs/ui.xml in an XML editor.
  3. Locate the content between the <menuContent>...</menuContent> tags.
  4. 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>
  5. 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.

  6. 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.

  7. Save and close the ui.xml file.
  8. Open the file c10_location/templates/ps/qs/features.xml in an XML editor.
  9. 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>
  10. Save and close the features.xml file.
  11. 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.

  12. 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
    };
  13. Save the JavaScript file.
  14. Start the IBM Cognos service.

Results

The new menu item appears under the menu for which it was added when the specified context is viewed.

To remove a menu item, delete the sections of code associated with the item from ui.xml and features.xml.