|
Eclipse Platform Release 3.6 |
|||||||||
| 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
public class 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.
Users setting up an editable table with more than 1 column have to pass the SWT.FULL_SELECTION style bit
SWT.VIRTUAL,
doFindItem(Object),
AbstractTableViewer.internalRefresh(Object, boolean)| Nested Class Summary |
|---|
| Nested classes/interfaces 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 |
doFindItem(java.lang.Object element)
Returns the widget in this viewer's control which represent the given element. |
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(java.lang.Object element,
boolean updateLabels,
boolean reveal)
Refreshes this viewer starting with the given element. |
void |
remove(java.lang.Object[] elements)
Removes the given elements from this table viewer. |
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, doUpdateItem, getColumnViewerOwner, getElementAt, getLabelProvider, getRawChildren, getSelectionFromWidget, handleDispose, hookControl, indexForElement, inputChanged, insert, internalRefresh, internalRefresh, remove, replace, reveal, setItemCount, setSelectionToWidget |
| Methods inherited from class org.eclipse.jface.viewers.ColumnViewer |
|---|
applyEditorValue, cancelEditing, checkBusy, editElement, getCell, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getLabelProvider, getViewerRow, hookEditingSupport, isBusy, isCellEditorActive, refresh, refresh, setBusy, 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 control
public TableViewer(Composite parent,
int style)
parent - the parent controlstyle - SWT style bitspublic TableViewer(Table table)
table - the table control| Method Detail |
|---|
public Control getControl()
Viewer
getControl in class Viewerpublic Table getTable()
protected ColumnViewerEditor createViewerEditor()
ColumnViewer
createViewerEditor in class ColumnViewernull 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 StructuredViewerselection - the new selectionreveal - true if the selection is to be made visible, and
false otherwiseTable.setSelection(int[]),
Table.showSelection()protected ViewerRow getViewerRowFromItem(Widget item)
ColumnViewerViewerRow 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 ColumnVieweritem - the row widget
protected ViewerRow internalCreateNewRowPart(int style,
int rowIndex)
internalCreateNewRowPart in class AbstractTableViewerstyle - rowIndex -
protected Item getItemAt(Point p)
ColumnViewerItem at the given widget-relative coordinates, or
null if there is no item at the given coordinates.
getItemAt in class ColumnViewerp - 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 AbstractTableViewerprotected int doIndexOf(Item item)
AbstractTableViewer
doIndexOf in class AbstractTableVieweritem - the search item
protected void doSetItemCount(int count)
AbstractTableViewer
doSetItemCount in class AbstractTableViewercount - the number of itemsprotected Item[] doGetItems()
AbstractTableViewer
doGetItems in class AbstractTableViewerprotected int doGetColumnCount()
ColumnViewer
doGetColumnCount in class ColumnViewerprotected Widget doGetColumn(int index)
AbstractTableViewer
doGetColumn in class AbstractTableViewerindex - the index of the column to return
protected Item doGetItem(int index)
AbstractTableViewer
doGetItem in class AbstractTableViewerindex - the index of the item to return
protected Item[] doGetSelection()
AbstractTableViewerItem 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 AbstractTableViewerprotected int[] doGetSelectionIndices()
AbstractTableViewer
doGetSelectionIndices in class AbstractTableViewerprotected void doClearAll()
AbstractTableViewerSWT.VIRTUAL style, these attributes are requested
again as needed.
doClearAll in class AbstractTableViewerprotected void doResetItem(Item item)
AbstractTableViewer
doResetItem in class AbstractTableVieweritem - the item to reset
protected void doRemove(int start,
int end)
AbstractTableViewer
doRemove in class AbstractTableViewerstart - the start of the rangeend - the end of the rangeprotected void doRemoveAll()
AbstractTableViewer
doRemoveAll in class AbstractTableViewerprotected void doRemove(int[] indices)
AbstractTableViewer
doRemove in class AbstractTableViewerindices - the array of indices of the itemsprotected void doShowItem(Item item)
AbstractTableViewer
doShowItem in class AbstractTableVieweritem - the item to be shownprotected void doDeselectAll()
AbstractTableViewer
doDeselectAll in class AbstractTableViewerprotected void doSetSelection(Item[] items)
AbstractTableViewerItems 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 AbstractTableVieweritems - the array of itemsprotected void doShowSelection()
AbstractTableViewer
doShowSelection in class AbstractTableViewerprotected void doSetSelection(int[] indices)
AbstractTableViewerIndices 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 AbstractTableViewerindices - the indices of the items to selectprotected void doClear(int index)
AbstractTableViewerSWT.VIRTUAL style, these
attributes are requested again as needed.
doClear in class AbstractTableViewerindex - the index of the item to clearSWT.VIRTUAL,
SWT.SetDataprotected void doSelect(int[] indices)
AbstractTableViewerIf 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 AbstractTableViewerindices - the array of indices for the items to select
public void refresh(java.lang.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 afterwards
public 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 afterwardspublic void remove(java.lang.Object[] elements)
AbstractTableViewerThis 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.
remove in class AbstractTableViewerelements - the elements to removeprotected Widget doFindItem(java.lang.Object element)
StructuredViewerThis method is internal to the framework; subclassers should not call this method.
doFindItem in class AbstractTableViewernull if none
|
Eclipse Platform Release 3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.