|
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
This is a widget independent class implementors of
Table
like widgets can use to provide a
viewer on top of their widget implementations.
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 | |
---|---|
AbstractTableViewer()
Create the new viewer for table like widgets |
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. |
protected void |
assertContentProviderType(IContentProvider provider)
Assert that the content provider is of one of the supported types. |
void |
clear(int index)
Clear the table item at the specified index |
protected abstract void |
doClear(int index)
Clears the item at the given zero-relative index in the receiver. |
protected abstract void |
doClearAll()
Clears all the items in the receiver. |
protected abstract void |
doDeselectAll()
Deselects all selected items in the receiver. |
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 abstract Widget |
doGetColumn(int index)
Returns the column at the given, zero-relative index in the receiver. |
protected abstract Item |
doGetItem(int index)
Returns the item at the given, zero-relative index in the receiver. |
protected abstract int |
doGetItemCount()
Returns the number of items contained in the receiver. |
protected abstract Item[] |
doGetItems()
Returns a (possibly empty) array of TableItems which are the items in the receiver. |
protected abstract Item[] |
doGetSelection()
Returns an array of Item that are currently selected in the
receiver. |
protected abstract int[] |
doGetSelectionIndices()
Returns the zero-relative indices of the items which are currently selected in the receiver. |
protected abstract 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 abstract void |
doRemove(int[] indices)
Removes the items from the receiver's list at the given zero-relative indices. |
protected abstract 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 abstract void |
doRemoveAll()
Removes all of the items from the receiver. |
protected abstract void |
doResetItem(Item item)
Resets the given item in the receiver. |
protected abstract void |
doSelect(int[] indices)
Selects the items at the given zero-relative indices in the receiver. |
protected abstract void |
doSetItemCount(int count)
Sets the number of items contained in the receiver. |
protected abstract void |
doSetSelection(int[] indices)
Selects the items at the given zero-relative indices in the receiver. |
protected abstract void |
doSetSelection(Item[] items)
Sets the receiver's selection to be the given array of items. |
protected abstract void |
doShowItem(Item item)
Shows the item. |
protected abstract void |
doShowSelection()
Shows the selection. |
protected void |
doUpdateItem(Widget widget,
Object element,
boolean fullMap)
Copies the attributes of the given element into the given SWT item. |
protected Widget |
getColumnViewerOwner(int columnIndex)
Returns the column widget at the given column index. |
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 Object[] |
getRawChildren(Object parent)
Returns the children of the given parent without sorting and filtering them. |
protected List |
getSelectionFromWidget()
Retrieves the selection, as a List , from the underlying
widget. |
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 abstract ViewerRow |
internalCreateNewRowPart(int style,
int rowIndex)
Create a new row. |
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. |
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 |
replace(Object element,
int index)
Replace the entries starting at index with elements. |
void |
reveal(Object element)
Ensures that the given element is visible, scrolling the viewer if necessary. |
void |
setItemCount(int count)
Set the item count of the receiver. |
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.ColumnViewer |
---|
applyEditorValue, cancelEditing, createViewerEditor, doGetColumnCount, editElement, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getItemAt, getLabelProvider, getViewerRow, getViewerRowFromItem, 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, getControl, 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 AbstractTableViewer()
Method Detail |
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 ColumnViewer
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 addprotected abstract ViewerRow internalCreateNewRowPart(int style, int rowIndex)
style
- the style for the new rowrowIndex
- the index of the row or -1 if the row is appended at the end
public 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 addprotected Widget doFindInputItem(Object element)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
doFindInputItem
in class StructuredViewer
element
-
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
element
-
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
full map 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
- elementfullMap
- true
if mappings are added and removed, and
false
if only the new map gets installedprotected Widget getColumnViewerOwner(int columnIndex)
ColumnViewer
getColumnViewerOwner
in class ColumnViewer
columnIndex
- the column index
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
protected int indexForElement(Object element)
element
- the element to insert
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 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.
NOTE: removing an object from a virtual table will decrement the itemCount.
element
- the elementpublic void reveal(Object element)
StructuredViewer
reveal
in class StructuredViewer
element
- the element to revealprotected 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
otherwisepublic void setItemCount(int count)
count
- the new table size.public void replace(Object element, int index)
element
- index
- ILazyContentProvider
public void clear(int index)
index
- the index of the table item to be clearedprotected Object[] getRawChildren(Object parent)
StructuredViewer
Returns an empty array if the given parent is null
.
getRawChildren
in class ColumnViewer
protected void assertContentProviderType(IContentProvider provider)
StructuredViewer
assertContentProviderType
in class StructuredViewer
provider
- protected abstract int doIndexOf(Item item)
item
- the search item
protected abstract int doGetItemCount()
protected abstract void doSetItemCount(int count)
count
- the number of itemsprotected abstract Item[] doGetItems()
protected abstract Widget doGetColumn(int index)
index
- the index of the column to return
IllegalArgumentException
- -
if the index is not between 0 and the number of elements
in the list minus 1 (inclusive)protected abstract Item doGetItem(int index)
index
- the index of the item to return
IllegalArgumentException
- -
if the index is not between 0 and the number of elements
in the list minus 1 (inclusive)protected abstract Item[] doGetSelection()
Item
that are currently selected in the
receiver. The order of the items is unspecified. An empty array indicates
that no items are selected.
protected abstract int[] doGetSelectionIndices()
protected abstract void doClearAll()
SWT.VIRTUAL
style, these attributes are requested
again as needed.
protected abstract void doResetItem(Item item)
item
- the item to resetprotected abstract void doRemove(int start, int end)
start
- the start of the rangeend
- the end of the range
IllegalArgumentException
- -
if either the start or end are not between 0 and the
number of elements in the list minus 1 (inclusive)protected abstract void doRemoveAll()
protected abstract void doRemove(int[] indices)
indices
- the array of indices of the items
IllegalArgumentException
- -
if the array is null, or if any of the indices is not
between 0 and the number of elements in the list minus 1
(inclusive)protected abstract void doShowItem(Item item)
item
- the item to be shown
IllegalArgumentException
- -
if the item is nullprotected abstract void doDeselectAll()
protected abstract void doSetSelection(Item[] items)
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.
items
- the array of items
IllegalArgumentException
- -
if the array of items is nullprotected abstract void doShowSelection()
protected abstract void doSetSelection(int[] indices)
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.
indices
- the indices of the items to select
IllegalArgumentException
- -
if the array of indices is nullprotected abstract void doClear(int index)
SWT.VIRTUAL
style, these
attributes are requested again as needed.
index
- the index of the item to clear
IllegalArgumentException
- -
if the index is not between 0 and the number of elements
in the list minus 1 (inclusive)SWT.VIRTUAL
,
SWT.SetData
protected abstract void doSelect(int[] indices)
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.
indices
- the array of indices for the items to select
IllegalArgumentException
- - if the array of indices is null
|
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.