JIDE 3.5.15

com.jidesoft.grid
Class AbstractPageTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.grid.AbstractPageTableModel
All Implemented Interfaces:
ContextSensitiveTableModel, MultiTableModel, PageNavigationSupport, Serializable, EventListener, TableModelListener, TableModel
Direct Known Subclasses:
AdvancePageTableModel, DefaultPageTableModel

public abstract class AbstractPageTableModel
extends AbstractTableModel
implements ContextSensitiveTableModel, MultiTableModel, PageNavigationSupport, TableModelListener

AbstractPageTableModel is the abstract implementation for PagingSupport. It extends AbstractTableModel and implements all methods PageNavigationSupport except PageNavigationSupport.getTotalRecordCount() and PageNavigationSupport.setTotalRecordCount(int).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface com.jidesoft.grid.MultiTableModel
FOOTER_COLUMN, HEADER_COLUMN, REGULAR_COLUMN
 
Constructor Summary
AbstractPageTableModel()
           
AbstractPageTableModel(int pageSize)
           
 
Method Summary
 void addPageNavigationListener(PageNavigationListener l)
          Adds a PageNavigationListener to the page.
protected  CompoundTableModelEvent createCompoundTableModelEvent()
          Creates a CompoundTableModelEvent instance.
 void firePageNavigationEvent(Object source, int id, int oldValue, int newValue)
          Runs each PageNavigationListener's PageNavigationEventFired method.
 void fireTableCellsUpdated(int firstRow, int lastRow, int column)
          Called each time the cells in column in the range [firstRow, lastRow] are updated.
 void fireTableChanged(TableModelEvent e)
           
 void firstPage()
          Navigates to the first page.
 Class<?> getCellClassAt(int rowIndex, int columnIndex)
          Gets the type at cell (row, column).
 int getColumnType(int columnIndex)
          Checks if the column at the columnIndex is a header column or footer column or just regular column.
 ConverterContext getConverterContextAt(int rowIndex, int columnIndex)
          Gets the converter context at cell (row, column).
 int getCurrentPage()
          Gets the current page.
 EditorContext getEditorContextAt(int rowIndex, int columnIndex)
          Gets the editor context at cell (row, column).
 int getPageCount()
          Gets the total page count.
 PageNavigationListener[] getPageNavigationListeners()
          Returns an array of all the PageNavigationListeners added to this Page with addPageNavigationListener .
 int getPageSize()
          Gets the page size.
 int getRowCount()
           
 int getTableIndex(int columnIndex)
          Gets the table index that this column belongs to.
 void lastPage()
          Navigates to the last page.
 void nextPage()
          Navigates to the next page.
protected abstract  void pageCountChanged(int oldPageCount, int newPageCount)
           
protected abstract  void pageIndexChanged(int oldPageIndex, int newPageIndex)
           
protected  void pageSizeChanged(int oldPageSize, int newPageSize)
          Adjusts the current page when page size changes so that the first row of the page is still visible after the page size changes.
 void previousPage()
          Navigates to the previous page.
 void removePageNavigationListener(PageNavigationListener l)
          Removes a PageNavigationListener from the page.
 void setCurrentPage(int page)
          Sets the current page.
protected  void setPageCount(int pageCount)
           
 void setPageSize(int pageSize)
          Sets the page size.
protected  void tableCellsUpdated(int column, int firstRow, int lastRow)
          Called each time the cells in column in the range [firstRow, lastRow] are updated.
 void tableChanged(TableModelEvent e)
           
