Eclipse Platform
2.0

org.eclipse.ui.part
Class WorkbenchPart

java.lang.Object
  |
  +--org.eclipse.ui.part.WorkbenchPart
All Implemented Interfaces:
IAdaptable, IExecutableExtension, IWorkbenchPart
Direct Known Subclasses:
EditorPart, ViewPart

public abstract class WorkbenchPart
extends Object
implements IWorkbenchPart, IExecutableExtension

Abstract base implementation of all workbench parts.

This class is not intended to be subclassed by clients outside this package; clients should instead subclass ViewPart or EditorPart.

See Also:
ViewPart, EditorPart

Field Summary
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
protected WorkbenchPart()
          Creates a new workbench part.
 
Method Summary
 void addPropertyListener(IPropertyListener l)
          Adds a listener for changes to properties of this workbench part.
abstract  void createPartControl(Composite parent)
          Creates the SWT controls for this workbench part.
 void dispose()
          The WorkbenchPart implementation of this IWorkbenchPart method disposes the title image loaded by setInitializationData.
protected  void firePropertyChange(int propertyId)
          Fires a property changed event.
 Object getAdapter(Class key)
          The WorkbenchPart implementation of this IAdaptable method returns null.
protected  IConfigurationElement getConfigurationElement()
          Returns the configuration element for this part.
protected  Image getDefaultImage()
          Returns the default title image.
 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 l)
          Removes the given property listener from this workbench part.
abstract  void setFocus()
          Asks this part to take focus within the workbench.
 void setInitializationData(IConfigurationElement cfig, String propertyName, Object data)
          The WorkbenchPart implementation of this IExecutableExtension records the configuration element in and internal state variable (accessible via getConfigElement).
protected  void setSite(IWorkbenchPartSite site)
          Sets the part site.
protected  void setTitle(String title)
          Sets or clears the title of this part.
protected  void setTitleImage(Image titleImage)
          Sets or clears the title image of this part.
protected  void setTitleToolTip(String text)
          Sets or clears the title tool tip text of this part.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkbenchPart

protected WorkbenchPart()
Creates a new workbench part.

Method Detail

addPropertyListener

public void addPropertyListener(IPropertyListener l)
Description copied from interface: IWorkbenchPart
Adds a listener for changes to properties of this workbench part. Has no effect if an identical listener is already registered.

The properties ids are as follows:

Specified by:
addPropertyListener in interface IWorkbenchPart
Parameters:
l - a property listener

createPartControl

public abstract void createPartControl(Composite parent)
Description copied from interface: IWorkbenchPart
Creates the SWT controls for this workbench part.

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:

  1. Create one or more controls within the parent.
  2. Set the parent layout as needed.
  3. Register any global actions with the IActionService.
  4. Register any popup menus with the IActionService.
  5. Register a selection provider with the ISelectionService (optional).

Specified by:
createPartControl in interface IWorkbenchPart
Parameters:
parent - the parent control

dispose

public void dispose()
The WorkbenchPart implementation of this IWorkbenchPart method disposes the title image loaded by setInitializationData. Subclasses may extend.

Specified by:
dispose in interface IWorkbenchPart

firePropertyChange

protected void firePropertyChange(int propertyId)
Fires a property changed event.

Parameters:
propertyId - the id of the property that changed

getAdapter

public Object getAdapter(Class key)
The WorkbenchPart implementation of this IAdaptable method returns null. Subclasses may reimplement.

Specified by:
getAdapter in interface IAdaptable
Parameters:
key - the adapter class to look up
Returns:
a object castable to the given class, or null if this object does not have an adapter for the given class

getConfigurationElement

protected IConfigurationElement getConfigurationElement()
Returns the configuration element for this part. The configuration element comes from the plug-in registry entry for the extension defining this part.

Returns:
the configuration element for this part

getDefaultImage

protected Image getDefaultImage()
Returns the default title image.

Returns:
the default image

getSite

public IWorkbenchPartSite getSite()
Description copied from interface: IWorkbenchPart
Returns the site for this workbench part.

Specified by:
getSite in interface IWorkbenchPart
Returns:
the part site

getTitle

public String getTitle()
Description copied from interface: IWorkbenchPart
Returns the title of this workbench part. If this value changes the part must fire a property listener event with PROP_TITLE.

The title is used to populate the title bar of this part's visual container.

Specified by:
getTitle in interface IWorkbenchPart
Returns:
the workbench part title

getTitleImage

public Image getTitleImage()
Description copied from interface: IWorkbenchPart
Returns the title image of this workbench part. If this value changes the part must fire a property listener event with 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.

Specified by:
getTitleImage in interface IWorkbenchPart
Returns:
the title image

getTitleToolTip

public String getTitleToolTip()
Description copied from interface: IWorkbenchPart
Returns the title tool tip text of this workbench part. If this value changes the part must fire a property listener event with PROP_TITLE.

The tool tip text is used to populate the title bar of this part's visual container.

Specified by:
getTitleToolTip in interface IWorkbenchPart
Returns:
the workbench part title tool tip

removePropertyListener

public void removePropertyListener(IPropertyListener l)
Description copied from interface: IWorkbenchPart
Removes the given property listener from this workbench part. Has no affect if an identical listener is not registered.

Specified by:
removePropertyListener in interface IWorkbenchPart
Parameters:
l - a property listener

setFocus

public abstract void setFocus()
Description copied from interface: IWorkbenchPart
Asks this part to take focus within the workbench.

Clients should not call this method (the workbench calls this method at appropriate times).

Specified by:
setFocus in interface IWorkbenchPart

setInitializationData

public void setInitializationData(IConfigurationElement cfig,
                                  String propertyName,
                                  Object data)
The WorkbenchPart implementation of this IExecutableExtension records the configuration element in and internal state variable (accessible via getConfigElement). It also loads the title image, if one is specified in the configuration element. Subclasses may extend. Should not be called by clients. It is called by the core plugin when creating this executable extension.

Specified by:
setInitializationData in interface IExecutableExtension
Parameters:
cfig - the configuration element used to trigger this execution. It can be queried by the executable extension for specific configuration properties
propertyName - the name of an attribute of the configuration element used on the createExecutableExtension(String) call. This argument can be used in the cases where a single configuration element is used to define multiple executable extensions.
data - adapter data in the form of a String, a Hashtable, or null.
See Also:
IConfigurationElement.createExecutableExtension(java.lang.String)

setSite

protected void setSite(IWorkbenchPartSite site)
Sets the part site.

Subclasses must invoke this method from IEditorPart.init and IViewPart.init.

Parameters:
site - the workbench part site

setTitle

protected void setTitle(String title)
Sets or clears the title of this part.

Parameters:
title - the title, or null to clear

setTitleImage

protected void setTitleImage(Image titleImage)
Sets or clears the title image of this part.

Parameters:
titleImage - the title image, or null to clear

setTitleToolTip

protected void setTitleToolTip(String text)
Sets or clears the title tool tip text of this part.

Parameters:
text - the new tool tip text

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.