Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.ui.part
Class ViewPart

java.lang.Object
  extended byorg.eclipse.ui.part.WorkbenchPart
      extended byorg.eclipse.ui.part.ViewPart

All Implemented Interfaces:
IAdaptable, IExecutableExtension, IViewPart, IWorkbenchPart, IWorkbenchPart2

Direct Known Subclasses:
BookmarkNavigator, PageBookView, ResourceNavigator, TaskList


public abstract class ViewPart
extends WorkbenchPart
implements IViewPart

Abstract base implementation of all workbench views.

This class should be subclassed by clients wishing to define new views. The name of the subclass should be given as the "class" attribute in a view extension contributed to the workbench's view extension point (named "org.eclipse.ui.views"). For example, the plug-in's XML markup might contain:

 <extension point="org.eclipse.ui.views">
      <view id="com.example.myplugin.view"
         name="My View"
         class="com.example.myplugin.MyView"
         icon="images/eview.gif"
      />
 </extension>
 
where com.example.myplugin.MyView is the name of the ViewPart subclass.

Subclasses must implement the following methods:

Subclasses may extend or reimplement the following methods as required:


Field Summary
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
protected ViewPart()
          Creates a new view.
 
Method Summary
 IViewSite getViewSite()
          Returns the site for this view.
 void init(IViewSite site)
          Initializes this view with the given view site.
 void init(IViewSite site, IMemento memento)
          Initializes this view with the given view site.
 void saveState(IMemento memento)
          Saves the object state within a memento.
protected  void setContentDescription(String description)
          Sets the content description for this part.
 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. 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 supplied
  • in case (1), the initialization data string is passed as a String
  • in case (2), the initialization data is passed as a Hashtable containing the actual parameter names and values (both Strings)

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. The WorkbenchPart implementation of this IExecutableExtension records the configuration element in and internal state variable (accessible via getConfigElement).
protected  void setPartName(String partName)
          Sets the name of this part.
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, createPartControl, dispose, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getPartName, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, createPartControl, dispose, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Constructor Detail

 

 

ViewPart

protected ViewPart()

Creates a new view.

Method Detail

 

 

getViewSite

public IViewSite getViewSite()

Description copied from interface: IViewPart
Returns the site for this view.

Specified by:
getViewSite in interface IViewPart

Returns:
the view site


 

 

init

public void init(IViewSite site)
          throws PartInitException

Description copied from interface: IViewPart
Initializes this view with the given view site.

This method is automatically called by the workbench shortly after the part is instantiated. It marks the start of the views's lifecycle. Clients must not call this method.

Specified by:
init in interface IViewPart

Parameters:
site - the view site
Throws:
PartInitException - if this view was not initialized successfully


 

 

init

public void init(IViewSite site,
                 IMemento memento)
          throws PartInitException

Description copied from interface: IViewPart
Initializes this view with the given view site. A memento is passed to the view which contains a snapshot of the views state from a previous session. Where possible, the view should try to recreate that state within the part controls.

This method is automatically called by the workbench shortly after the part is instantiated. It marks the start of the views's lifecycle. Clients must not call this method.

Specified by:
init in interface IViewPart

Parameters:
site - the view site
memento - the IViewPart state or null if there is no previous saved state
Throws:
PartInitException - if this view was not initialized successfully


 

 

saveState

public void saveState(IMemento memento)

Description copied from interface: IViewPart
Saves the object state within a memento.

Specified by:
saveState in interface IViewPart

Parameters:
memento - a memento to receive the object state


 

 

setPartName

protected void setPartName(String partName)

Description copied from class: WorkbenchPart
Sets the name of this part. The name will be shown in the tab area for the part. Clients should call this method instead of overriding getPartName. Setting this to the empty string will cause a default part name to be used.

setPartName and setContentDescription are intended to replace setTitle. This may change a value that was previously set using setTitle.

Overrides:
setPartName in class WorkbenchPart

Parameters:
partName - the part name, as it should be displayed in tabs.


 

 

setContentDescription

protected void setContentDescription(String description)

Description copied from class: WorkbenchPart
Sets the content description for this part. The content description is typically a short string describing the current contents of the part. Setting this to the empty string will cause a default content description to be used. Clients should call this method instead of overriding getContentDescription(). For views, the content description is shown (by default) in a line near the top of the view. For editors, the content description is shown beside the part name when showing a list of editors. If the editor is open on a file, this typically contains the path to the input file, without the filename or trailing slash.

This may overwrite a value that was previously set in setTitle

Overrides:
setContentDescription in class WorkbenchPart

Parameters:
description - the content description


 

 

setInitializationData

public void setInitializationData(IConfigurationElement cfig,
                                  String propertyName,
                                  Object data)

Description copied from class: WorkbenchPart
This method is called by the implementation of the method 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:

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
Overrides:
setInitializationData in class WorkbenchPart


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.