Class ViewPart
- All Implemented Interfaces:
- IAdaptable,- IExecutableExtension,- IPersistable,- IViewPart,- IWorkbenchPart,- IWorkbenchPart2,- IWorkbenchPart3,- IWorkbenchPartOrientation
- Direct Known Subclasses:
- CommonNavigator,- E4PartWrapper,- ErrorViewPart,- org.eclipse.ui.internal.views.markers.ExtendedMarkersView,- PageBookView,- ViewIntroAdapterPart
 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 SummaryFields inherited from interface org.eclipse.ui.IWorkbenchPartPROP_TITLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected final voidcheckSite(IWorkbenchPartSite site) Checks that the given site is valid for this type of part.Returns the site for this view.voidInitializes this view with the given view site.voidInitializes this view with the given view site.voidSaves the object state within a memento.protected voidsetContentDescription(String description) Sets the content description for this part.voidsetInitializationData(IConfigurationElement cfig, String propertyName, Object data) This method is called by the implementation of the methodIConfigurationElement.createExecutableExtensionon a newly constructed extension, passing it its relevant configuration information.protected voidsetPartName(String partName) Sets the name of this part.Methods inherited from class org.eclipse.ui.part.WorkbenchPartaddPartPropertyListener, 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, showBusyMethods inherited from class org.eclipse.core.commands.common.EventManageraddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IAdaptablegetAdapterMethods inherited from interface org.eclipse.ui.IWorkbenchPartaddPropertyListener, createPartControl, dispose, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus
- 
Constructor Details- 
ViewPartprotected ViewPart()Creates a new view.
 
- 
- 
Method Details- 
getViewSiteDescription copied from interface:IViewPartReturns the site for this view. This method is equivalent to(IViewSite) getSite().The site can be nullwhile the view is being initialized. After the initialization is complete, this value must be non-nullfor the remainder of the view's life cycle.- Specified by:
- getViewSitein interface- IViewPart
- Returns:
- the view site; this value may be nullif the view has not yet been initialized
 
- 
initDescription copied from interface:IViewPartInitializes 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:
- initin interface- IViewPart
- Parameters:
- site- the view site
- Throws:
- PartInitException- may be thrown from overrides
 
- 
initDescription copied from interface:IViewPartInitializes 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:
- initin 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
 
- 
saveStateDescription copied from interface:IViewPartSaves the object state within a memento.- Specified by:
- saveStatein interface- IPersistable
- Specified by:
- saveStatein interface- IViewPart
- Parameters:
- memento- a memento to receive the object state
 
- 
setPartNameDescription copied from class:WorkbenchPartSets 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:
- setPartNamein class- WorkbenchPart
- Parameters:
- partName- the part name, as it should be displayed in tabs.
 
- 
setContentDescriptionDescription copied from class:WorkbenchPartSets 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:
- setContentDescriptionin class- WorkbenchPart
- Parameters:
- description- the content description
 
- 
setInitializationDataDescription copied from class:WorkbenchPartThis method is called by the implementation of the methodIConfigurationElement.createExecutableExtensionon 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
 Hashtablecontaining the actual parameter names and values (bothStrings)
 WorkbenchPartimplementation of thisIExecutableExtensionrecords the configuration element in and internal state variable (accessible viagetConfigElement). 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:
- setInitializationDatain interface- IExecutableExtension
- Overrides:
- setInitializationDatain 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:
 
- 
checkSiteDescription copied from class:WorkbenchPartChecks that the given site is valid for this type of part. The default implementation does nothing.- Overrides:
- checkSitein class- WorkbenchPart
- Parameters:
- site- the site to check
 
 
-