Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.viewers
Class TableViewer  view TableViewer download TableViewer.java

java.lang.Object
  extended byorg.eclipse.jface.viewers.Viewer
      extended byorg.eclipse.jface.viewers.ContentViewer
          extended byorg.eclipse.jface.viewers.StructuredViewer
              extended byorg.eclipse.jface.viewers.TableViewer
All Implemented Interfaces:
IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider
Direct Known Subclasses:
CheckboxTableViewer

public class TableViewer
extends StructuredViewer

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).


Nested Class Summary
 
Nested classes inherited from class org.eclipse.jface.viewers.StructuredViewer
StructuredViewer.UpdateItemSafeRunnable
 
Field Summary
private  org.eclipse.swt.widgets.Table table
          This viewer's table control.
private  org.eclipse.swt.custom.TableEditor tableEditor
          This viewer's table editor.
private  TableViewerImpl tableViewerImpl
          Internal table viewer implementation.
 
Fields inherited from class org.eclipse.jface.viewers.StructuredViewer
 
Fields inherited from class org.eclipse.jface.viewers.ContentViewer
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Constructor Summary
TableViewer(org.eclipse.swt.widgets.Composite parent)
          Creates a table viewer on a newly-created table control under the given parent.
TableViewer(org.eclipse.swt.widgets.Composite parent, int style)
          Creates a table viewer on a newly-created table control under the given parent.
TableViewer(org.eclipse.swt.widgets.Table table)
          Creates a table viewer on the given table control.
 
Method Summary
 void add(java.lang.Object element)
          Adds the given element to this table viewer.
 void add(java.lang.Object[] elements)
          Adds the given elements to this table viewer.
 void cancelEditing()
          Cancels a currently active cell editor.
protected  org.eclipse.swt.widgets.Widget doFindInputItem(java.lang.Object element)
          Returns the widget in this viewer's control which represents the given element if it is the viewer's input.
protected  org.eclipse.swt.widgets.Widget doFindItem(java.lang.Object element)
          Returns the widget in this viewer's control which represent the given element.
