Eclipse Platform
2.0

org.eclipse.ui.part
Class ViewPart

java.lang.Object
  |
  +--org.eclipse.ui.part.WorkbenchPart
        |
        +--org.eclipse.ui.part.ViewPart
All Implemented Interfaces:
IAdaptable, IExecutableExtension, IViewPart, IWorkbenchPart
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/cview.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.
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, createPartControl, dispose, firePropertyChange, getAdapter, getConfigurationElement, getDefaultImage, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus, setInitializationData, setSite, setTitle, setTitleImage, setTitleToolTip
 
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 part construction. 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 part construction. 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

Eclipse Platform
2.0

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