|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.viewers.Viewer | +--org.eclipse.jface.viewers.ContentViewer | +--org.eclipse.jface.viewers.StructuredViewer | +--org.eclipse.jface.viewers.TableViewer
A concrete viewer based on a SWT Table
control.
This class is not intended to be subclassed outside the viewer framework. It is designed to be instantiated with a pre-existing SWT table control and configured with a domain-specific content provider, table label provider, element filter (optional), and element sorter (optional).
Label providers for table viewers must implement either the ITableLabelProvider
or the ILabelProvider
interface (see TableViewer.setLabelProvider
for more details).
Field Summary |
Fields inherited from class org.eclipse.jface.viewers.Viewer |
WIDGET_DATA_KEY |
Constructor Summary | |
TableViewer(Composite parent)
Creates a table viewer on a newly-created table control under the given parent. |
|
TableViewer(Composite parent,
int style)
Creates a table viewer on a newly-created table control under the given parent. |
|
TableViewer(Table table)
Creates a table viewer on the given table control. |
Method Summary | |
void |
add(Object element)
Adds the given element to this table viewer. |
void |
add(Object[] elements)
Adds the given elements to this table viewer. |
void |
cancelEditing()
Cancels a currently active cell editor. |
protected Widget |
doFindInputItem(Object element)
Returns the widget in this viewer's control which represents the given element if it is the viewer's input. |
protected Widget |
doFindItem(Object element)
Returns the widget in this viewer's control which represent the given element. |
protected void |
doUpdateItem(Widget widget,
Object element,
boolean fullMap)
Copies the attributes of the given element into the given SWT item. |
void |
editElement(Object element,
int column)
Starts editing the given element. |
CellEditor[] |
getCellEditors()
Returns the cell editors of this table viewer. |
ICellModifier |
getCellModifier()
Returns the cell modifier of this table viewer. |
Object[] |
getColumnProperties()
Returns the column properties of this table viewer. |
Control |
getControl()
Returns the primary control associated with this viewer. |
Object |
getElementAt(int index)
Returns the element with the given index from this table viewer. |
IBaseLabelProvider |
getLabelProvider()
The table viewer implementation of this Viewer framework
method returns the label provider, which in the case of table
viewers will be an instance of either ITableLabelProvider
or ILabelProvider . |
protected List |
getSelectionFromWidget()
Retrieves the selection, as a List , from the underlying widget. |
Table |
getTable()
Returns this table viewer's table control. |
protected void |
hookControl(Control control)
Adds event listener hooks to the given control. |
protected int |
indexForElement(Object element)
|
protected void |
inputChanged(Object input,
Object oldInput)
Internal hook method called when the input to this viewer is initially set or subsequently changed. |
void |
insert(Object element,
int position)
Inserts the given element into this table viewer at the given position. |
protected void |
internalRefresh(Object element)
Refreshes this viewer starting at the given element. |
protected void |
internalRefresh(Object element,
boolean updateLabels)
Refreshes this viewer starting at the given element. |
boolean |
isCellEditorActive()
Returns whether there is an active cell editor. |
void |
remove(Object element)
Removes the given element from this table viewer. |
void |
remove(Object[] elements)
Removes the given elements from this table viewer. |
void |
reveal(Object element)
Ensures that the given element is visible, scrolling the viewer if necessary. |
void |
setCellEditors(CellEditor[] editors)
Sets the cell editors of this table viewer. |
void |
setCellModifier(ICellModifier modifier)
Sets the cell modifier of this table viewer. |
void |
setColumnProperties(String[] columnProperties)
Sets the column properties of this table viewer. |
void |
setLabelProvider(IBaseLabelProvider labelProvider)
The table viewer implementation of this Viewer framework
method ensures that the given label provider is an instance
of either ITableLabelProvider or ILabelProvider . |
protected void |
setSelectionToWidget(List list,
boolean reveal)
Parlays the given list of selected elements into selections on this viewer's control. |
Methods inherited from class org.eclipse.jface.viewers.ContentViewer |
getContentProvider, getInput, handleDispose, labelProviderChanged |
Methods inherited from class org.eclipse.jface.viewers.Viewer |
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TableViewer(Composite parent)
MULTI, H_SCROLL, V_SCROLL,
and BORDER
.
The viewer has no input, no content provider, a default label provider,
no sorter, and no filters. The table has no columns.
parent
- the parent controlpublic TableViewer(Composite parent, int style)
parent
- the parent controlstyle
- SWT style bitspublic TableViewer(Table table)
table
- the table controlMethod Detail |
public void add(Object[] elements)
This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.
elements
- the elements to addpublic void add(Object element)
This method should be called (by the content provider) when a single element has been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous addition of multiple elements.
element
- the element to addpublic void cancelEditing()
protected Widget doFindInputItem(Object element)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
doFindInputItem
in class StructuredViewer
null
if noneprotected Widget doFindItem(Object element)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
doFindItem
in class StructuredViewer
null
if noneprotected void doUpdateItem(Widget widget, Object element, boolean fullMap)
StructuredViewer
fullMap
.
If fullMap
is true
then the current mapping
from element to widgets is removed and the new mapping is added.
If fullmap is false
then only the new map gets installed.
Installing only the new map is necessary in cases where only
the order of elements changes but not the set of elements.
This method is internal to the framework; subclassers should not call this method.
doUpdateItem
in class StructuredViewer
widget
- element
- the elementfullMap
- true
if mappings are added and removed,
and false
if only the new map gets installedpublic void editElement(Object element, int column)
element
- the elementcolumn
- the column numberpublic CellEditor[] getCellEditors()
public ICellModifier getCellModifier()
public Object[] getColumnProperties()
public Control getControl()
Viewer
getControl
in class Viewer
public Object getElementAt(int index)
null
if the index is out of range.
This method is internal to the framework.
index
- the zero-based index
null
if the
index is out of rangepublic IBaseLabelProvider getLabelProvider()
Viewer
framework
method returns the label provider, which in the case of table
viewers will be an instance of either ITableLabelProvider
or ILabelProvider
.
If it is an ITableLabelProvider
, then it provides a
separate label text and image for each column. If it is an
ILabelProvider
, then it provides only the label text
and image for the first column, and any remaining columns are blank.
getLabelProvider
in class ContentViewer
protected List getSelectionFromWidget()
StructuredViewer
List
, from the underlying widget.
getSelectionFromWidget
in class StructuredViewer
public Table getTable()
protected void hookControl(Control control)
ContentViewer
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.
hookControl
in class StructuredViewer
control
- the controlprotected int indexForElement(Object element)
protected void inputChanged(Object input, Object oldInput)
Viewer
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.
inputChanged
in class Viewer
input
- the new input of this viewer, or null
if noneoldInput
- the old input element or null
if there
was previously no inputpublic void insert(Object element, int position)
This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.
element
- the elementposition
- a 0-based position relative to the model, or -1 to indicate the last positionprotected void internalRefresh(Object element)
StructuredViewer
internalRefresh
in class StructuredViewer
element
- the elementprotected void internalRefresh(Object element, boolean updateLabels)
StructuredViewer
refresh(boolean updateLabels)
.
The default implementation simply calls internalRefresh(element)
,
ignoring updateLabels
.
If this method is overridden to do the actual refresh, then
internalRefresh(Object element)
should simply
call internalRefresh(element, true)
.
internalRefresh
in class StructuredViewer
element
- the elementupdateLabels
- true
to update labels for existing elements,
false
to only update labels as needed, assuming that labels
for existing elements are unchanged.public boolean isCellEditorActive()
true
if there is an active cell editor, and
false
otherwisepublic void remove(Object[] elements)
This method should be called (by the content provider) when elements have been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.
elements
- the elements to removepublic void remove(Object element)
This method should be called (by the content provider) when a single element has been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous removal of multiple elements.
element
- the elementpublic void reveal(Object element)
StructuredViewer
reveal
in class StructuredViewer
element
- the element to revealpublic void setCellEditors(CellEditor[] editors)
editors
- the list of cell editorspublic void setCellModifier(ICellModifier modifier)
modifier
- the cell modifierpublic void setColumnProperties(String[] columnProperties)
columnProperties
- the list of column propertiespublic void setLabelProvider(IBaseLabelProvider labelProvider)
Viewer
framework
method ensures that the given label provider is an instance
of either ITableLabelProvider
or ILabelProvider
.
If it is an ITableLabelProvider
, then it provides a
separate label text and image for each column. If it is an
ILabelProvider
, then it provides only the label text
and image for the first column, and any remaining columns are blank.
setLabelProvider
in class ContentViewer
labelProvider
- the label provider, or null
if noneprotected void setSelectionToWidget(List list, boolean reveal)
StructuredViewer
Subclasses should override to set their selection based on the given list of elements.
setSelectionToWidget
in class StructuredViewer
list
- list of selected elements (element type: Object
)
or null
if the selection is to be clearedreveal
- true
if the selection is to be made
visible, and false
otherwise
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |