com.google.gwt.widgetideas.table.client
Class PagingGrid

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.widgetideas.table.client.overrides.HTMLTable
                  extended by com.google.gwt.widgetideas.table.client.overrides.Grid
                      extended by com.google.gwt.widgetideas.table.client.SelectionGrid
                          extended by com.google.gwt.widgetideas.table.client.FixedWidthGrid
                              extended by com.google.gwt.widgetideas.table.client.SortableFixedWidthGrid
                                  extended by com.google.gwt.widgetideas.table.client.PagingGrid
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.SourcesTableEvents, ControllableTable, HasAutoFitColumn, HasFixedColumnWidth, HasRowPaging, HasSortableColumns, HasTableCells, SourceRowPagingEvents, SourceSortableColumnsEvents, SourceTableDataRequestEvents, SourceTableSelectionEvents
Direct Known Subclasses:
EditablePagingGrid

public class PagingGrid
extends SortableFixedWidthGrid
implements HasRowPaging, ControllableTable

A PagingGrid responds to events from an underlying TableController.


Nested Class Summary
static interface PagingGrid.CellRenderer
          The renderer used to set cell contents.
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.SortableFixedWidthGrid
SortableFixedWidthGrid.ColumnSorter, SortableFixedWidthGrid.ColumnSorterCallback
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.FixedWidthGrid
FixedWidthGrid.FixedWidthGridCellFormatter, FixedWidthGrid.FixedWidthGridColumnFormatter, FixedWidthGrid.FixedWidthGridRowFormatter
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.SelectionGrid
SelectionGrid.SelectedGridRowFormatter
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
HTMLTable.CellFormatter, HTMLTable.ColumnFormatter, HTMLTable.RowFormatter
 
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.FixedWidthGrid
DEFAULT_COLUMN_WIDTH, MIN_COLUMN_WIDTH
 
Fields inherited from class com.google.gwt.widgetideas.table.client.SelectionGrid
HOVERING_POLICY_CELL, HOVERING_POLICY_DISABLED, HOVERING_POLICY_ROW, SELECTION_POLICY_DISABLED, SELECTION_POLICY_MULTI_ROW, SELECTION_POLICY_ONE_ROW
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
PagingGrid(TableController tableController)
          Constructor.
PagingGrid(TableModel tableModel)
          Constructor.
 
Method Summary
 void addRowPagingListener(RowPagingListener listener)
          Add a new RowPagingListener.
 void addTableDataRequestListener(TableDataRequestListener listener)
          Add a new TableDataRequestListener.
 PagingGrid.CellRenderer getCellRenderer()
           
 int getCurrentPage()
           
 int getNumPages()
          Get the number of pages.
 int getNumRows()
           
 int getPageSize()
          Get the number of rows per page.
 java.lang.Object getRowValue(int row)
          Get the value associated with a row.
 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.
 void insertAbsoluteRow(int beforeRow, int numRows)
          Insert a row into the table relative to the total number of rows.
 void reloadPage()
          Reload the current page.
 void removeAbsoluteRow(int row, int numRows)
          Remove a row from the table relative to the total number of rows.
 void removeRowPagingListener(RowPagingListener listener)
          Remove a RowPagingListener.
 void removeTableDataRequestListener(TableDataRequestListener listener)
          Remove a TableDataRequestListener.
 void setCellRenderer(PagingGrid.CellRenderer cellRenderer)
          Set the PagingGrid.CellRenderer used to render cell contents.
 void setData(int row, int column, java.lang.Object data)
          Set the data in a cell.
 void setData(int firstRow, java.util.Iterator rows, java.util.List rowValues)
          Set a block of data.
 void setNumRows(int numRows)
          Set the number of rows in the underlying data.
 void setPageSize(int pageSize)
          Set the number of rows per page.
 void setPagingFailure(java.lang.Throwable caught)
          Set the failure condition associated with a page request.
 void setRowValue(int row, java.lang.Object value)
          Associate a row in the table with a value.
 void sortColumn(int column, boolean ascending)
          Sort the grid according to the specified column.
 
Methods inherited from class com.google.gwt.widgetideas.table.client.SortableFixedWidthGrid
addSortableColumnsListener, getColumnSorter, getColumnSortList, moveRowDown, moveRowUp, removeSortableColumnsListener, reverseRows, setColumnSorter, sortColumn, swapRows
 
Methods inherited from class com.google.gwt.widgetideas.table.client.FixedWidthGrid
autoFitColumnWidth, getAutoFitColumnWidth, getColumnWidth, getDefaultColumnWidth, insertRow, removeRow, resizeColumns, resizeRows, setColumnWidth
 
Methods inherited from class com.google.gwt.widgetideas.table.client.SelectionGrid
addTableSelectionListener, deselectRow, deselectRows, getHoveringPolicy, getMinHoverRow, getSelectedRows, getSelectionPolicy, isRowSelected, onBrowserEvent, onCellClicked, removeTableSelectionListener, selectRow, selectRow, setHoveringPolicy, setMinHoverRow, setSelectionPolicy
 
Methods inherited from class com.google.gwt.widgetideas.table.client.overrides.Grid
getCellCount, getColumnCount, getRowCount, resize
 
