Adding a menu action
The default IBM Sales Center actions are defined by the com.ibm.commerce.telesales.ui.actionSetGroups extension-point. This extension point allows you to specify a list of actionSet IDs and an ID for the whole group. When a IBM Sales Center perspective is loaded, it will use a predefined ID to determine which action set group to use. You can use the system configurator plug-in to override an entire action set group, or a specific action set that already defined as part of the action set.
About this task
To define a new menu action:
Procedure
- Define your actions using the base eclipse extension point org.eclipse.ui.actionSets.
The following sample defines a single action in an action set:
<extension point="org.eclipse.ui.actionSets"> <actionSet label="Sample Action Set" id="extensions.extendedActionSet"> <action label="" menubarPath="store/additions" id="extensions.ExtendedAction"> </action> </actionSet> </extension>
- When writing a new workbench action delegate class, make sure to
extend from the com.ibm.commerce.telesales.ui.actions.TelesalesWorkbenchActionDelegate
class. The real work for a IBM Sales Center workbench action is done in an
action registered with the com.ibm.commerce.telesales.ui.actions extension
point.
package extensions; import org.eclipse.jface.action.Action; public class ExtendedAction extends Action { public void run() { System.out.println("running extended action"); } }
ExtendedWorkbenchActionDelegate.java package extensions; import org.eclipse.jface.action.IAction; import com.ibm.commerce.telesales.ui.actions.TelesalesWorkbenchActionDelegate; public class ExtendedWorkbenchActionDelegate extends TelesalesWorkbenchActionDelegate { public void init(IAction action) { super.init(action); action.setEnabled(true); action.setText("my action"); action.setToolTipText("my action tool tip text"); action.setDescription("my action description"); } /** * Indicate that the real work is to be delegated to the action * registered under "extensions.ExtendedAction". * * @see com.ibm.commerce.telesales.ui.actions.TelesalesWorkbenchActionDelegate#getDelegateActionId() */ public String getDelegateActionId() { return "extensions.ExtendedAction"; } }
- Indicate the ID of the delegate action in your getDelegateActionId method (see preceding example).
- (Optional) Set the action attributes in the init(IAction
action) method. For example:
public void init(IAction action) { super.init(action); action.setText("my action"); action.setToolTipText("my action tool tip text"); action.setDescription("my action description"); }
- (Optional) Extend the following methods:
-
public String getActionDefinitionId()
-
public String getHelpContextId()
-
- To include the new action in the action set group for a perspective:
- Define a new action set group
- Use the system configurator to indicate that your action set group will be used instead of the default one. In normal circumstances you will include all of the default action sets as well as your new one. This can be done by referencing the default action set group in your action set group definition. The following sample is a new action set group definition for the Orders perspective that includes the test.actionSet action set.
This sample also requires that you add the following entry to your system configurator file:<extension name="Extended Orders Perspective ActionSet Group" point="com.ibm.commerce.telesales.ui.actionSetGroups"> <actionSetGroup id="extensions.actionSetGroup.orders"> <actionSetGroupContribution actionSetGroupId="com.ibm.commerce.telesales.actionSetGroup.orders"/> <actionSetContribution actionSetId="extensions.extendedActionSet"/> </actionSetGroup> </extension>
com.ibm.commerce.telesales.actionSetGroup.orders=extensions.actionSetGroup.orders
Results