com.google.gwt.widgetideas.table.client
Class PagingScrollTable<R>

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.client.ui.Panel
              extended by com.google.gwt.user.client.ui.ComplexPanel
                  extended by com.google.gwt.widgetideas.table.client.ScrollTable
                      extended by com.google.gwt.widgetideas.table.client.PagingScrollTable<R>
Type Parameters:
R - the data type of the row values
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.IndexedPanel, ResizableWidget, SourceRowPagingEvents

public class PagingScrollTable<R>
extends ScrollTable
implements SourceRowPagingEvents

A ScrollTable that acts as a view for an underlying TableModel.


Nested Class Summary
static interface PagingScrollTable.CellRenderer
          The renderer used to set cell contents.
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.ScrollTable
ScrollTable.ResizePolicy, ScrollTable.ScrollPolicy, ScrollTable.ScrollTableImages
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.widgetideas.table.client.ScrollTable
DEFAULT_STYLE_NAME
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
PagingScrollTable(TableModel<R> tableModel, FixedWidthGrid dataTable, FixedWidthFlexTable headerTable)
          Constructor.
PagingScrollTable(TableModel<R> tableModel, FixedWidthGrid dataTable, FixedWidthFlexTable headerTable, ScrollTable.ScrollTableImages images)
          Constructor.
 
Method Summary
 void addRowPagingListener(RowPagingListener listener)
          Add a new RowPagingListener.
protected  void editCell(int row, int column)
          Invoke the cell editor on a cell, if one is set.
 AbstractCellEditor<R> getCellEditor(int column)
          Get the column editor for a column.
protected  AbstractCellEditor.Callback<R> getCellEditorCallback()
           
 PagingScrollTable.CellRenderer getCellRenderer()
           
 int getCurrentPage()
           
protected  int getFirstRow()
          Get the first visible row index.
protected  int getLastRow()
          Get the last visible row index.
 int getNumPages()
           
 int getPageSize()
           
 R getRowValue(int row)
          Get the value associated with a row.
 TableModel<R> getTableModel()
           
 void gotoFirstPage()
          Go to the first page.
 void gotoLastPage()
          Go to the last page.
 void gotoNextPage()
          Go to the next page.
 void gotoPage(int page, boolean forced)
          Set the current page.
 void gotoPreviousPage()
          Go to the previous page.
 boolean hasCellEditor(int column)
          Check whether a column has a cell editor.
protected  void insertAbsoluteRow(int beforeRow)
          Insert a row into the table relative to the total number of rows.
protected  void onLoad()
          This method is called immediately after a widget becomes attached to the browser's document.
 void reloadPage()
          Reload the current page.
protected  void removeAbsoluteRow(int row)
          Remove a row from the table relative to the total number of rows.
 void removeRowPagingListener(RowPagingListener listener)
          Remove a RowPagingListener.
protected  void renderCell(int row, int column, java.lang.Object data)
          Render the contents of the cell.
protected  void setAbsoluteData(int row, int column, java.lang.Object data)
          Set the data in a cell.
 void setBulkRenderer(FixedWidthGridBulkRenderer bulkRenderer)
          Set the bulk table renderer.
 void setCellEditor(int column, AbstractCellEditor<R> editor)
          Set the cell editor for a column.
 void setCellRenderer(PagingScrollTable.CellRenderer cellRenderer)
          Set the PagingScrollTable.CellRenderer used to render cell contents.
protected  void setData(int firstRow, java.util.Iterator<java.util.Iterator<java.lang.Object>> rows, java.util.List<R> rowValues)
          Set a block of data.
 void setPageSize(int pageSize)
          Set the number of rows per page.
 void setRowValue(int row, R value)
          Associate a row in the table with a value.
 
Methods inherited from class com.google.gwt.widgetideas.table.client.ScrollTable
autoFitColumnWidth, fillWidth, getCellPadding, getCellSpacing, getColumnWidth, getDataTable, getDataWrapper, getFooterTable, getHeaderTable, getMinWidth, getResizePolicy, getScrollPolicy, isAutoFitEnabled, isColumnSortable, isSortingEnabled, onAttach, onBrowserEvent, onResize, redraw, remove, resizeTablesVertically, resizeTablesVerticallyNow, scrollTables, setAutoFitEnabled, setCellPadding, setCellSpacing, setColumnSortable, setColumnWidth, setColumnWidth, setFooterTable, setHeight, setMinWidth, setResizePolicy, setScrollPolicy, setSortingEnabled
 
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, insert, insert, iterator, remove
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, onUnload, orphan
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onDetach, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.widgetideas.client.ResizableWidget
getElement, isAttached
 

Constructor Detail

PagingScrollTable

public PagingScrollTable(TableModel<R> tableModel,
                         FixedWidthGrid dataTable,
                         FixedWidthFlexTable headerTable)
Constructor.

Parameters:
tableModel - the underlying table model
dataTable - the table used to display data
headerTable - the header table

PagingScrollTable

public PagingScrollTable(TableModel<R> tableModel,
                         FixedWidthGrid dataTable,
                         FixedWidthFlexTable headerTable,
                         ScrollTable.ScrollTableImages images)
