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.jface.viewers
Class ContentViewer

java.lang.Object
  extended byorg.eclipse.jface.viewers.Viewer
      extended byorg.eclipse.jface.viewers.ContentViewer

All Implemented Interfaces:
IInputProvider, IInputSelectionProvider, ISelectionProvider

Direct Known Subclasses:
ContentMergeViewer, StructuredViewer


public abstract class ContentViewer
extends Viewer

A content viewer is a model-based adapter on a widget which accesses its model by means of a content provider and a label provider.

A viewer's model consists of elements, represented by objects. A viewer defines and implements generic infrastructure for handling model input, updates, and selections in terms of elements. Input is obtained by querying an IContentProvider which returns elements. The elements themselves are not displayed directly. They are mapped to labels, containing text and/or an image, using the viewer's ILabelProvider.

Implementing a concrete content viewer typically involves the following steps:


Field Summary
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Constructor Summary
protected ContentViewer()
          Creates a content viewer with no input, no content provider, and a default label provider.
 
Method Summary
 IContentProvider getContentProvider()
          Returns the content provider used by this viewer, or null if this view does not yet have a content provider.
 Object getInput()
          The ContentViewer implementation of this IInputProvider method returns the current input of this viewer, or null if none.
 IBaseLabelProvider getLabelProvider()
          Returns the label provider used by this viewer.
protected  void handleDispose(DisposeEvent event)
          Handles a dispose event on this viewer's control.
protected  void handleLabelProviderChanged(LabelProviderChangedEvent event)
          Handles a label provider changed event.
protected  void hookControl(Control control)
          Adds event listener hooks to the given control.
protected  void labelProviderChanged()
          Notifies that the label provider has changed.
 void setContentProvider(IContentProvider contentProvider)
          Sets the content provider used by this viewer.
 void setInput(Object input)
          The ContentViewer implementation of this Viewer method invokes inputChanged on the content provider and then the inputChanged hook method.
 void setLabelProvider(IBaseLabelProvider labelProvider)
          Sets the label provider for this viewer.
 
Methods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getControl, getData, getSelection, handleHelpRequest, inputChanged, refresh, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection, setSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

 

 

ContentViewer

protected ContentViewer()

Creates a content viewer with no input, no content provider, and a default label provider.

Method Detail

 

 

getContentProvider

public IContentProvider getContentProvider()

Returns the content provider used by this viewer, or null if this view does not yet have a content provider.

The ContentViewer implementation of this method returns the content provider recorded is an internal state variable. Overriding this method is generally not required; however, if overriding in a subclass, super.getContentProvider must be invoked.

Returns:
the content provider, or null if none


 

 

getInput

public Object getInput()

The ContentViewer implementation of this IInputProvider method returns the current input of this viewer, or null if none. The viewer's input provides the "model" for the viewer's content.

Specified by:
getInput in interface IInputProvider
Specified by:
getInput in class Viewer


 

 

getLabelProvider

public IBaseLabelProvider getLabelProvider()

Returns the label provider used by this viewer.

The ContentViewer implementation of this method returns the label provider recorded in an internal state variable; if none has been set (with setLabelProvider) a SimpleLabelProvider will be created, remembered, and returned. Overriding this method is generally not required; however, if overriding in a subclass, super.getLabelProvider must be invoked.

Returns:
a label provider


 

 

handleDispose

protected void handleDispose(DisposeEvent event)

Handles a dispose event on this viewer's control.

The ContentViewer implementation of this method disposes of this viewer's label provider and content provider (if it has one). Subclasses should override this method to perform any additional cleanup of resources; however, overriding methods must invoke super.handleDispose.

Parameters:
event - a dispose event


 

 

handleLabelProviderChanged

protected void handleLabelProviderChanged(LabelProviderChangedEvent event)

Handles a label provider changed event.

The ContentViewer implementation of this method calls labelProviderChanged() to cause a complete refresh of the viewer. Subclasses may reimplement or extend.


 

 

hookControl

protected void hookControl(Control control)

Adds event listener hooks to the given control.

All subclasses must call this method when their control is first established.

The ContentViewer implementation of this method hooks dispose events for the given control. Subclasses may override if they need to add other control hooks; however, super.hookControl must be invoked.

Parameters:
control - the control


 

 

labelProviderChanged

protected void labelProviderChanged()

Notifies that the label provider has changed.

The ContentViewer implementation of this method calls refresh(). Subclasses may reimplement or extend.


 

 

setContentProvider

public void setContentProvider(IContentProvider contentProvider)

Sets the content provider used by this viewer.

The ContentViewer implementation of this method records the content provider in an internal state variable. Overriding this method is generally not required; however, if overriding in a subclass, super.setContentProvider must be invoked.

Parameters:
contentProvider - the content provider
See Also:
getContentProvider()


 

 

setInput

public void setInput(Object input)

The ContentViewer implementation of this Viewer method invokes inputChanged on the content provider and then the inputChanged hook method. This method fails if this viewer does not have a content provider. Subclassers are advised to override inputChanged rather than this method, but may extend this method if required.

Specified by:
setInput in class Viewer

Parameters:
input - the input of this viewer, or null if none


 

 

setLabelProvider

public void setLabelProvider(IBaseLabelProvider labelProvider)

Sets the label provider for this viewer.

The ContentViewer implementation of this method ensures that the given label provider is connected to this viewer and the former label provider is disconnected from this viewer. Overriding this method is generally not required; however, if overriding in a subclass, super.setLabelProvider must be invoked.

Parameters:
labelProvider - the label provider, or null if none


 

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.