JIDE 3.5.15

com.jidesoft.database
Class CrudDatabaseTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jidesoft.database.DatabaseTableModel
          extended by com.jidesoft.database.CrudDatabaseTableModel
All Implemented Interfaces:
CrudRowOperations, CrudTableModel, AutoFilterTableHeaderAdapter, AutoFilterTableModel, ContextSensitiveTableModel, IFilterableTableModel, ISortableTableModel, Serializable, TableModel

public class CrudDatabaseTableModel
extends DatabaseTableModel
implements CrudTableModel

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.ISortableTableModel
ISortableTableModel.SortItem
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.IFilterableTableModel
IFilterableTableModel.FilterItem
 
Nested classes/interfaces inherited from interface com.jidesoft.grid.AutoFilterTableHeaderAdapter
AutoFilterTableHeaderAdapter.FilterTitleFormatter
 
Field Summary
protected  ResultSetTableModelCrudSupport _crudSupport
           
protected  Record insertRow
           
protected  boolean isInInsertRow
           
 
Fields inherited from class com.jidesoft.database.DatabaseTableModel
_connection, _converterContexts, _filterItemSupport, _fromStatement, _preStatement, _resultSetTableModel, _selectStatement, _sortItemSupport, _statement
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface com.jidesoft.grid.ISortableTableModel
SORT_PRIORITY_FIFO, SORT_PRIORITY_FILO
 
Fields inherited from interface com.jidesoft.grid.IFilterableTableModel
ALL_COLUMNS, ANY_COLUMNS, IDENTIFIER_ALL_COLUMNS, IDENTIFIER_ANY_COLUMNS
 
Constructor Summary
CrudDatabaseTableModel(Connection connection, String fromStatement)
          Creates a CrudDatabaseTableModel.
CrudDatabaseTableModel(Connection connection, String selectStatement, String fromStatement)
          Creates a CrudDatabaseTableModel.
CrudDatabaseTableModel(Connection connection, String selectStatement, String fromStatement, boolean updatable)
          Creates a CrudDatabaseTableModel.
 
Method Summary
protected  ResultSetTableModel createResultSetTableModel(ResultSet resultSet, int rowCount)
           
protected  Record createRowRecord()
           
 void deleteRow(int rowIndex)
          Delete data of a designated row.
 int getRowCount()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
 void insertRow(Record record)
          Implementation of the CrudTableModel interface (Create, Read, Update and Delete operations over rows on table models)
 Record readRow(int rowIndex)
          Read data of a designated row.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 void updateRow(int rowIndex, Record record)
          Update data of a designated row with data.
 
Methods inherited from class com.jidesoft.database.DatabaseTableModel
addFilter, addFilter, addFilter, addFilterableTableModelListener, addSortListener, adjustStatement, clearFilters, close, commit, configureConverterContexts, convertElementToString, createCountStatement, createOrderStatement, createPossibleValuesStatement, createReadonlyStatement, createSqlStatement, createStatement, createWhereStatement, fireFilterAdded, fireFilterChanged, fireFilterRemoved, fireSortEvent, fireSortingEvent, getActualRowAt, getCellClassAt, getColumnClass, getColumnCount, getColumnMapping, getColumnName, getColumnSortRank, getConverterContextAt, getDynamicTableFilters, getEditorContextAt, getFilterableTableModelListeners, getFilterIcon, getFilterItems, getFilters, getFilterTitleFormatter, getListCellRenderer, getMasterSortColumns, getMaximumSortColumns, getPossibleValues, getPossibleValuesAndConverters, getSortedRowAt, getSortingColumns, getSortListeners, getSortPriority, getTitleConverter, hasFilter, hasFilter, initDatabase, invalidateCache, invalidateCache, isAdjusting, isAllowCustomFilter, isAllowMultipleValues, isAndMode, isCellEditable, isColumnAscending, isColumnAutoFilterable, isColumnFilterable, isColumnSortable, isColumnSorted, isColumnVisible, isConsiderCurrencyField, isFilteringPaused, isFiltersApplied, isMultiColumnSortable, isSameConverterAt, isSortable, isUpdatable, isUseTableCellRenderer, isValuePredetermined, prepareWhereStatement, refresh, refreshData, removeAllFilters, removeAllFilters, removeFilter, removeFilter, removeFilter, removeFilterableTableModelListener, removeSortListener, reset, resort, reverseColumnSortOrder, setAdjusting, setAndMode, setColumnMapping, setColumnSortable, setConsiderCurrencyField, setFilteringPaused, setFiltersApplied, setMasterSortColumns, setMaximumSortColumns, setMultiColumnSortable, setSortable, setSortingColumns, setSortPriority, setUpdatable, sort, sortColumn, sortColumn, sortColumn, toggleSortOrder, unsortColumn, validate, validateNullable, validatePrecision, validateSigned
 
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
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, isCellEditable, removeTableModelListener
 

