Sample 2 - Adding an action to a pop-up menu

The second sample project adds an action to existing pop-up menus in the CICS Explorer®.

The sample project is included with the CICS Explorer SDK. See the topic Introduction for more information.

Procedure

This task describes how to add an action to an existing pop-up menu in the CICS Explorer

  1. Create a new plug-in project with the following selections:
    • Ensure that the check box This plug-in will make contributions to the UI is selected in the Plug-in Content wizard.
    • Select the template Plug-in with a popup menu in the Templates wizard.
    • Use com.ibm.cics.model.IRegion as the interface for the target object class in the Sample Popup Menu wizard, to ensure that the pop-up menu is displayed only when the currently selected object is a CICS® region.

    When the plug-in is created the plug-in editor opens, however an error is displayed in the Problems view. The reason for the error is that the wizard has created a plug-in that is not aware of the plug-ins contributed by the CICS Explorer SDK. To resolve this problem you must add a dependency to the plug-in com.ibm.cics.model in the dependencies tab, then save, but do not close, the plug-in.

  2. Edit the code for the action started by the pop-up menu. Click the Extensions tab. Expand the org.eclipse.ui.popupMenus tree until New Action, or whatever action label you chose, is displayed, and then click the label.
  3. Click the class* hyperlink to open the Java™ editor and customize the code for the required action.
You can save the first element in the selection in the method to an instance variable:
public void selectionChanged(IAction action, ISelection selection)
and then display some information about that object in a dialog in the method
public void run(IAction action)
See the sample code for more information.

To add a variation of the action, add another object contribution, this time on ICICSobject, which is the supertype interface for all CICS objects in the CICS Explorer API.

<extension

point="org.eclipse.ui.popupMenus">

<objectContribution

objectClass="com.ibm.cics.model.ICICSObject"

id="com.ibm.cics.explorer.sdk.demo2.contribution2">

<menu

The popup menu contribution for IRegion is shown only when a CICS region is selected (in the region view), the one for ICICSObject appears in every CICS Explorer view.