Part interfaces
Parts do not need to implement any particular interface or inherit from any
particular base class. However, parts may optionally implement certain interfaces
in order to receive callbacks from their parent. For example, if a part implements
the IFocusable interface then its parent will use that interface to give focus
to the part. Parts are allowed to either implement the interface directly
or implement IAdaptable and provide an adapter for the interface.
Similarly to site interfaces, part interfaces are registered in the org.eclipse.core.component.types extension
point. There is a slight difference in the XML markup to distinguish between
a site interface and a part interface. Any plugin can extend the set of interfaces
available for a view to implement, and the PDE plugin registry can be used
to find all such interfaces.
The workbench provides the following interfaces to be implemented by parts:
Interface |
Description |
IFocusable |
Allows the part to implement setFocus.
|
IPersistable |
Allows the part to save its state between
sessions. |
IMultiPart |
Indicates that the part has the notion
of an active child. |
ISite |
Although this is never actually implemented
by a part, the implementations of other part interfaces can depend on
ISite in order to gain access to their site. |
Parts may also implement lifecycle interfaces. Lifecycle interfaces are different
from regular part interfaces in several ways:
- A lifecycle interface must be implemented directly (it cannot be provided
as an adapter);
- Any or all of a part's dependencies may also implement the lifecycle interface;
- When a lifecycle notification is sent to a part, it is also sent to all
of the part's dependencies;
- Lifecycle interfaces are hardcoded, and are not registered with an extension
point.
Parts support the following lifecycle interfaces:
Interface |
Description |
IDisposable |
Receives a notification when the component
is disposed. |
INestedComponent |
Implemented by children of a multiplexer.
Receives activate and deactivate messages when the active part changes.
|