|
JComponentPack 1.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
com.zfqjava.swing.model.ResultSetTableModel
public class ResultSetTableModel
ResultSetTableModel provides a
ResultSet 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.
| Field Summary | |
|---|---|
static int |
CHANGE_CELL
Identifies the update or insert policy. |
static int |
CHANGE_PAGE
Identifies the update or insert policy. |
static int |
CHANGE_ROW
Identifies the update or insert policy. |
protected SwingPropertyChangeSupport |
changeSupport
If any PropertyChangeListeners have been registered, the
changeSupport field describes them. |
static int |
OFF
Identifies the update or insert policy. |
static int |
UNKNOWN_COUNT
Identifies the unknown for page or all row count. |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
ResultSetTableModel()
Empty ResultSetTableModel |
|
ResultSetTableModel(ResultSet rs)
Constructs a ResultSetTableModel with a rs. |
|
ResultSetTableModel(ResultSet rs,
boolean sync)
Constructs a ResultSetTableModel with a rs. |
|
ResultSetTableModel(ResultSet rs,
boolean sync,
int pageSize)
Constructs a ResultSetTableModel with a rs. |
|
ResultSetTableModel(ResultSet rs,
int pageSize)
Constructs a ResultSetTableModel with a rs. |
|
ResultSetTableModel(String sql,
String url,
String username,
String password)
Constructs a ResultSetTableModel with a SQL query command. |
|
ResultSetTableModel(String sql,
String url,
String username,
String password,
boolean sync)
Constructs a ResultSetTableModel with a SQL query command. |
|
ResultSetTableModel(String sql,
String url,
String username,
String password,
boolean sync,
int pageSize)
Constructs a ResultSetTableModel with a SQL query command. |
|
ResultSetTableModel(String sql,
String url,
String username,
String password,
int pageSize)
Constructs a ResultSetTableModel with a SQL query command. |
|
| Method Summary | |
|---|---|
void |
acceptChanges()
Propagates all row update, insert and delete changes to the underlying data source. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
close()
Close the database connection. |
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 |
protected void |
firePropertyChange(String propertyName,
int oldValue,
int newValue)
|
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Supports reporting bound property changes. |
void |
firstPage()
|
void |
firstRow()
Goto the fist row. |
int |
getAllRowCount()
Returns all row count. |
int |
getAutoInsertPolicy()
Returns the auto insert policy. |
int |
getAutoUpdatePolicy()
Returns the auto update policy. |
Class |
getColumnClass(int columnIndex)
|
int |
getColumnCount()
|
String |
getColumnName(int columnIndex)
|
String |
getCommand()
Returns the command. |
String |
getCountCommand()
|
int |
getCurrentAllRowCount()
|
int |
getFirstRowIndex()
Returns the first row index in current page. |
int[] |
getKeyColumns()
Returns the primary key columns. |
int |
getPageCount()
Returns the page count. |
int |
getPageIndex()
Returns the current page index. |
int |
getPageSize()
Returns the page size. |
String |
getPassword()
Returns the password |
PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all the PropertyChangeListeners added
to this ResultSetTableModel with addPropertyChangeListener(). |
int |
getRowCount()
|
int |
getRowIndex()
Returns the current row index. |
String |
getTableName()
Returns the table name for updating. |
String |
getUrl()
Returns the url. |
String |
getUsername()
Returns the user name. |
Object |
getValueAt(int rowIndex,
int columnIndex)
|
boolean |
hasNextPage()
|
boolean |
hasPreviousPage()
|
void |
insertRow()
Inserts the data row. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
|
boolean |
isFirstPage()
|
boolean |
isLastPage()
|
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 |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
setAllRowCount(int allRowCount)
|
void |
setAutoInsertPolicy(int insertPolicy)
Sets the auto insert policy. |
void |
setAutoUpdatePolicy(int updatePolicy)
Sets the auto update policy. |
void |
setCommand(String sql)
Sets the command. |
void |
setCountCommand(String countCommand)
|
void |
setKeyColumns(int[] keyColumns)
Sets the primary key columns. |
void |
setPageIndex(int pageIndex)
Sets the page index. |
void |
setPassword(String password)
Sets the password |
void |
setRowIndex(int rowIndex)
Sets the row index. |
void |
setTableName(String tableName)
Sets the table name for updating. |
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 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 |
| Field Detail |
|---|
public static final int CHANGE_CELL
acceptChanges(),
Constant Field Valuespublic static final int CHANGE_ROW
acceptChanges(),
Constant Field Valuespublic static final int CHANGE_PAGE
acceptChanges(),
Constant Field Valuespublic static final int OFF
acceptChanges(),
Constant Field Valuespublic static final int UNKNOWN_COUNT
getPageCount(),
getAllRowCount(),
Constant Field Valuesprotected SwingPropertyChangeSupport changeSupport
PropertyChangeListeners have been registered, the
changeSupport field describes them.
| Constructor Detail |
|---|
public ResultSetTableModel()
public ResultSetTableModel(String sql,
String url,
String username,
String password)
sql - the SQL commandurl - the JDBC url for connectionusername - the user name for connectionpassword - the password for connection
public ResultSetTableModel(String sql,
String url,
String username,
String password,
int pageSize)
sql - the SQL commandurl - the JDBC url for connectionusername - the user name for connectionpassword - the password for connectionpageSize - the page size for the record
public ResultSetTableModel(String sql,
String url,
String username,
String password,
boolean sync)
sql - the SQL commandurl - the JDBC url for connectionusername - the user name for connectionpassword - the password for connectionsync - the synchronized flag
public ResultSetTableModel(String sql,
String url,
String username,
String password,
boolean sync,
int pageSize)
sql - the SQL commandurl - the JDBC url for connectionusername - the user name for connectionpassword - the password for connectionsync - the synchronized flagpageSize - the page size for the recordpublic ResultSetTableModel(ResultSet rs)
rs.
rs - the ResultSet
public ResultSetTableModel(ResultSet rs,
boolean sync)
rs.
rs - the ResultSetsync - the synchronized flag
public ResultSetTableModel(ResultSet rs,
int pageSize)
rs.
rs - the ResultSetpageSize - the page size for the record
public ResultSetTableModel(ResultSet rs,
boolean sync,
int pageSize)
rs.
rs - the ResultSetsync - the synchronized flagpageSize - the page size for the record| Method Detail |
|---|
public void close()
public void setUrl(String url)
url - the urlpublic String getUrl()
public void setUsername(String username)
username - public String getUsername()
public void setPassword(String password)
password - the passwordpublic String getPassword()
public void setCommand(String sql)
sql - the SQL commandpublic String getCommand()
public String getCountCommand()
public void setCountCommand(String countCommand)
public void reload()
reload in interface Reloadablepublic int getPageSize()
getPageSize in interface Pageablepublic int getPageCount()
getPageCount in interface Pageablepublic void setPageIndex(int pageIndex)
setPageIndex in interface PageablepageIndex - the page indexgetPageIndex()public int getPageIndex()
getPageIndex in interface PageablesetPageIndex(int)public void nextPage()
nextPage in interface Pageablepublic void previousPage()
previousPage in interface Pageablepublic boolean hasNextPage()
hasNextPage in interface Pageablepublic boolean hasPreviousPage()
hasPreviousPage in interface Pageablepublic void firstPage()
firstPage in interface Pageablepublic void lastPage()
lastPage in interface Pageablepublic boolean isFirstPage()
isFirstPage in interface Pageablepublic boolean isLastPage()
isLastPage in interface Pageablepublic void setRowIndex(int rowIndex)
rowIndex - the row indexgetRowIndex()public int getRowIndex()
setRowIndex(int)public int getFirstRowIndex()
public int getAllRowCount()
Note:This is different with getRowCount
when use page mode.
getAllRowCount in interface Pageablepublic void setAllRowCount(int allRowCount)
allRowCount - public int getCurrentAllRowCount()
public void nextRow()
public void lastRow()
public void previousRow()
public void firstRow()
public void setAutoUpdatePolicy(int updatePolicy)
updatePolicy - the update policyacceptChanges()public int getAutoUpdatePolicy()
acceptChanges()public void setAutoInsertPolicy(int insertPolicy)
insertPolicy - the insert policyacceptChanges()public int getAutoInsertPolicy()
acceptChanges()public void setTableName(String tableName)
tableName - the table name for updatinggetTableName()public String getTableName()
setTableName(java.lang.String)public void setKeyColumns(int[] keyColumns)
columns - the primary columnsgetKeyColumns()public int[] getKeyColumns()
setKeyColumns(int[])
public void updateCell(int rowIndex,
int columnIndex)
rowIndex - the data row indexcolumnIndex - the data column index
public void refreshCell(int rowIndex,
int columnIndex)
rowIndex - the data row indexcolumnIndex - the data column index
public void updateCell(int firstRow,
int lastRow,
int firstColumn,
int lastColumn)
firstRow - the first row index of the specified cell arealastRow - the last row index of the specified cell areafirstColumn - the first column index of the specified cell arealastColumn - the last column index of the specified cell area
public void refreshCell(int firstRow,
int lastRow,
int firstColumn,
int lastColumn)
firstRow - the first row index of the specified cell arealastRow - the last row index of the specified cell areafirstColumn - the first column index of the specified cell arealastColumn - the last column index of the specified cell areapublic void updateRow()
public void updateRow(int rowIndex)
rowIndex - the row index
public void updateRow(int firstRow,
int lastRow)
firstRow to lastRow
firstRow - the first row indexlastRow - the last row indexpublic void deleteRow()
public void deleteRow(int rowIndex)
rowIndex - the row index
public void deleteRow(int firstRow,
int lastRow)
firstRow to lastRow
firstRow - the first row indexlastRow - the last row indexpublic void refreshRow()
public void refreshRow(int rowIndex)
rowIndex - the row index
public void refreshRow(int firstRow,
int lastRow)
firstRow to lastRow
firstRow - the first row indexlastRow - the last row indexpublic int modelToDataRow(int modelRow)
modelRow - the mode row index
public void insertRow()
public void moveToInsertRow()
public int dataToModelRow(int dataRow)
dataRow - the data row index
public int getRowCount()
getRowCount in interface PageablegetRowCount in interface TableModelpublic int getColumnCount()
getColumnCount in interface TableModelpublic String getColumnName(int columnIndex)
getColumnName in interface TableModelgetColumnName in class AbstractTableModelpublic Class getColumnClass(int columnIndex)
getColumnClass in interface TableModelgetColumnClass in class AbstractTableModel
public boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface TableModelisCellEditable in class AbstractTableModel
public Object getValueAt(int rowIndex,
int columnIndex)
getValueAt in interface TableModel
public void setValueAt(Object aValue,
int rowIndex,
int columnIndex)
setValueAt in interface TableModelsetValueAt in class AbstractTableModelpublic void acceptChanges()
protected void firePropertyChange(String propertyName,
int oldValue,
int newValue)
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
PropertyChangeEvent to any registered
PropertyChangeListeners.
public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener to the listener list.
The listener is registered for all properties.
A PropertyChangeEvent will get fired in response to setting
a bound property, e.g. setFont, setBackground,
or setForeground.
Note that if the current component is inheriting its foreground,
background, or font from its container, then no event will be
fired in response to a change in the inherited property.
listener - The PropertyChangeListener to be addedAction#addPropertyChangeListenerpublic void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties.
listener - the PropertyChangeListener to be removedAction#removePropertyChangeListenerpublic PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListeners added
to this ResultSetTableModel with addPropertyChangeListener().
PropertyChangeListeners added or an empty
array if no listeners have been added
|
JComponentPack 1.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||