JComponentPack 1.3.0

com.zfqjava.swing.model
Class RowSetTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.zfqjava.swing.model.ResultSetTableModel
          extended by com.zfqjava.swing.model.RowSetTableModel
All Implemented Interfaces:
Pageable, Reloadable, Serializable, TableModel

public class RowSetTableModel
extends ResultSetTableModel

RowSetTableModel provides a RowSet table model.

The TableModel methods use the model row index, all other methods use the data row index of the ResultSet, but it is 0 based.
The page index also is 0 based.
All row index must be >= 0, and all first index must be <= last index.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.zfqjava.swing.model.ResultSetTableModel
CHANGE_CELL, CHANGE_PAGE, CHANGE_ROW, changeSupport, OFF, UNKNOWN_COUNT
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
RowSetTableModel(RowSet rs, boolean sync, int pageSize)
           
RowSetTableModel(RowSet rs, int pageSize)
           
 
Method Summary
 void acceptChanges()
          Propagates all row update, insert and delete changes to the underlying data source.
 int dataToModelRow(int dataRow)
          Converts the ResultSet row index to the model row index.
 void deleteRow()
          Deletes the data row at the specified current row index.
 void deleteRow(int rowIndex)
          Deletes the data row at the specified row index.
 void deleteRow(int firstRow, int lastRow)
          Deletes the data row from firstRow to lastRow
 void firstPage()
           
 void firstRow()
          Goto the fist row.
 int getAllRowCount()
          Returns all row count.
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 String getCommand()
          Returns the command.
 int getFirstRowIndex()
          Returns the first row index in current page.
 int getPageCount()
          Returns the page count.
 int getPageIndex()
          Returns the current page index.
 int getPageSize()
          Returns the page size.
 String getPassword()
          Returns the password
 int getRowCount()
           
 int getRowIndex()
          Returns the current row index.
 String getUrl()
          Returns the url.
 String getUsername()
          Returns the user name.
 Object getValueAt(int rowIndex, int columnIndex)
           
 void insertRow()
          Inserts the data row.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void lastPage()
           
 void lastRow()
          Goto the last row.
 int modelToDataRow(int modelRow)
          Converts the model row index to the ResultSet row index.
 void moveToInsertRow()
          Move the cursor to the insert row.
 void nextPage()
          Show the next page.
 void nextRow()
          Goto the next row.
 void previousPage()
          Show the previous page.
 void previousRow()
          Goto the previous row.
 void refreshCell(int rowIndex, int columnIndex)
          Refreshs the cell at the specified row and column index.
 void refreshCell(int firstRow, int lastRow, int firstColumn, int lastColumn)
          Refreshs the cell at the specified row and column index.
 void refreshRow()
          Refreshs the data row at the specified current row index.
 void refreshRow(int rowIndex)
          Refreshs the data row at the specified row index.
 void refreshRow(int firstRow, int lastRow)
          Refreshs the data row from firstRow to lastRow
 void reload()
          Reloads all record from database.
 void setCommand(String sql)
          Sets the command.
 void setPageIndex(int pageIndex)
          Sets the page index.
 void setPassword(String password)
          Sets the password
 void setRowIndex(int rowIndex)
          Sets the row index.
 void setUrl(String url)
          Sets the url.
 void setUsername(String username)
          Sets the user name.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 void updateCell(int rowIndex, int columnIndex)
          Updates the cell at the specified row and column index.
 void updateCell(int firstRow, int lastRow, int firstColumn, int lastColumn)
          Updates the cell at the specified row and column index.
 void updateRow()
          Updates the data row at the specified current row index.
 void updateRow(int rowIndex)
          Updates the data row at the specified row index.
 void updateRow(int firstRow, int lastRow)
          Updates the data row from firstRow to lastRow
 
Methods inherited from class com.zfqjava.swing.model.ResultSetTableModel
addPropertyChangeListener, close, firePropertyChange, firePropertyChange, getAutoInsertPolicy, getAutoUpdatePolicy, getCountCommand, getCurrentAllRowCount, getKeyColumns, getPropertyChangeListeners, getTableName, hasNextPage, hasPreviousPage, isFirstPage, isLastPage, removePropertyChangeListener, setAllRowCount, setAutoInsertPolicy, setAutoUpdatePolicy, setCountCommand, setKeyColumns, setTableName
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowSetTableModel

public RowSetTableModel(RowSet rs,
                        int pageSize)

RowSetTableModel

public RowSetTableModel(RowSet rs,
                        boolean sync,
                        int pageSize)
Method Detail

setUrl

public void setUrl(String url)
Sets the url.

Overrides:
setUrl in class ResultSetTableModel
Parameters:
url - the url
Since:
JDataGrid 1.3

getUrl

public String getUrl()
Returns the url.

