public abstract class WorkbenchPart extends EventManager implements IWorkbenchPart3, IExecutableExtension, IWorkbenchPartOrientation
This class is not intended to be subclassed by clients outside this
package; clients should instead subclass ViewPart
or
EditorPart
.
ViewPart
,
EditorPart
PROP_TITLE
Modifier | Constructor and Description |
---|---|
protected |
WorkbenchPart()
Creates a new workbench part.
|
Modifier and Type | Method and Description |
---|---|
void |
addPartPropertyListener(IPropertyChangeListener listener)
Add a listener for changes in the arbitrary properties set.
|
void |
addPropertyListener(IPropertyListener l)
Adds a listener for changes to properties of this workbench part.
|
protected void |
checkSite(IWorkbenchPartSite site)
Checks that the given site is valid for this type of 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 |
firePartPropertyChanged(String key,
String oldValue,
String newValue) |
protected void |
firePropertyChange(int propertyId)
Fires a property changed event.
|
Object |
getAdapter(Class adapter)
Returns an object which is an instance of the given class
associated with this object.
|
protected IConfigurationElement |
getConfigurationElement()
Returns the configuration element for this part.
|
String |
getContentDescription()
Returns the content description of this part.
|
protected Image |
getDefaultImage()
Returns the default title image.
|
int |
getOrientation()
Return the orientation of this part.
|
String |
getPartName()
Returns the name of this part.
|
Map |
getPartProperties()
Return an unmodifiable map of the arbitrary properties.
|
String |
getPartProperty(String key)
Return the value for the arbitrary property key, or
null . |
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 |
removePartPropertyListener(IPropertyChangeListener listener)
Remove a change listener from the arbitrary properties set.
|
void |
removePropertyListener(IPropertyListener l)
Removes the given property listener from this workbench part.
|
protected void |
setContentDescription(String description)
Sets the content description for this part.
|
abstract void |
setFocus()
Asks this part to take focus within the workbench.
|
void |
setInitializationData(IConfigurationElement cfig,
String propertyName,
Object data)
This method is called by the implementation of the method
IConfigurationElement.createExecutableExtension
on a newly constructed extension, passing it its relevant configuration
information. |
protected void |
setPartName(String partName)
Sets the name of this part.
|
void |
setPartProperty(String key,
String value)
Set an arbitrary property on the part.
|
protected void |
setSite(IWorkbenchPartSite site)
Sets the part site.
|
protected void |
setTitle(String title)
Deprecated.
new code should use setPartName and setContentDescription
|
protected void |
setTitleImage(Image titleImage)
Sets or clears the title image of this part.
|
protected void |
setTitleToolTip(String toolTip)
Sets or clears the title tool tip text of this part.
|
void |
showBusy(boolean busy)
Show that this part is busy due to a Job running that it
is listening to.
|
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
public void addPropertyListener(IPropertyListener l)
IWorkbenchPart
The property ids are defined in IWorkbenchPartConstants
.
addPropertyListener
in interface IWorkbenchPart
l
- a property listenerpublic abstract void createPartControl(Composite parent)
IWorkbenchPart
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:
IActionBars
.ISelectionService
(optional). createPartControl
in interface IWorkbenchPart
parent
- the parent controlpublic void dispose()
WorkbenchPart
implementation of this
IWorkbenchPart
method disposes the title image
loaded by setInitializationData
. Subclasses may extend.dispose
in interface IWorkbenchPart
protected void firePropertyChange(int propertyId)
propertyId
- the id of the property that changedpublic Object getAdapter(Class adapter)
null
if
no such object can be found.
Subclasses may override this method (however, if they do so, they
should invoke the method on their superclass to ensure that the
Platform's adapter manager is consulted).getAdapter
in interface IAdaptable
adapter
- the adapter class to look upnull
if this object does not
have an adapter for the given classprotected IConfigurationElement getConfigurationElement()
protected Image getDefaultImage()
public IWorkbenchPartSite getSite()
IWorkbenchPart
null
while the workbench part is being initialized. After
the initialization is complete, this value must be non-null
for the remainder of the part's life cycle.getSite
in interface IWorkbenchPart
null
if the part
has not yet been initializedpublic String getTitle()
PROP_TITLE
.
The title is used to populate the title bar of this part's visual container.
It is considered bad practise to overload or extend this method. Parts should set their title by calling setPartName and/or setContentDescription.
getTitle
in interface IWorkbenchPart
null
)public Image getTitleImage()
IWorkbenchPart
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.
getTitleImage
in interface IWorkbenchPart
public String getTitleToolTip()
IWorkbenchPart
PROP_TITLE
.
The tool tip text is used to populate the title bar of this part's visual container.
getTitleToolTip
in interface IWorkbenchPart
null
)public void removePropertyListener(IPropertyListener l)
IWorkbenchPart
removePropertyListener
in interface IWorkbenchPart
l
- a property listenerpublic abstract void setFocus()
IWorkbenchPart
Clients should not call this method (the workbench calls this method at
appropriate times). To have the workbench activate a part, use
IWorkbenchPage.activate(IWorkbenchPart) instead
.
setFocus
in interface IWorkbenchPart
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data)
IConfigurationElement.createExecutableExtension
on a newly constructed extension, passing it its relevant configuration
information. Most executable extensions only make use of the first
two call arguments.
Regular executable extensions specify their Java implementation class name as an attribute of the configuration element for the extension. For example
<action run="com.example.BaseAction"/>In the above example, this method would be called with a reference to the
<action>
element (first argument), and
"run"
as the name of the attribute that defined
this executable extension (second argument).
The last parameter is for the specific use of extension adapters and is typically not used by regular executable extensions.
There are two supported ways of associating additional adapter-specific data with the configuration in a way that is transparent to the extension point implementor:
(1) by specifying adapter data as part of the implementation
class attribute value. The Java class name can be followed
by a ":" separator, followed by any adapter data in string
form. For example, if the extension point specifies an attribute
"run"
to contain the name of the extension implementation,
an adapter can be configured as
<action run="com.example.ExternalAdapter:./cmds/util.exe -opt 3"/>
(2) by converting the attribute used to specify the executable extension to a child element of the original configuration element, and specifying the adapter data in the form of xml markup. Using this form, the example above would become
<action> <run class="com.xyz.ExternalAdapter"> <parameter name="exec" value="./cmds/util.exe"/> <parameter name="opt" value="3"/> </run > </action>
Form (2) will typically only be used for extension points that anticipate the majority of extensions configured into it will in fact be in the form of adapters.
In either case, the specified adapter class is instantiated using its 0-argument public constructor. The adapter data is passed as the last argument of this method. The data argument is defined as Object. It can have the following values:
null
, if no adapter data was suppliedString
Hashtable
containing the actual
parameter names and values (both String
s)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.setInitializationData
in interface IExecutableExtension
cfig
- the configuration element used to trigger this execution.
It can be queried by the executable extension for specific
configuration propertiespropertyName
- 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
.IConfigurationElement.createExecutableExtension(String)
protected void setSite(IWorkbenchPartSite site)
Subclasses must invoke this method from IEditorPart.init
and IViewPart.init
.
site
- the workbench part siteprotected void checkSite(IWorkbenchPartSite site)
site
- the site to check@Deprecated protected void setTitle(String title)
This may change a title that was previously set using setPartName or setContentDescription.
title
- the title, or null
to clearprotected void setTitleImage(Image titleImage)
titleImage
- the title image, or null
to clearprotected void setTitleToolTip(String toolTip)
getTitleToolTip
toolTip
- the new tool tip text, or null
to clearpublic void showBusy(boolean busy)
busy
- boolean to indicate that the busy state has started
or ended.IWorkbenchSiteProgressService.showBusyForFamily(Object)
public String getPartName()
IWorkbenchPartConstants.PROP_PART_NAME
.
It is considered bad practise to overload or extend this method. Parts should call setPartName to change their part name.
getPartName
in interface IWorkbenchPart2
null
)protected void setPartName(String partName)
setPartName and setContentDescription are intended to replace setTitle. This may change a value that was previously set using setTitle.
partName
- the part name, as it should be displayed in tabs.public String getContentDescription()
IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION
.
It is considered bad practise to overload or extend this method. Parts should call setContentDescription to change their content description.
getContentDescription
in interface IWorkbenchPart2
null
)protected void setContentDescription(String description)
This may overwrite a value that was previously set in setTitle
description
- the content descriptionpublic int getOrientation()
IWorkbenchPartOrientation
getOrientation
in interface IWorkbenchPartOrientation
Window.getDefaultOrientation()
,
SWT.RIGHT_TO_LEFT
,
SWT.LEFT_TO_RIGHT
,
Window.getDefaultOrientation()
public void addPartPropertyListener(IPropertyChangeListener listener)
IWorkbenchPart3
Note: this is a different set of properties than the ones covered by the IWorkbenchPartConstants.PROP_* constants.
addPartPropertyListener
in interface IWorkbenchPart3
listener
- Must not be null
.public void removePartPropertyListener(IPropertyChangeListener listener)
IWorkbenchPart3
Note: this is a different set of properties than the ones covered by the IWorkbenchPartConstants.PROP_* constants.
removePartPropertyListener
in interface IWorkbenchPart3
listener
- Must not be null
.protected void firePartPropertyChanged(String key, String oldValue, String newValue)
public void setPartProperty(String key, String value)
IWorkbenchPart3
A default implementation has been added to WorkbenchPart.
setPartProperty
in interface IWorkbenchPart3
key
- the arbitrary property. Must not be null
.value
- the property value. A null
value will remove
that property.public String getPartProperty(String key)
IWorkbenchPart3
null
.getPartProperty
in interface IWorkbenchPart3
key
- the arbitrary property. Must not be null
.null
.public Map getPartProperties()
IWorkbenchPart3
getPartProperties
in interface IWorkbenchPart3
null
.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.