FAQ how do I hook into global actions, such as copy and delete?
How to associate the global retarget action in the view.
Certain Standard toolbar and menu entries can be shared among several views and editors. These actions are called either
GlobalOrRetargetableActions and include such common tools as Undo/Redo, CUT/copy/paste, print, find, delete, and more. each view or editor is allowed to contribute a handler for these actions; when a new part becomes active, its handler
Takes control of that action.
A view typically registers its global action handlers inCreatepartcontrolMethod:
IActionBars actionBars= getViewSite().getActionBars(); actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), copyAction);
You have to do this only once for each view that is created. The platform remembers your Action Handler and retargets the action each time the view becomes active. to unregister from a global action, simply invoke
SetglobalactionhandlerAgain and pass inNullValue for the handler.
TheIworkbenchactionconstantsInterface inOrg. Eclipse. UIPackage contains a complete list of global actions. Look for constants in this interface with a comment saying "Global Action." In eclipse 3.0, you can also look at
ActionfactoryAndIdeactionfactoryClasses, which define factory objects for creating a variety of common actions.