### Setting a global action handler

A plug-in contributes a retargetable action for a view or editor part by implementing an IAction and registering it as a global action handler with the part's action bars. In views, this is usually done at the time that the part creates its actions and controls. For editors see Retargetable editor actions. The name of the retargeted action (as defined in IWorkbenchActionConstants) is used to specify which action the handler is intended for. The following shows how the workbench task list view registers its handler for the PROPERTIES action.

    public void createPartControl(Composite parent) {
    	...
    	makeActions();
    	...

    	// Add global action handlers.
    	...
    	getViewSite().getActionBars().setGlobalActionHandler(
    		IWorkbenchActionConstants.PROPERTIES,
    		propertiesAction);
    	...

The properties action is created in the local method makeActions:

    void makeActions() {
    	...
    	// properties
    	propertiesAction = new TaskPropertiesAction(this, "properties");
    	propertiesAction.setText(TaskListMessages.getString("Properties.text"));
    	propertiesAction.setToolTipText(TaskListMessages.getString("Properties.tooltip"));
    	propertiesAction.setEnabled(false);
    }

That's all that is needed. Your action will be run when the user chooses the action from the workbench menu bar or tool bar and your view or editor is active. The workbench handles the details of ensuring that the retargeted action is always associated with the currently active view. The same applies to editor actions supplied through the EditorActionBarContributor.