Methods inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
addTableListener, clear, clearAll, clearCell, getCellFormatter, getCellPadding, getCellSpacing, getColumnFormatter, getEventTargetCell, getHTML, getRowFormatter, getText, getWidget, isCellPresent, iterator, remove, removeTableListener, setBorderWidth, setCellPadding, setCellSpacing, setElement, setHTML, setText, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
add
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.widgetideas.table.client.HasFixedColumnWidth
getColumnCount, getColumnWidth, getDefaultColumnWidth, setColumnWidth
 
Methods inherited from interface com.google.gwt.widgetideas.table.client.HasTableCells
getCellCount, getCellPadding, getCellSpacing, getEventTargetCell, setCellPadding, setCellSpacing
 

Constructor Detail

PagingGrid

public PagingGrid(TableController tableController)
Constructor.

Parameters:
tableController - the underlying TableController

PagingGrid

public PagingGrid(TableModel tableModel)
Constructor.

Parameters:
tableModel - the TableModel used to retrieve data
Method Detail

addRowPagingListener

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

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

addTableDataRequestListener

public void addTableDataRequestListener(TableDataRequestListener listener)
Add a new TableDataRequestListener.

Specified by:
addTableDataRequestListener in interface SourceTableDataRequestEvents
Parameters:
listener - the listener

getCellRenderer

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

getCurrentPage

public int getCurrentPage()
Specified by:
getCurrentPage in interface HasRowPaging
Returns:
the current page

getNumPages

public int getNumPages()
Description copied from interface: HasRowPaging
Get the number of pages. If the number of pages is unknown, -1 is returned.

Specified by:
getNumPages in interface HasRowPaging
Returns:
the number of pages, or -1 if not known

getNumRows

public int getNumRows()
Returns:
the total number of rows, or -1 if not known

getPageSize

public int getPageSize()
Description copied from interface: HasRowPaging
Get the number of rows per page.

Specified by:
getPageSize in interface HasRowPaging
Returns:
the number of rows per page

getRowValue

public java.lang.Object getRowValue(int row)
Get the value associated with a row.

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

gotoFirstPage

public void gotoFirstPage()
Go to the first page.

Specified by:
gotoFirstPage in interface HasRowPaging

gotoLastPage

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

Specified by:
gotoLastPage in interface HasRowPaging

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.

Specified by:
gotoPage in interface HasRowPaging
Parameters:
page - the page
forced - reload the page even if it is already loaded

gotoPreviousPage

public void gotoPreviousPage()
Go to the previous page.


insertAbsoluteRow

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

Specified by:
insertAbsoluteRow in interface ControllableTable
Parameters:
beforeRow - the row index
numRows - the new number of rows

reloadPage

public void reloadPage()
Reload the current page.


removeAbsoluteRow

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

Specified by:
removeAbsoluteRow in interface ControllableTable
Parameters:
row - the row index
numRows - the new number of rows

removeRowPagingListener

public void removeRowPagingListener(RowPagingListener listener)
Remove a RowPagingListener.

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

removeTableDataRequestListener

public void removeTableDataRequestListener(TableDataRequestListener listener)
Remove a TableDataRequestListener.

Specified by:
removeTableDataRequestListener in interface SourceTableDataRequestEvents
Parameters:
listener - the listener to remove

setCellRenderer

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

Parameters:
cellRenderer - the new renderer

setData

public void setData(int row,
                    int column,
                    java.lang.Object data)
Set the data in a cell. The data object will be rendered using the PagingGrid.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.

Specified by:
setData in interface ControllableTable
Parameters:
row - the row index
column - the column index
data - the data to set

setData

public void setData(int firstRow,
                    java.util.Iterator rows,
                    java.util.List rowValues)
Set a block of data. This method is used when responding to data requests. This method takes an iterator of Collections, where each collection represents one row of data starting with the first row.

Specified by:
setData in interface ControllableTable
Parameters:
firstRow - the row index
rows - the 2D Iterator of data
rowValues - the values associated with each row

setNumRows

public void setNumRows(int numRows)
Set the number of rows in the underlying data.

Specified by:
setNumRows in interface ControllableTable
Parameters:
numRows - the new number of rows

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.

Specified by:
setPageSize in interface HasRowPaging
Parameters:
pageSize - the number of rows per page

setPagingFailure

public void setPagingFailure(java.lang.Throwable caught)
Description copied from interface: ControllableTable
Set the failure condition associated with a page request.

Specified by:
setPagingFailure in interface ControllableTable
Parameters:
caught - the exception that led to the failure
See Also:
ControllableTable.setPagingFailure(java.lang.Throwable)

setRowValue

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

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

sortColumn

public void sortColumn(int column,
                       boolean ascending)
Sort the grid according to the specified column. Unlike a normal SortableFixedWidthGrid, the PagingGrid does not automatically sort columns using a client side quick sort. Instead, PagingGrid sets the sorted column and reloads the page, allowing the user to move sorting to the server side. Setting a column sorter manually will override this behavior.

Overrides:
sortColumn in class SortableFixedWidthGrid
Parameters:
column - the column to sort
ascending - reverse sort the column
Throws:
java.lang.IndexOutOfBoundsException