|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.viewers.Viewer
org.eclipse.jface.viewers.ContentViewer
org.eclipse.jface.viewers.StructuredViewer
org.eclipse.jface.viewers.ColumnViewer
org.eclipse.jface.viewers.AbstractTableViewer
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).
As of 3.1 the TableViewer now supports the SWT.VIRTUAL flag. If the
underlying table is SWT.VIRTUAL, the content provider may implement
ILazyContentProvider
instead of IStructuredContentProvider
.
Note that in this case, the viewer does not support sorting or filtering.
Also note that in this case, the Widget based APIs may return null if the
element is not specified or not created yet.
Users of SWT.VIRTUAL should also avoid using getItems() from the Table within the TreeViewer as this does not necessarily generate a callback for the TreeViewer to populate the items. It also has the side effect of creating all of the items thereby eliminating the performance improvements of SWT.VIRTUAL.
SWT.VIRTUAL
,
AbstractTableViewer.doFindItem(Object)
,
AbstractTableViewer.internalRefresh(Object, boolean)
Nested Class Summary |
---|
Nested classes inherited from class org.eclipse.jface.viewers.StructuredViewer |
---|
StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders |
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 | |
---|---|
protected ColumnViewerEditor |
createViewerEditor()
Creates the viewer editor used for editing cell contents. |
protected void |
doClear(int index)
Clears the item at the given zero-relative index in the receiver. |
protected void |
doClearAll()
Clears all the items in the receiver. |
protected void |
doDeselectAll()
Deselects all selected items in the receiver. |
protected Widget |
doGetColumn(int index)
Returns the column at the given, zero-relative index in the receiver. |
protected int |
doGetColumnCount()
Returns the number of columns contained in the receiver. |
protected Item |
doGetItem(int index)
Returns the item at the given, zero-relative index in the receiver. |
protected int |
doGetItemCount()
Returns the number of items contained in the receiver. |
protected Item[] |
doGetItems()
Returns a (possibly empty) array of TableItems which are the items in the receiver. |
protected Item[] |
doGetSelection()
Returns an array of Item that are currently selected in the
receiver. |
protected int[] |
doGetSelectionIndices()
Returns the zero-relative indices of the items which are currently selected in the receiver. |
protected int |
doIndexOf(Item item)
Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. |
protected void |
doRemove(int[] indices)
Removes the items from the receiver's list at the given zero-relative indices. |
protected void |
doRemove(int start,
int end)
Removes the items from the receiver which are between the given zero-relative start and end indices (inclusive). |
protected void |
doRemoveAll()
Removes all of the items from the receiver. |
protected void |
doResetItem(Item item)
Resets the given item in the receiver. |
protected void |
doSelect(int[] indices)
Selects the items at the given zero-relative indices in the receiver. |
protected void |
doSetItemCount(int count)
Sets the number of items contained in the receiver. |
protected void |
doSetSelection(int[] indices)
Selects the items at the given zero-relative indices in the receiver. |
protected void |
doSetSelection(Item[] items)
Sets the receiver's selection to be the given array of items. |
protected void |
doShowItem(Item item)
Shows the item. |
protected void |
doShowSelection()
Shows the selection. |
Control |
getControl()
Returns the primary control associated with this viewer. |
protected Item |
getItemAt(Point p)
Returns the Item at the given widget-relative coordinates, or
null if there is no item at the given coordinates. |
Table |
getTable()
Returns this table viewer's table control. |
protected ViewerRow |
getViewerRowFromItem(Widget item)
Returns a ViewerRow associated with the given row widget. |
protected ViewerRow |
internalCreateNewRowPart(int style,
int rowIndex)
Create a new row with style at index |
void |
refresh(boolean updateLabels,
boolean reveal)
Refreshes this viewer with information freshly obtained from this viewer's model. |
void |
refresh(Object element,
boolean updateLabels,
boolean reveal)
Refreshes this viewer starting with the given element. |
void |
setSelection(ISelection selection,
boolean reveal)
Sets a new selection for this viewer and optionally makes it visible. |
Methods inherited from class org.eclipse.jface.viewers.AbstractTableViewer |
---|
add, add, assertContentProviderType, clear, doFindInputItem, doFindItem, doUpdateItem, getColumnViewerOwner, getElementAt, getLabelProvider, getRawChildren, getSelectionFromWidget, hookControl, indexForElement, inputChanged, insert, internalRefresh, internalRefresh, remove, remove, replace, reveal, setItemCount, setSelectionToWidget |
Methods inherited from class org.eclipse.jface.viewers.ColumnViewer |
---|
applyEditorValue, cancelEditing, editElement, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getLabelProvider, getViewerRow, hookEditingSupport, isCellEditorActive, refresh, refresh, setCellEditors, setCellModifier, setColumnProperties, setColumnViewerEditor, setLabelProvider, triggerEditorActivationEvent, update |
Methods inherited from class org.eclipse.jface.viewers.ContentViewer |
---|
getContentProvider, getInput, 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 |
Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider |
---|
addSelectionChangedListener, removeSelectionChangedListener, setSelection |
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 Control getControl()
Viewer
getControl
in class Viewer
public Table getTable()
protected ColumnViewerEditor createViewerEditor()
ColumnViewer
createViewerEditor
in class ColumnViewer
null
if this viewer does not
support editing cell contents.public void setSelection(ISelection selection, boolean reveal)
Sets a new selection for this viewer and optionally makes it visible. The TableViewer implementation of this method is inefficient for the ILazyContentProvider as lookup is done by indices rather than elements and may require population of the entire table in worse case.
Use Table#setSelection(int[] indices) and Table#showSelection() if you wish to set selection more efficiently when using a ILazyContentProvider.
setSelection
in class StructuredViewer
selection
- the new selectionreveal
- true
if the selection is to be made visible,
and false
otherwiseTable.setSelection(int[])
,
Table.showSelection()
protected ViewerRow getViewerRowFromItem(Widget item)
ColumnViewer
ViewerRow
associated with the given row widget. Implementations
may re-use the same instance for different row widgets; callers can only use the viewer
row locally and until the next call to this method.
getViewerRowFromItem
in class ColumnViewer
item
- the row widget
protected ViewerRow internalCreateNewRowPart(int style, int rowIndex)
internalCreateNewRowPart
in class AbstractTableViewer
style
- rowIndex
-
protected Item getItemAt(Point p)
ColumnViewer
Item
at the given widget-relative coordinates, or
null
if there is no item at the given coordinates.
getItemAt
in class ColumnViewer
p
- the widget-relative coordinates
Item
at the coordinates or null
if
there is no item at the given coordinatesprotected int doGetItemCount()
AbstractTableViewer
doGetItemCount
in class AbstractTableViewer
protected int doIndexOf(Item item)
AbstractTableViewer
doIndexOf
in class AbstractTableViewer
item
- the search item
protected void doSetItemCount(int count)
AbstractTableViewer
doSetItemCount
in class AbstractTableViewer
count
- the number of itemsprotected Item[] doGetItems()
AbstractTableViewer
doGetItems
in class AbstractTableViewer
protected int doGetColumnCount()
ColumnViewer
doGetColumnCount
in class ColumnViewer
protected Widget doGetColumn(int index)
AbstractTableViewer
doGetColumn
in class AbstractTableViewer
index
- the index of the column to return
protected Item doGetItem(int index)
AbstractTableViewer
doGetItem
in class AbstractTableViewer
index
- the index of the item to return
protected Item[] doGetSelection()
AbstractTableViewer
Item
that are currently selected in the
receiver. The order of the items is unspecified. An empty array indicates
that no items are selected.
doGetSelection
in class AbstractTableViewer
protected int[] doGetSelectionIndices()
AbstractTableViewer
doGetSelectionIndices
in class AbstractTableViewer
protected void doClearAll()
AbstractTableViewer
SWT.VIRTUAL
style, these attributes are requested
again as needed.
doClearAll
in class AbstractTableViewer
protected void doResetItem(Item item)
AbstractTableViewer
doResetItem
in class AbstractTableViewer
item
- the item to resetprotected void doRemove(int start, int end)
AbstractTableViewer
doRemove
in class AbstractTableViewer
start
- the start of the rangeend
- the end of the rangeprotected void doRemoveAll()
AbstractTableViewer
doRemoveAll
in class AbstractTableViewer
protected void doRemove(int[] indices)
AbstractTableViewer
doRemove
in class AbstractTableViewer
indices
- the array of indices of the itemsprotected void doShowItem(Item item)
AbstractTableViewer
doShowItem
in class AbstractTableViewer
item
- the item to be shownprotected void doDeselectAll()
AbstractTableViewer
doDeselectAll
in class AbstractTableViewer
protected void doSetSelection(Item[] items)
AbstractTableViewer
Items that are not in the receiver are ignored. If the receiver is single-select and multiple items are specified, then all items are ignored.
doSetSelection
in class AbstractTableViewer
items
- the array of itemsprotected void doShowSelection()
AbstractTableViewer
doShowSelection
in class AbstractTableViewer
protected void doSetSelection(int[] indices)
AbstractTableViewer
Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
doSetSelection
in class AbstractTableViewer
indices
- the indices of the items to selectprotected void doClear(int index)
AbstractTableViewer
SWT.VIRTUAL
style, these
attributes are requested again as needed.
doClear
in class AbstractTableViewer
index
- the index of the item to clearSWT.VIRTUAL
,
SWT.SetData
protected void doSelect(int[] indices)
AbstractTableViewer
If the item at a given index is not selected, it is selected. If the item at a given index was already selected, it remains selected. Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
doSelect
in class AbstractTableViewer
indices
- the array of indices for the items to selectpublic void refresh(Object element, boolean updateLabels, boolean reveal)
refresh(boolean updateLabels)
. The
methods attempts to preserve the selection.
Unlike the update
methods, this handles structural changes
to the given element (e.g. addition or removal of children). If only the
given element needs updating, it is more efficient to use the
update
methods.
Subclasses who can provide this feature can open this method for the public
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.reveal
- true
to make the preserved selection visible
afterwardspublic void refresh(boolean updateLabels, boolean reveal)
updateLabels
is true
then labels for otherwise unaffected elements are updated as well.
Otherwise, it assumes labels for existing elements are unchanged, and
labels are only obtained as needed (for example, for new elements).
Calling refresh(true)
has the same effect as
refresh()
.
Note that the implementation may still obtain labels for existing
elements even if updateLabels
is false. The intent is
simply to allow optimization where possible.
updateLabels
- true
to update labels for existing elements,
false
to only update labels as needed, assuming
that labels for existing elements are unchanged.reveal
- true
to make the preserved selection visible
afterwards
|
Eclipse Platform Release 3.3 |
|||||||||||
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, 2007. All rights reserved.