EchoPoint
1.0

echopoint.table
Class SortablePagedTableModel

java.lang.Object
  extended bynextapp.echo.table.AbstractTableModel
      extended byechopoint.table.TableModelAdapter
          extended byechopoint.table.SortableTableModel
              extended byechopoint.table.SortablePagedTableModel
All Implemented Interfaces:
java.util.EventListener, PagedTableModel, java.io.Serializable, nextapp.echo.table.TableModel, nextapp.echo.event.TableModelListener

public class SortablePagedTableModel
extends SortableTableModel
implements PagedTableModel

The SortablePagedTableModel is a SortableTabledModel that can be used to display a subset (ie. a page worth) of data at a time from an underlying TableModel and can also be sorted by column.

Author:
jp
See Also:
Serialized Form

Field Summary
 
Fields inherited from class echopoint.table.SortableTableModel
DOWN, NONE, UP
 
Fields inherited from class echopoint.table.TableModelAdapter
model
 
Fields inherited from class nextapp.echo.table.AbstractTableModel
listenerList
 
Constructor Summary
SortablePagedTableModel(nextapp.echo.table.TableModel model)
          Creates a PagedTableModel that pages over the provided TableMode with a default page size of Integer.MAX_VALUE.
SortablePagedTableModel(nextapp.echo.table.TableModel model, int pageSize)
          Creates a PagedTableModel that pages over the provided TableModel with a default page size of pageSize.
 
Method Summary
 int getMaxPageIndex()
          Gets the maximum number of pages that this model contains.
 int getModelRowIndex(int row)
          This returns the "sorted" table model row index for a given "visual" table row index.
 int getPageIndex()
          Gets the current page index.
 int getRowCount()
          In a PagedTableModel, this reports the minimum of the current rows per page or the number of rows left in the current page.
 int getRowsPerPage()
          Gets the number of rows per page.
 int getTotalRowCount()
          Returns the total number of rows in the TableModel.
 java.lang.Object getValueAt(int column, int row)
          Returns the "sorted" value at the given column and row.
 void next()
          Move forward a page, rolling over to 0 from getMaxPageIndex
 void previous()
          Move back a page, rolling over to getMaxPageIndex from 0
 void setPageIndex(int pageIndex)
          Sets the current page index.
 void setRowsPerPage(int pageSize)
          Sets the number of rows per page.
 
Methods inherited from class echopoint.table.SortableTableModel
getColumnSortingState, getComparator, setComparator, setModel, sortByColumn, sortByColumn, tableChanged
 
Methods inherited from class echopoint.table.TableModelAdapter
deleteRow, getColumnClass, getColumnCount, getColumnName, getModel, insertRow
 
Methods inherited from class nextapp.echo.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nextapp.echo.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, removeTableModelListener
 

Constructor Detail

SortablePagedTableModel

public SortablePagedTableModel(nextapp.echo.table.TableModel model)
Creates a PagedTableModel that pages over the provided TableMode with a default page size of Integer.MAX_VALUE.

Parameters:
model - - the underlying TabeModel to page

SortablePagedTableModel

public SortablePagedTableModel(nextapp.echo.table.TableModel model,
                               int pageSize)
Creates a PagedTableModel that pages over the provided TableModel with a default page size of pageSize.

Parameters:
model - - the underlying TabeModel to page
pageSize - - the number of rows in a page
Method Detail

previous

public void previous()
Description copied from interface: PagedTableModel
Move back a page, rolling over to getMaxPageIndex from 0

Specified by:
previous in interface PagedTableModel
See Also:
PagedTableModel.previous()

next

public void next()
Description copied from interface: PagedTableModel
Move forward a page, rolling over to 0 from getMaxPageIndex

Specified by:
next in interface PagedTableModel
See Also:
PagedTableModel.next()

getRowsPerPage

public int getRowsPerPage()
Description copied from interface: PagedTableModel
Gets the number of rows per page.

Specified by:
getRowsPerPage in interface PagedTableModel
Returns:
- the number of rows per page.
See Also:
PagedTableModel.getRowsPerPage()

setRowsPerPage

public void setRowsPerPage(int pageSize)
Description copied from interface: PagedTableModel
Sets the number of rows per page. Any integer value is fine since this just defines the viewable upper bound.

Specified by:
setRowsPerPage in interface PagedTableModel
Parameters:
pageSize - - the number of rows per page
See Also:
PagedTableModel.setRowsPerPage(int)

getPageIndex

public int getPageIndex()
Description copied from interface: PagedTableModel
Gets the current page index.

Specified by:
getPageIndex in interface PagedTableModel
Returns:
the current page index
See Also:
PagedTableModel.getPageIndex()

setPageIndex

public void setPageIndex(int pageIndex)
Description copied from interface: PagedTableModel
Sets the current page index. This method will safely roll to the max page or 0 depending on the given value being and over or under flow respectively.

Specified by:
setPageIndex in interface PagedTableModel
Parameters:
pageIndex - - the new page index
See Also:
PagedTableModel.setPageIndex(int)

getMaxPageIndex

public int getMaxPageIndex()
Description copied from interface: PagedTableModel
Gets the maximum number of pages that this model contains.

Specified by:
getMaxPageIndex in interface PagedTableModel
Returns:
the maximum number of pages that this model contains.
See Also:
PagedTableModel.getMaxPageIndex()

getTotalRowCount

public int getTotalRowCount()
Description copied from interface: PagedTableModel
Returns the total number of rows in the TableModel.

Contrasts this with the getRowCount() method.

Specified by:
getTotalRowCount in interface PagedTableModel
Returns:
the total number of rows in the TableModel.
See Also:
PagedTableModel.getTotalRowCount()

getModelRowIndex

public int getModelRowIndex(int row)
Description copied from class: SortableTableModel
This returns the "sorted" table model row index for a given "visual" table row index.

Overrides:
getModelRowIndex in class SortableTableModel
See Also:
SortableTableModel.getModelRowIndex(int)

getRowCount

public int getRowCount()
Description copied from interface: PagedTableModel
In a PagedTableModel, this reports the minimum of the current rows per page or the number of rows left in the current page.

Constrast this with the original getRowCount() which reports the total number of rows in the model. This is needed to "trick" the visual Table component into thinking it sees a complete model of row data, when in fact it only sees a page.

Specified by:
getRowCount in interface PagedTableModel
Overrides:
getRowCount in class TableModelAdapter
See Also:
TableModel.getRowCount()

getValueAt

public java.lang.Object getValueAt(int column,
                                   int row)
Description copied from class: SortableTableModel
Returns the "sorted" value at the given column and row.

Specified by:
getValueAt in interface nextapp.echo.table.TableModel
Overrides:
getValueAt in class SortableTableModel
See Also:
TableModel.getValueAt(int, int)

EchoPoint
1.0