Utilizing extension points

This sections describes how to implement the extension points available in Eclipse plug-ins for the WebSphere MQ Explorer.

For further information on using extension points see the WebSphere MQ Explorer help, as follows:

  1. Click Help->Help Contents.
  2. Expand Platform Plug-in Developers Guide.
  3. Click Programmers Guide.

For information on how to include an extension point, see Plugging into the workbench->Basic workbench extension points in the Programmers Guide.

Through utilizing the available extension points, you can extend the function of the WebSphere MQ Explorer in the following ways:

Multiple extension points of the same type can be included in a single plug-in. The extension points that you use will be dependent on the way in which you intend to extend the functionality of the WebSphere MQ Explorer. However, every plug-in for the WebSphere MQ Explorer must use the register extension point. For details on the register extension point, see Register.

Register

The register extension point is used for the following:

The following code extract is taken from the file, plugin.xml, from the simple plug-in and shows a basic implementation of the register extension point:

<extension
	  id="com.ibm.mq.explorer.sample.simple"
	  name="Simple Sample"
	  point="com.ibm.mq.explorer.ui.registerplugin">
	<pluginDetails
		 pluginId="com.ibm.mq.explorer.sample.simple"
		 name="Simple"
		 class="com.ibm.mq.explorer.sample.simple.SimpleNotify"
		 enabledByDefault="true"
		 description="a very simple sample plugin to Explorer"
		 vendor="IBM">
	</pluginDetails>
</extension>
Enabling and disabling a plug-in

All plug-ins that contain the register extension point can be enabled, or disabled, within the WebSphere MQ Explorer by doing the following:

  1. From the WebSphere MQ Explorer toolbar click, Window -> Preferences.
  2. Expand IBM WebSphere MQ.
  3. Click Enable plug-ins.

    All registered plug-ins are displayed.

  4. Select all plug-ins that should be enabled.
  5. Click OK.
Notify events

Within the WebSphere MQ Explorer, when a WebSphere MQ object is created, or manipulated, a java object relating to the WebSphere MQ object can be generated. These java object can be used to find the name, type, and other externalized attributes of a WebSphere MQ object.

For java objects to be generated, the register extension point must specify a class. In the plugin.xml file from the simple plug-in, the class specified is as follows:

class="com.ibm.mq.explorer.sample.simple.SimpleNotify"

This class contains a number of object specific methods. When a WebSphere MQ object is created, or manipulated, the appropriate method from the notify class is called. This class can be used as a basis for writing your own class. For the methods that this class must contain refer to the WebSphere MQ Explorer JavaDoc. For information on how to access the WebSphere MQ Explorer JavaDoc, see Accessing Javadoc.

Add tree node

A tree node extension point is used to add a tree node to the navigation view and associate it with a content page.

The following code extract is taken from the file, plugin.xml, from the simple plug-in and shows a basic implementation of the tree node extension point:

<extension
	  id="com.ibm.mq.explorer.samples.simpleTreeNode"
	  name="Simple TreeNode"
	  point="com.ibm.mq.explorer.ui.addtreenode">
	<treeNode
		 pluginId="com.ibm.mq.explorer.sample.simple"
		 name="com.ibm.mq.explorer.sample.simple"
		 class="com.ibm.mq.explorer.sample.simple.SimpleTreeNodeFactory"
		 treeNodeId="com.ibm.mq.explorer.sample.simple"
		 sequence="888">
	</treeNode>
</extension>

As well as declaring the tree node extension point in plugin.xml, the following classes are needed:

Add content page

A content page extension point is used to add a content pages to the content view. A content page can be associated with a tree node.

The following code extract is taken from the file, plugin.xml, from the simple plug-in and shows a basic implementation of the content page extension point:

<extension
	  id="com.ibm.mq.explorer.sample.simpleContentPage"
	  name="Simple ContentPage"
	  point="com.ibm.mq.explorer.ui.addcontentpage">
	<contentPage
		 pluginId="com.ibm.mq.explorer.sample.simple"
		 name="com.ibm.mq.explorer.sample.simple"
		 class="com.ibm.mq.explorer.sample.simple.SimpleContentPageFactory"
		 contentPageId="com.ibm.mq.explorer.sample.simple">
	</contentPage>
</extension>

As well as declaring the content page extension point in plugin.xml, the following classes are needed:

Add context menu item

A context menu extension point is used to add context menu items to the WebSphere MQ Explorer.

The following code extract is taken from the file, plugin.xml, from the simple plug-in and shows a basic implementation of the context menu extension point:

<extension
	  id="com.ibm.mq.explorer.sample.simple.object1"
	  name="Object1"
	  point="org.eclipse.ui.popupMenus">
	<objectContribution
		  objectClass="com.ibm.mq.explorer.ui.extensions.MQExtObject"
		  id="com.ibm.mq.explorer.sample.simple.obj1">
		<visibility>
			<and>
				<pluginState
				  value="activated"
				  id="com.ibm.mq.explorer.ui">
				</pluginState>
				<objectClass
				  name="com.ibm.mq.explorer.ui.extensions.MQExtObject">
				</objectClass>
				<objectState
				  name="PluginEnabled"
				  value="com.ibm.mq.explorer.sample.simple">
				</objectState>
			</and>
		</visibility>
		<action
		  label="Simple: Sample action on any MQExtObject"
		  class="com.ibm.mq.explorer.sample.simple.MenuActions"
		  menubarPath="additions"
		  id="com.ibm.mq.explorer.sample.simple.obj.action1">
		</action>
	</objectContribution>
</extension>

Additional context menu items are added using the Eclipse extension point org.eclipse.ui.popupMenus. The <visibility> attribute in the above extract contains the elements that control the conditions under which the context menu item is displayed. These conditions include tests on the plug-in state, the type of object, and the state of the object. For example, a content menu item can be displayed for local queues only, or for remote queue managers only.