Adding Custom Menus and Toolbar Buttons
Custom menus and/or toolbar buttons can be added to the Workspace application or your custom WCC application using configuration settings in the application’s configuration file, config.xml.
The record element that specifies a custom menu or toolbar button has a jsxid attribute value of customMenus:
<record jsxid="customMenus"> <!-- custom menu or toolbar elements added here --> </record>
The <record jsxid="customMenus"> element can have either toolbar or menu child elements, that display custom toolbar buttons and menus, respectively.
Both the toolbar and menu elements have three attributes:
- parent - The name of the list or toolbar on which the custom menu or button is to be displayed. The following values are valid(1):
- width - The display width in pixels. Note, however, that this is used only with a parent of "MainAppToolbar". For all other parents, it is ignored.
- prototype - The path to the default prototype XML file. This is the General Interface prototype that defines the GUI components for the menu or toolbar.
Both the toolbar and menu elements may also have optional locale child elements that define prototype XML files that are localized for specific languages. If a locale child element exists, and it corresponds to the language and locale currently selected by the user, the language-specific prototype is loaded, otherwise the default prototype is loaded.
Each locale child element has three attributes:
- localeKey - Locale identifier. This value must correspond to one of the
key attribute values defined in the
locale element of the
JSXAPPS\base\locale\locale.xml configuration file. The
key
attribute values are of the format: ll or ll_CC, where ll is a lowercase, two- letter ISO 639 language code, and CC is the optional, uppercase, two-letter ISO 3166 country code. For a list of codes, visit these web sites:
- International Organization for Standardization (ISO):
- Language codes:
- Country codes:
http://www.iso.ch/iso/en/prods-services/iso3166ma/ 02iso-3166-code-lists/index.html
- width - The display width in pixels. Note, however, that this is used only with a parent of "MainAppToolbar". For all other parents, it is ignored.
- prototype - The path to the prototype XML file containing language-specific data. This is the General Interface prototype that defines the GUI components for the menu or toolbar.
The following is an example <record jsxid="customMenus"> element that would cause a custom menu and toolbar button to appear on the work item list (parent = "WorkItemList"):
<record jsxid="customMenus"> <menu parent="WorkItemList" prototype="customMenusSample/prototypes/menus/MenuSample.xml"></menu> <toolbar parent="WorkItemList" prototype="customMenusSample/prototypes/toolbars/ToolbarSample.xml"></toolbar> </record>
The prototype attribute references the prototype for the custom menu or toolbar button—in the example above, they reference the prototypes provided in the custom menus sample: MenuSample.xml and ToolbarSample.xml (for more information about the custom menus sample, see Provided Custom Menus Sample).
The prototypes themselves reference the event handlers for the custom buttons and/or menu selections. For example, the ToolbarSample.xml prototype executes the sampleToolbarHandler, which is located in the AppMain.js file in the following directory:
StudioHome\wcc\version\JSXAPPS\WCCProjectName\application\js
where:
- StudioHome is the directory in which TIBCO Business Studio was installed.
- version is the version number of Workspace that was installed with TIBCO Business Studio.
- WCCProjectName is the name of the General Interface Builder project that contains your custom application. If you are working with the Workspace application, this is "workspace".
Add your custom application code to the appropriate handler in AppMain.js.
A custom WCC application can define new parent values in customMenus and provide its own custom handling for adding the menu or toolbar specified by the new parent name. See the loadWorkspaceCustomMenu method in the mixin interface (JSXAPPS\wcc\application\js\AppMain.js) for an example of how this is handled for the MainAppToolbar value.