Field Detail

_crudSupport

protected ResultSetTableModelCrudSupport _crudSupport

insertRow

protected Record insertRow

isInInsertRow

protected volatile boolean isInInsertRow
Constructor Detail

CrudDatabaseTableModel

public CrudDatabaseTableModel(Connection connection,
                              String fromStatement)
                       throws SQLException
Creates a CrudDatabaseTableModel.

Parameters:
connection - a database connection.
fromStatement - a SQL from statement. It could be
  • FROM first_table
  • FROM first_table, second_table
  • FROM first_table LEFT JOIN second_table
  • FROM first_table INNER JOIN second_table
Throws:
SQLException - if a database related error happens. It could be because the connection is closed.

CrudDatabaseTableModel

public CrudDatabaseTableModel(Connection connection,
                              String selectStatement,
                              String fromStatement)
                       throws SQLException
Creates a CrudDatabaseTableModel.

Parameters:
connection - a database connection.
selectStatement - a SQL select statement. If null, we default it to "*".
fromStatement - a SQL from statement. It could be
  • FROM first_table
  • FROM first_table, second_table
  • FROM first_table LEFT JOIN second_table
  • FROM first_table INNER JOIN second_table
Throws:
SQLException - if a database related error happens. It could be because the connection is closed.

CrudDatabaseTableModel

public CrudDatabaseTableModel(Connection connection,
                              String selectStatement,
                              String fromStatement,
                              boolean updatable)
                       throws SQLException
Creates a CrudDatabaseTableModel.

Parameters:
connection - a database connection.
selectStatement - a SQL select statement. If null, we default it to "*".
fromStatement - a SQL from statement. It could be
  • FROM first_table
  • FROM first_table, second_table
  • FROM first_table LEFT JOIN second_table
  • FROM first_table INNER JOIN second_table
updatable - if the table model is updatable (or editable)
Throws:
SQLException - if a database related error happens. It could be because the connection is closed.
Method Detail

getRowCount

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

getValueAt

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

setValueAt

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

insertRow

public void insertRow(Record record)
               throws Exception
Implementation of the CrudTableModel interface (Create, Read, Update and Delete operations over rows on table models)

Specified by:
insertRow in interface CrudRowOperations
Parameters:
record - the data structure
Throws:
Exception - if encouting any database update error

createRowRecord

protected Record createRowRecord()

readRow

public Record readRow(int rowIndex)
               throws Exception
Description copied from interface: CrudRowOperations
Read data of a designated row.

Specified by:
readRow in interface CrudRowOperations
Parameters:
rowIndex - the row index
Returns:
the data structure
Throws:
Exception - if encouting any database read error

updateRow

public void updateRow(int rowIndex,
                      Record record)
               throws Exception
Description copied from interface: CrudRowOperations
Update data of a designated row with data.

Specified by:
updateRow in interface CrudRowOperations
Parameters:
rowIndex - the row index
record - the data array
Throws:
Exception - if encouting any database update error

deleteRow

public void deleteRow(int rowIndex)
               throws Exception
Description copied from interface: CrudRowOperations
Delete data of a designated row.

Specified by:
deleteRow in interface CrudRowOperations
Parameters:
rowIndex - the row index
Throws:
Exception - if encouting any database update error.

createResultSetTableModel

protected ResultSetTableModel createResultSetTableModel(ResultSet resultSet,
                                                        int rowCount)
                                                 throws SQLException
Overrides:
createResultSetTableModel in class DatabaseTableModel
Throws:
SQLException

JIDE 3.5.15