Add a Toolbar Button

You can customize the Query Studio toolbar by adding buttons.

Procedure

  1. Stop the IBM® Cognos® service.
  2. Open the file c10_location/templates/ps/qs/ui.xml in an XML or text editor.
  3. Under the toolbarContent element, add an ID for the new button.

    The following example shows how to do this for a button named Test.

    <button id="Test" />
  4. Save and close the ui.xml file.
  5. Open the file c10_location/templates/ps/qs/features.xml in an XML editor.
  6. Under the root element, add a new feature element corresponding to the toolbar button defined in the ui.xml file.

    For example, for the Test button, add the following:

    <feature name="Test" >
    		<toolbar buttonType="button">
    		<tooltip>"Test"</tooltip>
    			<icon>
    				<active useWebRoot="true">qs/images/toolbar/test_button.gif</active>
    			</icon>
    		<action>
    			<parameters>
    				<parameter type="string">Test</parameter>
    			</parameters>
    		</action>
    	</toolbar>
    </feature>

    The test.gif file referenced by the icon element must exist in the c10_location/webcontent/qs/images/toolbar directory.

    Note: If you are adding a corresponding menu item for the same functionality, add the button under the same feature element as the menu item, as shown in the following example:

    <feature name="Test" >
        <menuItem type="menuItem">
    		<...
    	 </menuItem>
    	 <toolbar buttonType="button">
    		 <...
    	  </toolbar>
    </feature>
  7. Save and close the features.xml file.
  8. In the c10_location\webcontent\qs\classes directory, create a new JavaScript file named CFeatureID.js.

    For example, for the Test button, the file name would be CTest.js.

    Note: If you are adding a corresponding menu item for the same functionality, this file is used both by the menu item and the button.

  9. 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
    };
  10. Save the JavaScript file.
  11. Start the IBM Cognos service.

Results

The new button appears in the Cognos Query toolbar.

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