protected  void doUpdateItem(org.eclipse.swt.widgets.Widget widget, java.lang.Object element, boolean fullMap)
          Copies the attributes of the given element into the given SWT item.
 void editElement(java.lang.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.
 java.lang.Object[] getColumnProperties()
          Returns the column properties of this table viewer.
 org.eclipse.swt.widgets.Control getControl()
          Returns the primary control associated with this viewer.
 java.lang.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  java.util.List getSelectionFromWidget()
          Retrieves the selection, as a List, from the underlying widget.
 org.eclipse.swt.widgets.Table getTable()
          Returns this table viewer's table control.
protected  void hookControl(org.eclipse.swt.widgets.Control control)
          Adds event listener hooks to the given control.
protected  int indexForElement(java.lang.Object element)
           
private  void initTableViewerImpl()
          Initializes the table viewer implementation.
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.
 void insert(java.lang.Object element, int position)
          Inserts the given element into this table viewer at the given position.
protected  void internalRefresh(java.lang.Object element)
          Refreshes this viewer starting at the given element.
protected  void internalRefresh(java.lang.Object element, boolean updateLabels)
          Refreshes this viewer starting at the given element.
private  void internalRemove(java.lang.Object[] elements)
          Removes the given elements from this table viewer.
 boolean isCellEditorActive()
          Returns whether there is an active cell editor.
 void remove(java.lang.Object element)
          Removes the given element from this table viewer.
 void remove(java.lang.Object[] elements)
          Removes the given elements from this table viewer.
 void reveal(java.lang.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(java.lang.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(java.util.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.StructuredViewer
addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, associate, disassociate, equals, filter, findItem, fireDoubleClick, fireOpen, firePostSelectionChanged, getComparer, getFilteredChildren, getFilters, getItem, getRawChildren, getRoot, getSelection, getSortedChildren, getSorter, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, mapElement, needsRefilter, newHashtable, preservingSelection, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparer, setContentProvider, setInput, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMap
 
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
 
Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider
addSelectionChangedListener, removeSelectionChangedListener, setSelection
 

Field Detail

tableViewerImpl

private TableViewerImpl tableViewerImpl
Internal table viewer implementation.


table

private org.eclipse.swt.widgets.Table table
This viewer's table control.


tableEditor

private org.eclipse.swt.custom.TableEditor tableEditor
This viewer's table editor.

Constructor Detail

TableViewer

public TableViewer(org.eclipse.swt.widgets.Composite parent)
Creates a table viewer on a newly-created table control under the given parent. The table control is created using the SWT style bits 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.


TableViewer

public TableViewer(org.eclipse.swt.widgets.Composite parent,
                   int style)
Creates a table viewer on a newly-created table control under the given parent. The table control is created using the given style bits. The viewer has no input, no content provider, a default label provider, no sorter, and no filters. The table has no columns.


TableViewer

public TableViewer(org.eclipse.swt.widgets.Table table)
Creates a table viewer on the given table control. The viewer has no input, no content provider, a default label provider, no sorter, and no filters.

Method Detail

add

public void add(java.lang.Object[] elements)
Adds the given elements to this table viewer. If this viewer does not have a sorter, the elements are added at the end in the order given; otherwise the elements are inserted at appropriate positions.

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.


add

public void add(java.lang.Object element)
Adds the given element to this table viewer. If this viewer does not have a sorter, the element is added at the end; otherwise the element is inserted at the appropriate position.

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.


cancelEditing

public void cancelEditing()
Cancels a currently active cell editor. All changes already done in the cell editor are lost.


doFindInputItem

protected org.eclipse.swt.widgets.Widget doFindInputItem(java.lang.Object element)
Description copied from class: StructuredViewer
Returns the widget in this viewer's control which represents the given element if it is the viewer's input.

This method is internal to the framework; subclassers should not call this method.

Specified by:
doFindInputItem in class StructuredViewer

doFindItem

protected org.eclipse.swt.widgets.Widget doFindItem(java.lang.Object element)
Description copied from class: StructuredViewer
Returns the widget in this viewer's control which represent the given element. This method searchs all the children of the input element.

This method is internal to the framework; subclassers should not call this method.

Specified by:
doFindItem in class StructuredViewer

doUpdateItem

protected void doUpdateItem(org.eclipse.swt.widgets.Widget widget,
                            java.lang.Object element,
                            boolean fullMap)
Description copied from class: StructuredViewer
Copies the attributes of the given element into the given SWT item. The element map is updated according to the value of 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.

Specified by:
doUpdateItem in class StructuredViewer

editElement

public void editElement(java.lang.Object element,
                        int column)
Starts editing the given element.


getCellEditors

public CellEditor[] getCellEditors()
Returns the cell editors of this table viewer.


getCellModifier

public ICellModifier getCellModifier()
Returns the cell modifier of this table viewer.


getColumnProperties

public java.lang.Object[] getColumnProperties()
Returns the column properties of this table viewer. The properties must correspond with the columns of the table control. They are used to identify the column in a cell modifier.


getControl

public org.eclipse.swt.widgets.Control getControl()
Description copied from class: Viewer
Returns the primary control associated with this viewer.

Specified by:
getControl in class Viewer

getElementAt

public java.lang.Object getElementAt(int index)
Returns the element with the given index from this table viewer. Returns null if the index is out of range.

This method is internal to the framework.


getLabelProvider

public 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. 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.

Overrides:
getLabelProvider in class ContentViewer

getSelectionFromWidget

protected java.util.List getSelectionFromWidget()
Description copied from class: StructuredViewer
Retrieves the selection, as a List, from the underlying widget.

Specified by:
getSelectionFromWidget in class StructuredViewer

getTable

public org.eclipse.swt.widgets.Table getTable()
Returns this table viewer's table control.


hookControl

protected void hookControl(org.eclipse.swt.widgets.Control control)
Description copied from class: ContentViewer
Adds event listener hooks to the given control.

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.

Overrides:
hookControl in class StructuredViewer

indexForElement

protected int indexForElement(java.lang.Object element)

initTableViewerImpl

private void initTableViewerImpl()
Initializes the table viewer implementation.


inputChanged

protected void inputChanged(java.lang.Object input,
                            java.lang.Object oldInput)
Description copied from class: Viewer
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.

Overrides:
inputChanged in class Viewer

insert

public void insert(java.lang.Object element,
                   int position)
Inserts the given element into this table viewer at the given position. If this viewer has a sorter, the position is ignored and the element is inserted at the correct position in the sort order.

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.


internalRefresh

protected void internalRefresh(java.lang.Object element)
Description copied from class: StructuredViewer
Refreshes this viewer starting at the given element.

Specified by:
internalRefresh in class StructuredViewer

internalRefresh

protected void internalRefresh(java.lang.Object element,
                               boolean updateLabels)
Description copied from class: StructuredViewer
Refreshes this viewer starting at the given element. Labels are updated as described in 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).

Overrides:
internalRefresh in class StructuredViewer

internalRemove

private void internalRemove(java.lang.Object[] elements)
Removes the given elements from this table viewer.


isCellEditorActive

public boolean isCellEditorActive()
Returns whether there is an active cell editor.


remove

public void remove(java.lang.Object[] elements)
Removes the given elements from this table viewer. The selection is updated if required.

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.


remove

public void remove(java.lang.Object element)
Removes the given element from this table viewer. The selection is updated if necessary.

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.


reveal

public void reveal(java.lang.Object element)
Description copied from class: StructuredViewer
Ensures that the given element is visible, scrolling the viewer if necessary. The selection is unchanged.

Specified by:
reveal in class StructuredViewer

setCellEditors

public void setCellEditors(CellEditor[] editors)
Sets the cell editors of this table viewer.


setCellModifier

public void setCellModifier(ICellModifier modifier)
Sets the cell modifier of this table viewer.


setColumnProperties

public void setColumnProperties(java.lang.String[] columnProperties)
Sets the column properties of this table viewer. The properties must correspond with the columns of the table control. They are used to identify the column in a cell modifier.


setLabelProvider

public 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. 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.

Overrides:
setLabelProvider in class ContentViewer

setSelectionToWidget

protected void setSelectionToWidget(java.util.List list,
                                    boolean reveal)
Description copied from class: StructuredViewer
Parlays the given list of selected elements into selections on this viewer's control.

Subclasses should override to set their selection based on the given list of elements.

Specified by:
setSelectionToWidget in class StructuredViewer