Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.viewers
Class AbstractTableViewer

java.lang.Object
  extended by 

org.eclipse.jface.viewers.Viewer
      extended by 

org.eclipse.jface.viewers.ContentViewer
          extended by 

org.eclipse.jface.viewers.StructuredViewer
              extended by 

org.eclipse.jface.viewers.ColumnViewer
                  extended by 
org.eclipse.jface.viewers.AbstractTableViewer
All Implemented Interfaces:
IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider
Direct Known Subclasses:
TableViewer

public abstract class AbstractTableViewer
extends ColumnViewer

This is a widget independent class implementors of Table like widgets can use to provide a viewer on top of their widget implementations.

Since:
3.3

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
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 handleDispose ( DisposeEvent event)
          Handles a dispose event on this viewer's 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 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 element at the given index with the given element.
 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, checkBusy, createViewerEditor, doGetColumnCount, editElement, getCell, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getItemAt, getLabelProvider, getViewerRow, getViewerRowFromItem, hookEditingSupport, isBusy, isCellEditorActive, refresh, refresh, setBusy, setCellEditors, setCellModifier, setColumnProperties, setColumnViewerEditor, setLabelProvider, triggerEditorActivationEvent, update
 
Methods inherited from class org.eclipse.jface.viewers. StructuredViewer
addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, associate, buildLabel, disassociate, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getRoot, getSelection, getSortedChildren, getSorter, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, internalUpdate, mapElement, needsRefilter, preservingSelection, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparator, setComparer, setContentProvider, setFilters, setInput, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapAllElements, unmapElement, unmapElement, update, updateItem, updateSelection, usingElementMap
 
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

AbstractTableViewer

public AbstractTableViewer()
Create the new viewer for table like widgets

Method Detail

hookControl

