Diamond Control Suite 3.0

diamondedge.swing.grid
Class ResultSetTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by diamondedge.swing.grid.AbstractGridRowModel
          extended by diamondedge.swing.grid.ResultSetTableModel
All Implemented Interfaces:
GridRowModel, Serializable, TableModel

public class ResultSetTableModel
extends AbstractGridRowModel
implements GridRowModel

You do not want to make the RowHeaderVisible or set individual RowHeights or turn sorting on when there is a large amount of data.

This requires drivers which support JDBC 2.0 scrollable cursors. If scrollable cursors are not available then you can load the data into the Grid using DsGrid.loadResultSet()

See Also:
DsGrid.loadResultSet(java.sql.ResultSet, boolean), Serialized Form

Field Summary
 
Fields inherited from class diamondedge.swing.grid.AbstractGridRowModel
curRow
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ResultSetTableModel(Connection con, String sql)
           
ResultSetTableModel(ResultSet rs)
           
 
Method Summary
 void cancelChanges()
          Cancels any edits that have been made to the current row.
 void finalize()
           
 int getCacheSize()
          Returns the number of column values that will be cached.
 int getColumn(String colName)
           
 int getColumnCount()
          Returns the number of columns in this data table.
 String getColumnName(int column)
          Returns the column name.
 ResultSet getResultSet()
           
 int getRowCount()
          Returns the number of rows in this data table.
 Object getValueAt(int row, int column)
           
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 boolean isChanged()
          Returns true if any edits or changes have been made to the current row.
 boolean isEditable()
          Returns whether any cells can be edited by the user.
 void saveChanges()
          Save any edits or changes that have been made to the current row.
 void setCacheSize(int cacheSize)
          Sets the number of column values that will be cached.
 void setChanged(boolean markChanged)
          If set to true then the current row will be marked to be saved.
 void setEditable(boolean editable)
          Returns whether the user can edit any cell.
 void setResultSet(Connection con, String sql)
          A ResultSet will be created based on the given connection and SQL query.
 void setResultSet(ResultSet rs)
          Sets the ResultSet to be used to retrieve the data from.
 void setRowPosition(int rowNumber)
          Sets the current record number for the database cursor.
 void setValueAt(Object val, int row, int column)
           
 void updateRow()
           
 
Methods inherited from class diamondedge.swing.grid.AbstractGridRowModel
addGridRowListener, fireRowChanged, getRowPosition, removeGridRowListener
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface diamondedge.swing.grid.GridRowModel
addGridRowListener, getRowPosition, removeGridRowListener
 

Constructor Detail

ResultSetTableModel

public ResultSetTableModel(ResultSet rs)
                    throws SQLException
Throws:
SQLException

ResultSetTableModel

public ResultSetTableModel(Connection con,
                           String sql)
                    throws SQLException
Throws:
SQLException
Method Detail

finalize

public void finalize()
Overrides:
finalize in class Object

setRowPosition

public void setRowPosition(int rowNumber)
Sets the current record number for the database cursor. Lost focus sets RowPosition to -1

Specified by:
setRowPosition in interface GridRowModel
Overrides:
setRowPosition in class AbstractGridRowModel

isEditable

public boolean isEditable()
Returns whether any cells can be edited by the user.


setEditable

public void setEditable(boolean editable)
Returns whether the user can edit any cell. Updates normally occur automatically when the current record is changed.


getResultSet

public ResultSet getResultSet()

setResultSet

public void setResultSet(ResultSet rs)
                  throws SQLException
Sets the ResultSet to be used to retrieve the data from. The JDBC driver must be JDBC 2.0 compliant.

Throws:
SQLException

setResultSet

public void setResultSet(Connection con,
                         String sql)
                  throws SQLException
A ResultSet will be created based on the given connection and SQL query. This ResultSet will then be used to retrieve the data from. The JDBC driver must be JDBC 2.0 compliant.

Throws:
SQLException

getCacheSize

public int getCacheSize()
Returns the number of column values that will be cached.


setCacheSize

public void setCacheSize(int cacheSize)
Sets the number of column values that will be cached.


getRowCount

public int getRowCount()
Returns the number of rows in this data table.

Specified by:
getRowCount in interface TableModel
Returns:
the number of rows in the model

getValueAt

public Object getValueAt(int row,
                         int column)
Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object val,
                       int row,
                       int column)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

cancelChanges

public void cancelChanges()
Cancels any edits that have been made to the current row.

Specified by:
cancelChanges in interface GridRowModel

saveChanges

public void saveChanges()
Save any edits or changes that have been made to the current row.

Specified by:
saveChanges in interface GridRowModel

isChanged

public boolean isChanged()
Returns true if any edits or changes have been made to the current row.

Specified by:
isChanged in interface GridRowModel

setChanged

public void setChanged(boolean markChanged)
If set to true then the current row will be marked to be saved. If set to false changes are cancelled.

Specified by:
setChanged in interface GridRowModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. Otherwise, the setValueAt() on the cell will not change the value of that cell.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
true if the cell is editable.
See Also:
setValueAt(java.lang.Object, int, int)

updateRow

public void updateRow()
               throws SQLException
Throws:
SQLException

getColumnCount

public int getColumnCount()
Returns the number of columns in this data table.

Specified by:
getColumnCount in interface TableModel
Returns:
the number of columns in the model

getColumnName

public String getColumnName(int column)
Returns the column name.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Returns:
a name for this column using the string value of the appropriate member in columnIdentfiers. If columnIdentfiers is null or does not have and entry for this index return the default name provided by the superclass.

getColumn

public int getColumn(String colName)

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.