Overrides:
getUrl in class ResultSetTableModel
Returns:
the url
Since:
JDataGrid 1.3

setUsername

public void setUsername(String username)
Sets the user name.

Overrides:
setUsername in class ResultSetTableModel
Parameters:
username -
Since:
JDataGrid 1.3

getUsername

public String getUsername()
Returns the user name.

Overrides:
getUsername in class ResultSetTableModel
Returns:
the user name
Since:
JDataGrid 1.3

setPassword

public void setPassword(String password)
Sets the password

Overrides:
setPassword in class ResultSetTableModel
Parameters:
password - the password
Since:
JDataGrid 1.3

getPassword

public String getPassword()
Returns the password

Overrides:
getPassword in class ResultSetTableModel
Returns:
the password
Since:
JDataGrid 1.3

setCommand

public void setCommand(String sql)
Sets the command.

Overrides:
setCommand in class ResultSetTableModel
Parameters:
sql - the SQL command
Since:
JDataGrid 1.3

getCommand

public String getCommand()
Returns the command.

Overrides:
getCommand in class ResultSetTableModel
Returns:
the SQL command
Since:
JDataGrid 1.3

reload

public void reload()
Reloads all record from database.

Specified by:
reload in interface Reloadable
Overrides:
reload in class ResultSetTableModel

firstPage

public void firstPage()
Specified by:
firstPage in interface Pageable
Overrides:
firstPage in class ResultSetTableModel

lastPage

public void lastPage()
Specified by:
lastPage in interface Pageable
Overrides:
lastPage in class ResultSetTableModel

getPageSize

public int getPageSize()
Returns the page size.

Specified by:
getPageSize in interface Pageable
Overrides:
getPageSize in class ResultSetTableModel
Returns:
the page size
Since:
JDataGrid 1.3

getPageCount

public int getPageCount()
Returns the page count.

Specified by:
getPageCount in interface Pageable
Overrides:
getPageCount in class ResultSetTableModel
Returns:
the page count
Since:
JDataGrid 1.3

setPageIndex

public void setPageIndex(int pageIndex)
Sets the page index.

Specified by:
setPageIndex in interface Pageable
Overrides:
setPageIndex in class ResultSetTableModel
Parameters:
pageIndex - the page index
Since:
JDataGrid 1.3
See Also:
getPageIndex()

getPageIndex

public int getPageIndex()
Returns the current page index.

Specified by:
getPageIndex in interface Pageable
Overrides:
getPageIndex in class ResultSetTableModel
Returns:
the page index
Since:
JDataGrid 1.3
See Also:
setPageIndex(int)

nextPage

public void nextPage()
Show the next page.

Specified by:
nextPage in interface Pageable
Overrides:
nextPage in class ResultSetTableModel
Since:
JDataGrid 1.3

lastRow

public void lastRow()
Goto the last row.

Overrides:
lastRow in class ResultSetTableModel
Since:
JDataGrid 1.3

previousPage

public void previousPage()
Show the previous page.

Specified by:
previousPage in interface Pageable
Overrides:
previousPage in class ResultSetTableModel
Since:
JDataGrid 1.3

firstRow

public void firstRow()
Goto the fist row.

Overrides:
firstRow in class ResultSetTableModel
Since:
JDataGrid 1.3

setRowIndex

public void setRowIndex(int rowIndex)
Sets the row index.

Overrides:
setRowIndex in class ResultSetTableModel
Parameters:
rowIndex - the row index
Since:
JDataGrid 1.3
See Also:
getRowIndex()

getRowIndex

public int getRowIndex()
Returns the current row index.

Overrides:
getRowIndex in class ResultSetTableModel
Returns:
the row index
Since:
JDataGrid 1.3
See Also:
setRowIndex(int)

getFirstRowIndex

public int getFirstRowIndex()
Returns the first row index in current page.

Overrides:
getFirstRowIndex in class ResultSetTableModel
Returns:
the first row index
Since:
JDataGrid 1.3

getAllRowCount

public int getAllRowCount()
Returns all row count.

Note:This is different with getRowCount when use page mode.

Specified by:
getAllRowCount in interface Pageable
Overrides:
getAllRowCount in class ResultSetTableModel
Returns:
all row count in the result set
Since:
JDataGrid 1.3

nextRow

public void nextRow()
Goto the next row.

Overrides:
nextRow in class ResultSetTableModel
Since:
JDataGrid 1.3

previousRow

public void previousRow()
Goto the previous row.

Overrides:
previousRow in class ResultSetTableModel
Since:
JDataGrid 1.3

modelToDataRow

public int modelToDataRow(int modelRow)
Converts the model row index to the ResultSet row index.

Overrides:
modelToDataRow in class ResultSetTableModel
Parameters:
modelRow - the mode row index
Returns:
the ResultSet row index for the specified model row index

dataToModelRow