protected  void tableDataChanged()
          Called each time all of the data (i.e.
protected  void tableRowsDeleted(int firstRow, int lastRow)
          Called each time one or more contiguous rows are deleted from the underlying TableModel.
protected  void tableRowsInserted(int firstRow, int lastRow)
          Called each time one or more contiguous rows are inserted into the underlying TableModel.
protected  void tableRowsUpdated(int firstRow, int lastRow)
          Called each time one or more contiguous rows are updated in the underlying TableModel.
protected  void tableStructureChanged()
          Called each time the structure (TableColumns, etc) of the underlying TableModel changes.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from interface com.jidesoft.paging.PageNavigationSupport
getTotalRecordCount, setTotalRecordCount
 

Constructor Detail

AbstractPageTableModel

public AbstractPageTableModel()

AbstractPageTableModel

public AbstractPageTableModel(int pageSize)
Method Detail

getPageSize

public int getPageSize()
Description copied from interface: PageNavigationSupport
Gets the page size.

Specified by:
getPageSize in interface PageNavigationSupport
Returns:
the page size.

setPageSize

public void setPageSize(int pageSize)
Description copied from interface: PageNavigationSupport
Sets the page size.

Specified by:
setPageSize in interface PageNavigationSupport
Parameters:
pageSize - the new page size.

getCurrentPage

public int getCurrentPage()
Description copied from interface: PageNavigationSupport
Gets the current page.

Specified by:
getCurrentPage in interface PageNavigationSupport
Returns:
the current page.

setCurrentPage

public void setCurrentPage(int page)
Description copied from interface: PageNavigationSupport
Sets the current page.

Specified by:
setCurrentPage in interface PageNavigationSupport
Parameters:
page - the new current page.

setPageCount

protected void setPageCount(int pageCount)

getPageCount

public int getPageCount()
Description copied from interface: PageNavigationSupport
Gets the total page count.

Specified by:
getPageCount in interface PageNavigationSupport
Returns:
the total page count.

nextPage

public void nextPage()
Description copied from interface: PageNavigationSupport
Navigates to the next page.

Specified by:
nextPage in interface PageNavigationSupport

previousPage

public void previousPage()
Description copied from interface: PageNavigationSupport
Navigates to the previous page.

Specified by:
previousPage in interface PageNavigationSupport

firstPage

public void firstPage()
Description copied from interface: PageNavigationSupport
Navigates to the first page.

Specified by:
firstPage in interface PageNavigationSupport

lastPage

public void lastPage()
Description copied from interface: PageNavigationSupport
Navigates to the last page.

Specified by:
lastPage in interface PageNavigationSupport

addPageNavigationListener

public void addPageNavigationListener(PageNavigationListener l)
Adds a PageNavigationListener to the page.

Specified by:
addPageNavigationListener in interface PageNavigationSupport
Parameters:
l - the PageNavigationListener to be added

removePageNavigationListener

public void removePageNavigationListener(PageNavigationListener l)
Removes a PageNavigationListener from the page.

Specified by:
removePageNavigationListener in interface PageNavigationSupport
Parameters:
l - the PageNavigationListener to be removed

getPageNavigationListeners

public PageNavigationListener[] getPageNavigationListeners()
Returns an array of all the PageNavigationListeners added to this Page with addPageNavigationListener .

Specified by:
getPageNavigationListeners in interface PageNavigationSupport
Returns:
all of the PageNavigationListeners added, or an empty array if no listeners have been added

firePageNavigationEvent

public void firePageNavigationEvent(Object source,
                                    int id,
                                    int oldValue,
                                    int newValue)
Runs each PageNavigationListener's PageNavigationEventFired method.

Specified by:
firePageNavigationEvent in interface PageNavigationSupport
Parameters:
source - of this event
id - event id.
oldValue - the old value associated with this event.
newValue - the new value associated with this event.

pageSizeChanged

protected void pageSizeChanged(int oldPageSize,
                               int newPageSize)
Adjusts the current page when page size changes so that the first row of the page is still visible after the page size changes.

Parameters:
oldPageSize - the previous page size
newPageSize - the new page size

pageCountChanged

protected abstract void pageCountChanged(int oldPageCount,
                                         int newPageCount)

pageIndexChanged

protected abstract void pageIndexChanged(int oldPageIndex,
                                         int newPageIndex)

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

tableChanged

public void tableChanged(TableModelEvent e)
Specified by:
tableChanged in interface TableModelListener

tableRowsInserted

protected void tableRowsInserted(int firstRow,
                                 int lastRow)
Called each time one or more contiguous rows are inserted into the underlying TableModel. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row that was inserted
lastRow - the index of the last row that was inserted

tableRowsDeleted

protected void tableRowsDeleted(int firstRow,
                                int lastRow)
Called each time one or more contiguous rows are deleted from the underlying TableModel. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row that was deleted
lastRow - the index of the last row that was deleted

tableRowsUpdated

protected void tableRowsUpdated(int firstRow,
                                int lastRow)
Called each time one or more contiguous rows are updated in the underlying TableModel. simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row that was updated
lastRow - the index of the last row that was updated

fireTableCellsUpdated

public void fireTableCellsUpdated(int firstRow,
                                  int lastRow,
                                  int column)
Called each time the cells in column in the range [firstRow, lastRow] are updated. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
firstRow - the index of the first row in the above column that was updated
lastRow - the index of the last row in the above column that was updated
column - the index of the column that was updated

tableCellsUpdated

protected void tableCellsUpdated(int column,
                                 int firstRow,
                                 int lastRow)
Called each time the cells in column in the range [firstRow, lastRow] are updated. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.

Parameters:
column - the index of the column that was updated
firstRow - the index of the first row in the above column that was updated
lastRow - the index of the last row in the above column that was updated

createCompoundTableModelEvent

protected CompoundTableModelEvent createCompoundTableModelEvent()
Creates a CompoundTableModelEvent instance.

Returns:
the CompoundTableModelEvent instance.

tableDataChanged

protected void tableDataChanged()
Called each time all of the data (i.e. all rows) is changed in the underlyingTableModel. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.


tableStructureChanged

protected void tableStructureChanged()
Called each time the structure (TableColumns, etc) of the underlying TableModel changes. This default implementation simply fires a corresponding TableModelEvent to the listeners on this model.


fireTableChanged

public void fireTableChanged(TableModelEvent e)
Overrides:
fireTableChanged in class AbstractTableModel

getConverterContextAt

public ConverterContext getConverterContextAt(int rowIndex,
                                              int columnIndex)
Description copied from interface: ContextSensitiveTableModel
Gets the converter context at cell (row, column).

For a special row index like -1, please return the default converter context for the entire column if there is any.

Specified by:
getConverterContextAt in interface ContextSensitiveTableModel
Parameters:
rowIndex - the row index
columnIndex - the column index
Returns:
converter context

getEditorContextAt

public EditorContext getEditorContextAt(int rowIndex,
                                        int columnIndex)
Description copied from interface: ContextSensitiveTableModel
Gets the editor context at cell (row, column).

For a special row index like -1, please return the default editor context for the entire column if there is any.

Specified by:
getEditorContextAt in interface ContextSensitiveTableModel
Parameters:
rowIndex - the row index
columnIndex - the column index
Returns:
editor context

getCellClassAt

public Class<?> getCellClassAt(int rowIndex,
                               int columnIndex)
Description copied from interface: ContextSensitiveTableModel
Gets the type at cell (row, column).

For a special row index like -1, please return the default column class for the entire column if there is any.

Specified by:
getCellClassAt in interface ContextSensitiveTableModel
Parameters:
rowIndex - the row index
columnIndex - the column index
Returns:
type

getColumnType

public int getColumnType(int columnIndex)
Description copied from interface: MultiTableModel
Checks if the column at the columnIndex is a header column or footer column or just regular column. Header columns will be displayed at the left side of the table. Footer columns will be on the right side. Regular columns will in the middle and will have horizontal scroll bar if there are a lot of columns.

Specified by:
getColumnType in interface MultiTableModel
Parameters:
columnIndex - the column index
Returns:
column type. The possible values are REGULAR_COLUMN, HEADER_COLUMN, or FOOTER_COLUMN.

getTableIndex

public int getTableIndex(int columnIndex)
Description copied from interface: MultiTableModel
Gets the table index that this column belongs to. As convention, the table index starts from 0. So all columns that return 0 in this method will be grouped into the first table. Those return 1 will be on the second table, and so on.

Specified by:
getTableIndex in interface MultiTableModel
Parameters:
columnIndex - the column index
Returns:
the table index.

JIDE 3.5.15