protected void hookControl(
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 ColumnViewer
Parameters:
control - the control

handleDispose

protected void handleDispose(
DisposeEvent event)
Description copied from class: ContentViewer
Handles a dispose event on this viewer's control.

The ContentViewer implementation of this method disposes of this viewer's label provider and content provider (if it has one). Subclasses should override this method to perform any additional cleanup of resources; however, overriding methods must invoke super.handleDispose.

Overrides:
handleDispose in class StructuredViewer
Parameters:
event - a dispose event

add

public void add(
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.

Parameters:
elements - the elements to add

internalCreateNewRowPart

protected abstract 
ViewerRow internalCreateNewRowPart(int style,
                                                      int rowIndex)
Create a new row. Callers can only use the returned object locally and before making the next call on the viewer since it may be re-used for subsequent method calls.

Parameters:
style - the style for the new row
rowIndex - the index of the row or -1 if the row is appended at the end
Returns:
the newly created row

add

public void add(
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.

Parameters:
element - the element to add

doFindInputItem

protected 
Widget doFindInputItem(
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
Returns:
the corresponding widget, or null if none

doFindItem

protected 
Widget doFindItem(
Object element)
Description copied from class: StructuredViewer
Returns the widget in this viewer's control which represent the given element. This method searches 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
Returns:
the corresponding widget, or null if none

doUpdateItem

protected void doUpdateItem(
Widget widget,
                            
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 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.

Specified by:
doUpdateItem in class StructuredViewer
element - element
fullMap - true if mappings are added and removed, and false if only the new map gets installed

getColumnViewerOwner

protected 
Widget getColumnViewerOwner(int columnIndex)
Description copied from class: ColumnViewer
Returns the column widget at the given column index.

Specified by:
getColumnViewerOwner in class ColumnViewer
Parameters:
columnIndex - the column index
Returns:
Widget the column widget

getElementAt

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

Parameters:
index - the zero-based index
Returns:
the element at the given index, or null if the index is out of range

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
Returns:
a label provider

getSelectionFromWidget

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

Specified by:
getSelectionFromWidget in class StructuredViewer
Returns:
the list of selected elements

indexForElement

protected int indexForElement(
Object element)
Parameters:
element - the element to insert
Returns:
the index where the item should be inserted.

inputChanged

protected void inputChanged(
Object input,
                            
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
Parameters:
input - the new input of this viewer, or null if none
oldInput - the old input element or null if there was previously no input

insert

public void insert(
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.

Parameters:
element - the element
position - a 0-based position relative to the model, or -1 to indicate the last position

internalRefresh

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

Specified by:
internalRefresh in class StructuredViewer
Parameters:
element - the element

internalRefresh

protected void internalRefresh(
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
Parameters:
element - the element
updateLabels - true to update labels for existing elements, false to only update labels as needed, assuming that labels for existing elements are unchanged.

remove

public void remove(
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.

Parameters:
elements - the elements to remove

remove

public void remove(
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.

NOTE: removing an object from a virtual table will decrement the itemCount.

Parameters:
element - the element

reveal

public void reveal(
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
Parameters:
element - the element to reveal

setSelectionToWidget

protected void setSelectionToWidget(
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
Parameters:
list - list of selected elements (element type: Object) or null if the selection is to be cleared
reveal - true if the selection is to be made visible, and false otherwise

setItemCount

public void setItemCount(int count)
Set the item count of the receiver.

Parameters:
count - the new table size.
Since:
3.1

replace

public void replace(
Object element,
                    int index)
Replace the element at the given index with the given element. This method will not call the content provider to verify. Note that this method will materialize a TableItem the given index..

Parameters:
element -
index -
Since:
3.1
See Also:
ILazyContentProvider

clear

public void clear(int index)
Clear the table item at the specified index

Parameters:
index - the index of the table item to be cleared
Since:
3.1

getRawChildren

protected 
Object[] getRawChildren(
Object parent)
Description copied from class: StructuredViewer
Returns the children of the given parent without sorting and filtering them. The resulting array must not be modified, as it may come directly from the model's internal state.

Returns an empty array if the given parent is null.

Overrides:
getRawChildren in class ColumnViewer
Parameters:
parent - the parent element
Returns:
the child elements

assertContentProviderType

protected void assertContentProviderType(
IContentProvider provider)
Description copied from class: StructuredViewer
Assert that the content provider is of one of the supported types.

Overrides:
assertContentProviderType in class StructuredViewer

doIndexOf

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. If no item is found, returns -1.

Parameters:
item - the search item
Returns:
the index of the item
Since:
3.3

doGetItemCount

protected abstract int doGetItemCount()
Returns the number of items contained in the receiver.

Returns:
the number of items
Since:
3.3

doSetItemCount

protected abstract void doSetItemCount(int count)
Sets the number of items contained in the receiver.

Parameters:
count - the number of items
Since:
3.3

doGetItems

protected abstract 
Item[] doGetItems()
Returns a (possibly empty) array of TableItems which are the items in the receiver.

Returns:
the items in the receiver
Since:
3.3

doGetColumn

protected abstract 
Widget doGetColumn(int index)
Returns the column at the given, zero-relative index in the receiver. Throws an exception if the index is out of range. Columns are returned in the order that they were created. If no TableColumns were created by the programmer, this method will throw ERROR_INVALID_RANGE despite the fact that a single column of data may be visible in the table. This occurs when the programmer uses the table like a list, adding items but never creating a column.

Parameters:
index - the index of the column to return
Returns:
the column at the given index
Throws:
IllegalArgumentException - - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
Since:
3.3

doGetItem

protected abstract 
Item doGetItem(int index)
Returns the item at the given, zero-relative index in the receiver. Throws an exception if the index is out of range.

Parameters:
index - the index of the item to return
Returns:
the item at the given index
Throws:
IllegalArgumentException - - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
Since:
3.3

doGetSelection

protected abstract 
Item[] doGetSelection()
Returns an array of Item that are currently selected in the receiver. The order of the items is unspecified. An empty array indicates that no items are selected.

Returns:
an array representing the selection
Since:
3.3

doGetSelectionIndices

protected abstract int[] doGetSelectionIndices()
Returns the zero-relative indices of the items which are currently selected in the receiver. The order of the indices is unspecified. The array is empty if no items are selected.

Returns:
an array representing the selection
Since:
3.3

doClearAll

protected abstract void doClearAll()
Clears all the items in the receiver. The text, icon and other attributes of the items are set to their default values. If the table was created with the SWT.VIRTUAL style, these attributes are requested again as needed.

Since:
3.3

doResetItem

protected abstract void doResetItem(
Item item)
Resets the given item in the receiver. The text, icon and other attributes of the item are set to their default values.

Parameters:
item - the item to reset
Since:
3.3

doRemove

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

Parameters:
start - the start of the range
end - the end of the range
Throws:
IllegalArgumentException - - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)
Since:
3.3

doRemoveAll

protected abstract void doRemoveAll()
Removes all of the items from the receiver.

Since:
3.3

doRemove

protected abstract void doRemove(int[] indices)
Removes the items from the receiver's list at the given zero-relative indices.

Parameters:
indices - the array of indices of the items
Throws:
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)
Since:
3.3

doShowItem

protected abstract void doShowItem(
Item item)
Shows the item. If the item is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the item is visible.

Parameters:
item - the item to be shown
Throws:
IllegalArgumentException - - if the item is null
Since:
3.3

doDeselectAll

protected abstract void doDeselectAll()
Deselects all selected items in the receiver.

Since:
3.3

doSetSelection

protected abstract void doSetSelection(
Item[] items)
Sets the receiver's selection to be the given array of items. The current selection is cleared before the new items are selected.

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.

Parameters:
items - the array of items
Throws:
IllegalArgumentException - - if the array of items is null
Since:
3.3

doShowSelection

protected abstract void doShowSelection()
Shows the selection. If the selection is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the selection is visible.

Since:
3.3

doSetSelection

protected abstract void doSetSelection(int[] indices)
Selects the items at the given zero-relative indices in the receiver. The current selection is cleared before the new items are 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.

Parameters:
indices - the indices of the items to select
Throws:
IllegalArgumentException - - if the array of indices is null
Since:
3.3

doClear

protected abstract void doClear(int index)
Clears the item at the given zero-relative index in the receiver. The text, icon and other attributes of the item are set to the default value. If the table was created with the SWT.VIRTUAL style, these attributes are requested again as needed.

Parameters:
index - the index of the item to clear
Throws:
IllegalArgumentException - - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
Since:
3.3
See Also:
SWT.VIRTUAL, SWT.SetData

doSelect

protected abstract void doSelect(int[] indices)
Selects the items at the given zero-relative indices in the receiver. The current selection is not cleared before the new items are selected.

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.

Parameters:
indices - the array of indices for the items to select
Throws:
IllegalArgumentException - - if the array of indices is null

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire