Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.ui.part
Class ViewPart


java.lang.Object
  extended by 

org.eclipse.core.commands.common.EventManager
      extended by 

org.eclipse.ui.part.WorkbenchPart
          extended by 
org.eclipse.ui.part.ViewPart
All Implemented Interfaces:
IAdaptable, IExecutableExtension, IPersistable, IViewPart, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPart3, IWorkbenchPartOrientation
Direct Known Subclasses:
BookmarkNavigator, CommonNavigator, org.eclipse.ui.internal.views.markers.ExtendedMarkersView, 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:

  • createPartControl - to create the view's controls
  • setFocus - to accept focus

Subclasses may extend or reimplement the following methods as required:

  • setInitializationData - extend to provide additional initialization when view extension is instantiated
  • init(IWorkbenchPartSite) - extend to provide additional initialization when view is assigned its site
  • dispose - extend to provide additional cleanup
  • getAdapter - reimplement to make their view adaptable


Field Summary
 
Fields inherited from interface org.eclipse.ui. IWorkbenchPart
PROP_TITLE
 
Constructor Summary
protected ViewPart ()
          Creates a new view.
 
Method Summary
protected  void checkSite ( IWorkbenchPartSite site)
          Checks that the given site is valid for this type of part.
  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.
protected  void setPartName ( String partName)
          Sets the name of this part.
 
Methods inherited from class org.eclipse.ui.part. WorkbenchPart
addPartPropertyListener, addPropertyListener, createPartControl, dispose, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setFocus, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class org.eclipse.core.commands.common. EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
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. This method is equivalent to (IViewSite) getSite().

The site can be null while the view is being initialized. After the initialization is complete, this value must be non-null for the remainder of the view's life cycle.

Specified by:
getViewSite in interface IViewPart
Returns:
the view site; this value may be null if the view has not yet been initialized

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 IPersistable
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:

  • 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.

Specified by:
setInitializationData in interface IExecutableExtension
Overrides:
setInitializationData in class WorkbenchPart
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(String)

checkSite

protected final void checkSite(
IWorkbenchPartSite site)
Checks that the given site is valid for this type of part. The site for a view must be an IViewSite.

Overrides:
checkSite in class WorkbenchPart
Parameters:
site - the site to check
Since:
3.1

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire