|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ viewers overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.jface.viewers
Class Viewer

java.lang.Objectorg.eclipse.jface.viewers.Viewer
- All Implemented Interfaces:
- IInputProvider, IInputSelectionProvider, ISelectionProvider
- Direct Known Subclasses:
- ContentViewer
- public abstract class Viewer
- extends java.lang.Object
- implements IInputSelectionProvider
- extends java.lang.Object
A viewer is a model-based adapter on a widget.
A viewer can be created as an adapter on a pre-existing control (e.g.,
creating a ListViewer on an existing List control).
All viewers also provide a convenience constructor for creating the control.
Implementing a concrete 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)
| Field Summary | |
private boolean |
helpHooked
Remembers whether we've hooked the help listener on the control or not. |
private org.eclipse.swt.events.HelpListener |
helpListener
Help listener for the control, created lazily when client's first help listener is added. |
private org.eclipse.jface.util.ListenerList |
helpListeners
List of help request listeners (element type: org.eclipse.swt.events.HelpListener). |
private java.lang.String[] |
keys
The names of this viewer's properties. |
private org.eclipse.jface.util.ListenerList |
selectionChangedListeners
List of selection change listeners (element type: ISelectionChangedListener). |
private java.lang.Object[] |
values
The values of this viewer's properties. |
protected static java.lang.String |
WIDGET_DATA_KEY
Unique key for associating element data with widgets. |
| Constructor Summary | |
protected |
Viewer()
Creates a new viewer. |
| Method Summary | |
void |
addHelpListener(org.eclipse.swt.events.HelpListener listener)
Adds a listener for help requests in this viewer. |
void |
addSelectionChangedListener(ISelectionChangedListener listener)
Adds a listener for selection changes in this selection provider. |
protected void |
fireHelpRequested(org.eclipse.swt.events.HelpEvent event)
Notifies any help listeners that help has been requested. |
protected void |
fireSelectionChanged(SelectionChangedEvent event)
Notifies any selection changed listeners that the viewer's selection has changed. |
abstract org.eclipse.swt.widgets.Control |
getControl()
Returns the primary control associated with this viewer. |
java.lang.Object |
getData(java.lang.String key)
Returns the value of the property with the given name, or null if the property is not found. |
abstract java.lang.Object |
getInput()
Returns the input. |
abstract ISelection |
getSelection()
Returns the current selection for this provider. |
protected void |
handleHelpRequest(org.eclipse.swt.events.HelpEvent event)
Handles a help request from the underlying SWT control. |
protected void |
inputChanged(java.lang.Object input,
java.lang.Object oldInput)
Internal hook method called when the input to this viewer is initially set or subsequently changed. |
abstract void |
refresh()
Refreshes this viewer completely with information freshly obtained from this viewer's model. |
void |
removeHelpListener(org.eclipse.swt.events.HelpListener listener)
Removes the given help listener from this viewer. |
void |
removeSelectionChangedListener(ISelectionChangedListener listener)
Removes the given selection change listener from this selection provider. |
org.eclipse.swt.widgets.Item |
scrollDown(int x,
int y)
Scrolls the viewer's control down by one item from the given display-relative coordinates. |
org.eclipse.swt.widgets.Item |
scrollUp(int x,
int y)
Scrolls the viewer's control up by one item from the given display-relative coordinates. |
void |
setData(java.lang.String key,
java.lang.Object value)
Sets the value of the property with the given name to the given value, or to null if the property is to be
removed. |
abstract void |
setInput(java.lang.Object input)
Sets or clears the input for this viewer. |
void |
setSelection(ISelection selection)
The viewer implementation of this ISelectionProvider
method make the new selection for this viewer without making it visible. |
abstract void |
setSelection(ISelection selection,
boolean reveal)
Sets a new selection for this viewer and optionally makes it visible. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
selectionChangedListeners
private org.eclipse.jface.util.ListenerList selectionChangedListeners
- List of selection change listeners (element type:
ISelectionChangedListener).
helpListeners
private org.eclipse.jface.util.ListenerList helpListeners
- List of help request listeners (element type:
org.eclipse.swt.events.HelpListener). Help request listeners.
keys
private java.lang.String[] keys
- The names of this viewer's properties.
nullif this viewer has no properties.- See Also:
setData(java.lang.String, java.lang.Object)55
values
private java.lang.Object[] values
- The values of this viewer's properties.
nullif this viewer has no properties. This array parallels the value of thekeysfield.- See Also:
setData(java.lang.String, java.lang.Object)55
helpHooked
private boolean helpHooked
- Remembers whether we've hooked the help listener on the control or not.
helpListener
private org.eclipse.swt.events.HelpListener helpListener
- Help listener for the control, created lazily when client's first help listener is added.
WIDGET_DATA_KEY
protected static final java.lang.String WIDGET_DATA_KEY
- Unique key for associating element data with widgets.
| Constructor Detail |
Viewer
protected Viewer()
- Creates a new viewer.
| Method Detail |
addHelpListener
public void addHelpListener(org.eclipse.swt.events.HelpListener listener)
- Adds a listener for help requests in this viewer.
Has no effect if an identical listener is already registered.
addSelectionChangedListener
public void addSelectionChangedListener(ISelectionChangedListener listener)
- Description copied from interface:
ISelectionProvider - Adds a listener for selection changes in this selection provider.
Has no effect if an identical listener is already registered.
- Specified by:
addSelectionChangedListenerin interfaceISelectionProvider
fireHelpRequested
protected void fireHelpRequested(org.eclipse.swt.events.HelpEvent event)
- Notifies any help listeners that help has been requested.
Only listeners registered at the time this method is called are notified.
fireSelectionChanged
protected void fireSelectionChanged(SelectionChangedEvent event)
- Notifies any selection changed listeners that the viewer's selection has changed.
Only listeners registered at the time this method is called are notified.
getControl
public abstract org.eclipse.swt.widgets.Control getControl()
- Returns the primary control associated with this viewer.
getData
public java.lang.Object getData(java.lang.String key)
- Returns the value of the property with the given name,
or
nullif the property is not found.The default implementation performs a (linear) search of an internal table. Overriding this method is generally not required if the number of different keys is small. If a more efficient representation of a viewer's properties is required, override both
getDataandsetData.
getInput
public abstract java.lang.Object getInput()
- Description copied from interface:
IInputProvider - Returns the input.
- Specified by:
getInputin interfaceIInputProvider
getSelection
public abstract ISelection getSelection()
- Description copied from interface:
ISelectionProvider - Returns the current selection for this provider.
- Specified by:
getSelectionin interfaceISelectionProvider
handleHelpRequest
protected void handleHelpRequest(org.eclipse.swt.events.HelpEvent event)
- Handles a help request from the underlying SWT control.
The default behavior is to fire a help request,
with the event's data modified to hold this viewer.
inputChanged
protected void inputChanged(java.lang.Object input, java.lang.Object oldInput)
- Internal hook method called when the input to this viewer is
initially set or subsequently changed.
The default implementation does nothing. Subclassers may override this method to do something when a viewer's input is set. A typical use is populate the viewer.
refresh
public abstract void refresh()
- Refreshes this viewer completely with information freshly obtained from this
viewer's model.
removeHelpListener
public void removeHelpListener(org.eclipse.swt.events.HelpListener listener)
- Removes the given help listener from this viewer.
Has no affect if an identical listener is not registered.
removeSelectionChangedListener
public void removeSelectionChangedListener(ISelectionChangedListener listener)
- Description copied from interface:
ISelectionProvider - Removes the given selection change listener from this selection provider.
Has no affect if an identical listener is not registered.
- Specified by:
removeSelectionChangedListenerin interfaceISelectionProvider
scrollDown
public org.eclipse.swt.widgets.Item scrollDown(int x, int y)
- Scrolls the viewer's control down by one item from the given
display-relative coordinates. Returns the newly revealed Item,
or
nullif no scrolling occurred or if the viewer doesn't represent an item-based widget.
scrollUp
public org.eclipse.swt.widgets.Item scrollUp(int x, int y)
- Scrolls the viewer's control up by one item from the given
display-relative coordinates. Returns the newly revealed Item,
or
nullif no scrolling occurred or if the viewer doesn't represent an item-based widget.
setData
public void setData(java.lang.String key, java.lang.Object value)
- Sets the value of the property with the given name to the
given value, or to
nullif the property is to be removed. If this viewer has such a property, its value is replaced; otherwise a new property is added.The default implementation records properties in an internal table which is searched linearly. Overriding this method is generally not required if the number of different keys is small. If a more efficient representation of a viewer's properties is required, override both
getDataandsetData.
setInput
public abstract void setInput(java.lang.Object input)
- Sets or clears the input for this viewer.
setSelection
public void setSelection(ISelection selection)
- The viewer implementation of this
ISelectionProvidermethod make the new selection for this viewer without making it visible.This method is equivalent to
setSelection(selection,false).- Specified by:
setSelectionin interfaceISelectionProvider
setSelection
public abstract void setSelection(ISelection selection, boolean reveal)
- Sets a new selection for this viewer and optionally makes it visible.
Subclasses must implement this method.
|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ viewers overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.eclipse.jface.viewers.Viewer