|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A workbench part is a visual component within a workbench page. There
are two subtypes: view and editor, as defined by IViewPart
and
IEditorPart
.
A view is typically used to navigate a hierarchy of information (like the workspace), open an editor, or display properties for the active editor. Modifications made in a view are saved immediately.
An editor is typically used to edit or browse a document or input object.
The input is identified using an IEditorInput
. Modifications made
in an editor part follow an open-save-close lifecycle model.
This interface may be implemented directly. For convenience, a base
implementation is defined in WorkbenchPart
.
The lifecycle of a workbench part is as follows:
part.init(site)
part.createControl(parent)
to create actual widgetspartOpened
event to all listenerspart.setFocus()
partActivated
event to all listenerspartClosed
event to all listenerspart.dispose()
After createPartControl
has been called, the implementor may
safely reference the controls created. When the part is closed
these controls will be disposed as part of an SWT composite. This
occurs before the IWorkbenchPart.dispose
method is called.
If there is a need to free SWT resources the part should define a dispose
listener for its own control and free those resources from the dispose
listener. If the part invokes any method on the disposed SWT controls
after this point an SWTError
will be thrown.
The last method called on IWorkbenchPart
is dispose
.
This signals the end of the part lifecycle.
An important point to note about this lifecycle is that following a call to init, createControl may never be called. Thus in the dispose method, implementors must not assume controls were created.
Workbench parts implement the IAdaptable
interface; extensions
are managed by the platform's adapter manager.
IViewPart
,
IEditorPart
Field Summary | |
static int |
PROP_TITLE
The property id for getTitle and getTitleImage . |
Method Summary | |
void |
addPropertyListener(IPropertyListener listener)
Adds a listener for changes to properties of this workbench part. |
void |
createPartControl(Composite parent)
Creates the SWT controls for this workbench part. |
void |
dispose()
Disposes of this workbench part. |
IWorkbenchPartSite |
getSite()
Returns the site for this workbench part. |
String |
getTitle()
Returns the title of this workbench part. |
Image |
getTitleImage()
Returns the title image of this workbench part. |
String |
getTitleToolTip()
Returns the title tool tip text of this workbench part. |
void |
removePropertyListener(IPropertyListener listener)
Removes the given property listener from this workbench part. |
void |
setFocus()
Asks this part to take focus within the workbench. |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
getAdapter |
Field Detail |
public static final int PROP_TITLE
getTitle
and getTitleImage
.
Method Detail |
public void addPropertyListener(IPropertyListener listener)
The properties ids are as follows:
IWorkbenchPart.PROP_TITLE
IEditorPart.PROP_INPUT
IEditorPart.PROP_DIRTY
listener
- a property listenerpublic void createPartControl(Composite parent)
Clients should not call this method (the workbench calls this method when it needs to, which may be never).
For implementors this is a multi-step process:
IActionService
.IActionService
.ISelectionService
(optional).
parent
- the parent controlpublic void dispose()
This is the last method called on the IWorkbenchPart
. At this
point the part controls (if they were ever created) have been disposed as part
of an SWT composite. There is no guarantee that createPartControl() has been
called, so the part controls may never have been created.
Within this method a part may release any resources, fonts, images, etc. held by this part. It is also very important to deregister all listeners from the workbench.
Clients should not call this method (the workbench calls this method at appropriate times).
public IWorkbenchPartSite getSite()
public String getTitle()
PROP_TITLE
.
The title is used to populate the title bar of this part's visual container.
public Image getTitleImage()
PROP_TITLE
.
The title image is usually used to populate the title bar of this part's visual container. Since this image is managed by the part itself, callers must not dispose the returned image.
public String getTitleToolTip()
PROP_TITLE
.
The tool tip text is used to populate the title bar of this part's visual container.
public void removePropertyListener(IPropertyListener listener)
listener
- a property listenerpublic void setFocus()
Clients should not call this method (the workbench calls this method at appropriate times).
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |