com.google.gwt.user.cellview.client
Class CellTable<T>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.cellview.client.CellTable<T>
Type Parameters:
T - the data type of each row
All Implemented Interfaces:
HasHandlers, EventListener, ListView<T>, PagingListView<T>

public class CellTable<T>
extends Widget
implements PagingListView<T>

A list view that supports paging and columns.


Nested Class Summary
static interface CellTable.CleanResources
          A cleaner version of the table that uses less graphics.
static interface CellTable.CleanStyle
          A cleaner version of the table that uses less graphics.
static interface CellTable.Resources
          A ClientBundle that provides images for this widget.
static interface CellTable.Style
          Styles used by this widget.
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Nested classes/interfaces inherited from interface com.google.gwt.view.client.PagingListView
PagingListView.Pager<T>
 
Nested classes/interfaces inherited from interface com.google.gwt.view.client.ListView
ListView.Delegate<T>
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
CellTable()
          Constructs a table with a default page size of 15.
CellTable(int pageSize)
          Constructs a table with the given page size.
CellTable(int pageSize, CellTable.Resources resources)
          Constructs a table with the given page size with the specified CellTable.CleanResources.
 
Method Summary
 void addColumn(Column<T,?> col)
          Adds a column to the table.
 void addColumn(Column<T,?> col, Header<?> header)
          Adds a column to the table with an associated header.
 void addColumn(Column<T,?> col, Header<?> header, Header<?> footer)
          Adds a column to the table with an associated header and footer.
 void addColumn(Column<T,?> col, java.lang.String headerString)
          Adds a column to the table with an associated String header.
 void addColumn(Column<T,?> col, java.lang.String headerString, java.lang.String footerString)
          Adds a column to the table with an associated String header and footer.
 void addColumnStyleName(int index, java.lang.String styleName)
          Add a style name to the TableColElement at the specified index, creating it if necessary.
 int getBodyHeight()
           
 int getDataSize()
          Get the total data size.
 T getDisplayedItem(int indexOnPage)
           
 java.util.List<T> getDisplayedItems()
           
 int getHeaderHeight()
           
 ProvidesKey<T> getKeyProvider()
           
 int getPageSize()
           
 int getPageStart()
           
 Range getRange()
          Get the range that this view is displaying.
 TableRowElement getRowElement(int row)
          Get the TableRowElement for the specified row.
 boolean isDataSizeExact()
          Returns the value of the 'isExact' parameter of the most recent call to ListView.setDataSize(int, boolean).
 boolean isSelectionEnabled()
          Check whether or not mouse selection is enabled.
 void onBrowserEvent(Event event)
          Fired whenever a browser event is received.
 void redraw()
          Redraw the table using the existing data.
 void redrawFooters()
           
 void redrawHeaders()
           
 void removeColumn(Column<T,?> col)
          Remove a column.
 void removeColumn(int index)
          Remove a column.
 void removeColumnStyleName(int index, java.lang.String styleName)
          Remove a style from the TableColElement at the specified index.
 void setData(int start, int length, java.util.List<T> values)
          Set a range of data in the view.
 void setDataSize(int size, boolean isExact)
          Set the total data size of the underlying data.
 void setDelegate(ListView.Delegate<T> delegate)
          Set the ListView.Delegate that responds to changes in the range.
 void setKeyProvider(ProvidesKey<T> providesKey)
          Sets the ProvidesKey instance that will be used to generate keys for each record object as needed.
 void setPager(PagingListView.Pager<T> pager)
          Set the PagingListView.Pager that allows the user to change the range.
 void setPageSize(int pageSize)
          Set the number of rows per page and refresh the table.
 void setPageStart(int pageStart)
          Set the starting index of the current visible page.
 void setRange(int start, int length)
          Set a new range.
 void setSelectionEnabled(boolean isSelectionEnabled)
          Enable mouse and keyboard selection.
 void setSelectionModel(SelectionModel<? super T> selectionModel)
          Set the SelectionModel used by this ListView.
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
fireEvent, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CellTable

public CellTable()
Constructs a table with a default page size of 15.


CellTable

public CellTable(int pageSize)
Constructs a table with the given page size.

Parameters:
pageSize - the page size

CellTable

public CellTable(int pageSize,
                 CellTable.Resources resources)
Constructs a table with the given page size with the specified CellTable.CleanResources.

Parameters:
pageSize - the page size
resources - the resources to use for this widget
Method Detail

addColumn

public void addColumn(Column<T,?> col)
Adds a column to the table.


addColumn

public void addColumn(Column<T,?> col,
                      Header<?> header)
Adds a column to the table with an associated header.


addColumn

public void addColumn(Column<T,?> col,
                      Header<?> header,
                      Header<?> footer)
Adds a column to the table with an associated header and footer.


addColumn

public void addColumn(Column<T,?> col,
                      java.lang.String headerString)
Adds a column to the table with an associated String header.


addColumn

