Section 6.1. IAction versus IActionDelegate


6.1. IAction versus IActionDelegate

An Eclipse action is composed of several parts, including the XML declaration of the action in the plug-in's manifest, the IAction object instantiated by the Eclipse UI to represent the action, and the IActionDelegate defined in the plug-in library containing the code to perform the action (see Figure 6-1).

Figure 6-1. Action versus IActionDelegate.


This separation of the IAction object, defined and instantiated by the Eclipse user interface based on the plug-in's manifest and the IActionDelegate defined in the plug-in's library, allows Eclipse to represent the action in a menu or toolbar without loading the plug-in that contains the operation until the user selects a specific menu item or clicks on the toolbar. Again, this approach represents one of the overarching themes of Eclipse: lazy plug-in initialization.

There are several interesting subtypes of IActionDelegate.

IActionDelegate2 Provides lifecycle events to action delegates; if you are implementing IActionDelegate and need additional information, such as when to clean up before the action delegate is disposed, then implement IActionDelegate2 instead.

IEditorActionDelegate Provides lifecycle events to action delegates associated with an editor (see Section 6.5.3, IEditorActionDelegate, on page 246).

IObjectActionDelegate Provides lifecycle events to action delegates associated with a context menu (see Section 6.3.3, IObjectActionDelegate, on page 233).

IViewActionDelegate Provides lifecycle events to action delegates associated with a view (see Section 6.4.3, IViewActionDelegate, on page 240).

IWorkbenchWindowActionDelegate Provides lifecycle events to action delegates associated with the workbench window menu bar or toolbar.



Eclipse(c) Building Commercial-Quality Plug-ins
Eclipse: Building Commercial-Quality Plug-ins (2nd Edition)
ISBN: 032142672X
EAN: 2147483647
Year: 2004
Pages: 200

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net