Creating an action element

You can inform the Menu Manager that actions exist by adding action elements for each action in the com.ibm.tpf.menumanager.actions extension point, and then referencing these actions in the Menu Manager.

About this task

Each action element must consist of an ID and a class.

Procedure

To create an action element, complete the following steps:

  1. Create a plug-in project. For information about creating a plug-in project, see the related topics.
  2. In the plug-in project, right-click the MANIFEST.MF file and select Open With > Plug-in Manifest Editor.
    The file opens in the manifest editor.
  3. In the Plug-in Manifest Editor, click the Dependencies tab and complete the following steps:
    1. In the Required Plug-ins section, click Add.
      The Plug-in Selection window opens.
    2. In the Select a Plug-in field, type com.ibm.tpf.menumanager, and then click OK.
  4. In the Plug-in Manifest Editor, click the Extensions tab and complete the following steps:
    1. Click Add.
      The New Extension wizard opens.
    2. Click the Extension Points tab.
    3. From the list of available extension points, select com.ibm.tpf.menumanager.actions, and then click Finish.
  5. In the Extensions tab, right-click the com.ibm.tpf.menumanager.actions extension point and select New > action from the pop-up menu.
    An action element is added as a child of the com.ibm.tpf.menumanager.actions extension point.
  6. Select the action element.
    The Extension Element Details section displays the following information for the action element:
    • id - this value is displayed in the Use existing action list when you create an action in the Menu Manager. This ID must be unique. It cannot be the same as the ID of any other actions that are contributed from this plug-in or a different plug-in.
    • class - the name of a class that implements org.eclipse.jface.action.IAction. The class also specifies cosmetic properties for the action, such as icons.
      Note: The run method of the specified class provides the code that is run when the action is selected from a pop-up menu.
    • separateThread - specify whether you want to run this action on a separate thread of execution. By default, it is set to false. To run the action on a separate thread of execution, set the value to true.
  7. In the Extension Element Details section, do one of the following to select a Java™ class for the action element:
    • To use an existing Java class, click Browse to open the Select Type window. In the Select entries field, type the name of the Java class that you want to use. From the list of Matching types, select the Java class, and then click OK.
    • To generate a Java class for the action element, click class to open the New Java Class wizard. In the Source folder field, type the name of the folder in which you want to store the Java class or click Browse to browse for the location of the folder. In the Package field, type the name of the package in which you want to store the Java class or click Browse to browse for the package. In the Name field, type the name of the Java class, and then click Finish.
    Note: You must select a Java class that implements the org.eclipse.jface.action.IAction interface. The Java class can extend the org.eclipse.jface.action.Action class instead which provides defaults for several of the methods in the IAction interface.
  8. In the id field, type a unique identifier for this action.
  9. From the separateThread list, select true to run this action on a separate thread of execution.
    By default, this value is set to false.
    Note: Calls to the GUI can be run only from the main thread. If you are running in a separate thread, you must wrap all GUI calls in an org.eclipse.swt.widgets.Display.syncExec call.
  10. In the Extensions tab, right-click to open the pop-up menu and select Save.
    The action element is created.