|
 |
|
|
org.eclipse.jface.viewers
Class ContentViewer
java.lang.Object
org.eclipse.jface.viewers.Viewer
org.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:
-
create SWT controls for viewer (in constructor) (optional)
-
initialize SWT controls from input (inputChanged)
-
define viewer-specific update methods
-
support selections (
setSelection , getSelection )
Constructor Summary
|
protected
|
ContentViewer
()
Creates a content viewer with no input, no content provider, and a
default label provider. |
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
|
ContentViewer
protected ContentViewer()
- Creates a content viewer with no input, no content provider, and a
default label provider.
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
-
-
Returns:
- the input object
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 default label provider
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.
-
-
Parameters:
-
event - the change event
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
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.
|
|
|