public int dataToModelRow(int dataRow)
Converts the ResultSet row index to the model row index.

Overrides:
dataToModelRow in class ResultSetTableModel
Parameters:
dataRow - the data row index
Returns:
the model index for the specified ResultSet row index

insertRow

public void insertRow()
Inserts the data row.

Overrides:
insertRow in class ResultSetTableModel
Since:
JDataGrid 1.4

moveToInsertRow

public void moveToInsertRow()
Move the cursor to the insert row.

Overrides:
moveToInsertRow in class ResultSetTableModel
Since:
JDataGrid 1.8

updateCell

public void updateCell(int rowIndex,
                       int columnIndex)
Updates the cell at the specified row and column index.

Overrides:
updateCell in class ResultSetTableModel
Parameters:
rowIndex - the data row index
columnIndex - the data column index
Since:
JDataGrid 1.3

refreshCell

public void refreshCell(int rowIndex,
                        int columnIndex)
Refreshs the cell at the specified row and column index.

Overrides:
refreshCell in class ResultSetTableModel
Parameters:
rowIndex - the data row index
columnIndex - the data column index
Since:
JDataGrid 1.3

updateCell

public void updateCell(int firstRow,
                       int lastRow,
                       int firstColumn,
                       int lastColumn)
Updates the cell at the specified row and column index.

Overrides:
updateCell in class ResultSetTableModel
Parameters:
firstRow - the first row index of the specified cell area
lastRow - the last row index of the specified cell area
firstColumn - the first column index of the specified cell area
lastColumn - the last column index of the specified cell area
Since:
JDataGrid 1.3

refreshCell

public void refreshCell(int firstRow,
                        int lastRow,
                        int firstColumn,
                        int lastColumn)
Refreshs the cell at the specified row and column index.

Overrides:
refreshCell in class ResultSetTableModel
Parameters:
firstRow - the first row index of the specified cell area
lastRow - the last row index of the specified cell area
firstColumn - the first column index of the specified cell area
lastColumn - the last column index of the specified cell area
Since:
JDataGrid 1.3

updateRow

public void updateRow()
Updates the data row at the specified current row index.

Overrides:
updateRow in class ResultSetTableModel
Since:
JDataGrid 1.3

updateRow

public void updateRow(int rowIndex)
Updates the data row at the specified row index.

Overrides:
updateRow in class ResultSetTableModel
Parameters:
rowIndex - the row index
Since:
JDataGrid 1.3

updateRow

public void updateRow(int firstRow,
                      int lastRow)
Updates the data row from firstRow to lastRow

Overrides:
updateRow in class ResultSetTableModel
Parameters:
firstRow - the first row index
lastRow - the last row index
Since:
JDataGrid 1.3

deleteRow

public void deleteRow()
Deletes the data row at the specified current row index.

Overrides:
deleteRow in class ResultSetTableModel
Since:
JDataGrid 1.3

deleteRow

public void deleteRow(int rowIndex)
Deletes the data row at the specified row index.

Overrides:
deleteRow in class ResultSetTableModel
Parameters:
rowIndex - the row index
Since:
JDataGrid 1.3

deleteRow

public void deleteRow(int firstRow,
                      int lastRow)
Deletes the data row from firstRow to lastRow

Overrides:
deleteRow in class ResultSetTableModel
Parameters:
firstRow - the first row index
lastRow - the last row index
Since:
JDataGrid 1.3

refreshRow

public void refreshRow()
Refreshs the data row at the specified current row index.

Overrides:
refreshRow in class ResultSetTableModel
Since:
JDataGrid 1.3

refreshRow

public void refreshRow(int rowIndex)
Refreshs the data row at the specified row index.

Overrides:
refreshRow in class ResultSetTableModel
Parameters:
rowIndex - the row index
Since:
JDataGrid 1.3

refreshRow

public void refreshRow(int firstRow,
                       int lastRow)
Refreshs the data row from firstRow to lastRow

Overrides:
refreshRow in class ResultSetTableModel
Parameters:
firstRow - the first row index
lastRow - the last row index
Since:
JDataGrid 1.3

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface Pageable
Specified by:
getRowCount in interface TableModel
Overrides:
getRowCount in class ResultSetTableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel
Overrides:
getColumnCount in class ResultSetTableModel

getColumnName

public String getColumnName(int columnIndex)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class ResultSetTableModel

getColumnClass

public Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class ResultSetTableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class ResultSetTableModel

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class ResultSetTableModel

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class ResultSetTableModel

acceptChanges

public void acceptChanges()
Description copied from class: ResultSetTableModel
Propagates all row update, insert and delete changes to the underlying data source.

Overrides:
acceptChanges in class ResultSetTableModel

JComponentPack 1.3.0

Send your Feedback
JComponentPack 1.3.0
Copyright © 2001-2007 Extreme Component, Inc. All rights reserved.