public void addColumn(Column<T,?> col,
                      java.lang.String headerString,
                      java.lang.String footerString)
Adds a column to the table with an associated String header and footer.


addColumnStyleName

public void addColumnStyleName(int index,
                               java.lang.String styleName)
Add a style name to the TableColElement at the specified index, creating it if necessary.

Parameters:
index - the column index
styleName - the style name to add

getBodyHeight

public int getBodyHeight()

getDataSize

public int getDataSize()
Description copied from interface: PagingListView
Get the total data size.

Specified by:
getDataSize in interface PagingListView<T>

getDisplayedItem

public T getDisplayedItem(int indexOnPage)

getDisplayedItems

public java.util.List<T> getDisplayedItems()

getHeaderHeight

public int getHeaderHeight()

getKeyProvider

public ProvidesKey<T> getKeyProvider()

getPageSize

public final int getPageSize()

getPageStart

public final int getPageStart()

getRange

public Range getRange()
Description copied from interface: ListView
Get the range that this view is displaying.

Specified by:
getRange in interface ListView<T>
Returns:
the range

getRowElement

public TableRowElement getRowElement(int row)
Get the TableRowElement for the specified row. If the row element has not been created, null is returned.

Parameters:
row - the row index
Returns:
the row element, or null if it doesn't exists
Throws:
java.lang.IndexOutOfBoundsException - if the row index is outside of the current page

isDataSizeExact

public boolean isDataSizeExact()
Description copied from interface: ListView
Returns the value of the 'isExact' parameter of the most recent call to ListView.setDataSize(int, boolean).

Specified by:
isDataSizeExact in interface ListView<T>

isSelectionEnabled

public boolean isSelectionEnabled()
Check whether or not mouse selection is enabled.

Returns:
true if enabled, false if disabled

onBrowserEvent

public void onBrowserEvent(Event event)
Description copied from interface: EventListener
Fired whenever a browser event is received.

Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Widget
Parameters:
event - the event received

redraw

public void redraw()
Redraw the table using the existing data.


redrawFooters

public void redrawFooters()

redrawHeaders

public void redrawHeaders()

removeColumn

public void removeColumn(int index)
Remove a column.

Parameters:
index - the column index

removeColumn

public void removeColumn(Column<T,?> col)
Remove a column.

Parameters:
col - the column to remove

removeColumnStyleName

public void removeColumnStyleName(int index,
                                  java.lang.String styleName)
Remove a style from the TableColElement at the specified index.

Parameters:
index - the column index
styleName - the style name to remove

setData

public void setData(int start,
                    int length,
                    java.util.List<T> values)
Description copied from interface: ListView
Set a range of data in the view.

Specified by:
setData in interface ListView<T>
Parameters:
start - the start index of the data
length - the length of the data
values - the values within the range

setDataSize

public void setDataSize(int size,
                        boolean isExact)
Description copied from interface: ListView
Set the total data size of the underlying data.

Specified by:
setDataSize in interface ListView<T>
Parameters:
size - the total data size
isExact - true if the size is exact, false if it is an estimate

setDelegate

public void setDelegate(ListView.Delegate<T> delegate)
Description copied from interface: ListView
Set the ListView.Delegate that responds to changes in the range.

Specified by:
setDelegate in interface ListView<T>
Parameters:
delegate - the ListView.Delegate

setKeyProvider

public void setKeyProvider(ProvidesKey<T> providesKey)
Sets the ProvidesKey instance that will be used to generate keys for each record object as needed.

Parameters:
providesKey - an instance of ProvidesKey used to generate keys for record objects.

setPager

public void setPager(PagingListView.Pager<T> pager)
Description copied from interface: PagingListView
Set the PagingListView.Pager that allows the user to change the range.

Specified by:
setPager in interface PagingListView<T>
Parameters:
pager - the PagingListView.Pager

setPageSize

public final void setPageSize(int pageSize)
Set the number of rows per page and refresh the table.

Parameters:
pageSize - the page size
Throws:
java.lang.IllegalArgumentException - if pageSize is negative or 0

setPageStart

public final void setPageStart(int pageStart)
Set the starting index of the current visible page. The actual page start will be clamped in the range [0, getSize() - 1].

Parameters:
pageStart - the index of the row that should appear at the start of the page

setRange

public void setRange(int start,
                     int length)
Description copied from interface: PagingListView
Set a new range.

Specified by:
setRange in interface PagingListView<T>
Parameters:
start - the new start index
length - the new page size

setSelectionEnabled

public void setSelectionEnabled(boolean isSelectionEnabled)
Enable mouse and keyboard selection.

Parameters:
isSelectionEnabled - true to enable, false to disable

setSelectionModel

public void setSelectionModel(SelectionModel<? super T> selectionModel)
Description copied from interface: ListView
Set the SelectionModel used by this ListView.

Specified by:
setSelectionModel in interface ListView<T>
Parameters:
selectionModel - the SelectionModel