Constructor.

Parameters:
tableModel - the underlying table model
dataTable - the table used to display data
headerTable - the header table
images - the images to use in the table
Method Detail

addRowPagingListener

public void addRowPagingListener(RowPagingListener listener)
Add a new RowPagingListener.

Specified by:
addRowPagingListener in interface SourceRowPagingEvents
Parameters:
listener - the listener

getCellEditor

public AbstractCellEditor<R> getCellEditor(int column)
Get the column editor for a column.

Parameters:
column - the column index
Returns:
the cell editor

getCellRenderer

public PagingScrollTable.CellRenderer getCellRenderer()
Returns:
the PagingScrollTable.CellRenderer used to render cells.

getCurrentPage

public int getCurrentPage()
Returns:
the current page

getNumPages

public int getNumPages()
Returns:
the number of pages, or -1 if not known

getPageSize

public int getPageSize()
Returns:
the number of rows per page

getRowValue

public R getRowValue(int row)
Get the value associated with a row.

Parameters:
row - the row index
Returns:
the value associated with the row

getTableModel

public TableModel<R> getTableModel()
Returns:
the table model

gotoFirstPage

public void gotoFirstPage()
Go to the first page.


gotoLastPage

public void gotoLastPage()
Go to the last page. If the number of pages is not known, this method is ignored.


gotoNextPage

public void gotoNextPage()
Go to the next page.


gotoPage

public void gotoPage(int page,
                     boolean forced)
Set the current page. If the page is out of bounds, it will be automatically set to zero or the last page without throwing any errors.

Parameters:
page - the page
forced - reload the page even if it is already loaded

gotoPreviousPage

public void gotoPreviousPage()
Go to the previous page.


hasCellEditor

public boolean hasCellEditor(int column)
Check whether a column has a cell editor.

Parameters:
column - the column index
Returns:
true if a cell editor is assigned

reloadPage

public void reloadPage()
Reload the current page.


removeRowPagingListener

public void removeRowPagingListener(RowPagingListener listener)
Remove a RowPagingListener.

Specified by:
removeRowPagingListener in interface SourceRowPagingEvents
Parameters:
listener - the listener to remove

setCellEditor

public void setCellEditor(int column,
                          AbstractCellEditor<R> editor)
Set the cell editor for a column.

Parameters:
column - the column index
editor - the cell editor

setCellRenderer

public void setCellRenderer(PagingScrollTable.CellRenderer cellRenderer)
Set the PagingScrollTable.CellRenderer used to render cell contents.

Parameters:
cellRenderer - the new renderer

setPageSize

public void setPageSize(int pageSize)
Set the number of rows per page. By default, the page size is zero, which indicates that all rows should be shown on the page.

Parameters:
pageSize - the number of rows per page

setRowValue

public void setRowValue(int row,
                        R value)
Associate a row in the table with a value.

Parameters:
row - the row index
value - the value to associate

setBulkRenderer

public void setBulkRenderer(FixedWidthGridBulkRenderer bulkRenderer)
Set the bulk table renderer.

Parameters:
bulkRenderer - the table renderer

editCell

protected void editCell(int row,
                        int column)
Invoke the cell editor on a cell, if one is set. If a cell editor is not specified, this method has no effect.


getCellEditorCallback

protected AbstractCellEditor.Callback<R> getCellEditorCallback()
Returns:
the cell editor callback.

getFirstRow

protected int getFirstRow()
Get the first visible row index.

Returns:
the first row index

getLastRow

protected int getLastRow()
Get the last visible row index.

Returns:
the last row index

insertAbsoluteRow

protected void insertAbsoluteRow(int beforeRow)
Insert a row into the table relative to the total number of rows.

Parameters:
beforeRow - the row index

onLoad

protected void onLoad()
This method is called immediately after a widget becomes attached to the browser's document.

Overrides:
onLoad in class com.google.gwt.user.client.ui.Panel

removeAbsoluteRow

protected void removeAbsoluteRow(int row)
Remove a row from the table relative to the total number of rows.

Parameters:
row - the row index

renderCell

protected void renderCell(int row,
                          int column,
                          java.lang.Object data)
Render the contents of the cell.

Parameters:
row - the row index
column - the column index
data - the data to render

setAbsoluteData

protected void setAbsoluteData(int row,
                               int column,
                               java.lang.Object data)
Set the data in a cell. The data object will be rendered using the PagingScrollTable.CellRenderer, if one is specified. The row index in this method is relative to the total number of rows across all pages. It is not the same as the row index passed into setHTML, which is relative to the current page.

Parameters:
row - the row index
column - the column index
data - the data to set

setData

protected void setData(int firstRow,
                       java.util.Iterator<java.util.Iterator<java.lang.Object>> rows,
                       java.util.List<R> rowValues)
Set a block of data. This method is used when responding to data requests. This method takes an iterator of iterators, where each iterator represents one row of data starting with the first row.

Parameters:
firstRow - the row index
rows - the 2D Iterator of data
rowValues - the values associated with each row