Package mgui.interfaces.datasources
Class DataTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
mgui.interfaces.tables.InterfaceTableModel
mgui.interfaces.datasources.DataTableModel
- All Implemented Interfaces:
java.io.Serializable,javax.swing.table.TableModel,AttributeObject,InterfaceObject,NamedObject,TreeObject,CleanableObject
public class DataTableModel extends InterfaceTableModel
Class extending AbstractTableModel to act as a model for JTable, and in particular
for use by InterfaceDataTable. Thus acts as a bridge between a DataRecordSet and an
InterfaceDataTable object.
TODO: Allow table sort only if cached; otherwise use DB sort
TODO: Sort table (not query) columns alpha-numerically
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<java.util.ArrayList<java.lang.Object>>cacheprotected DataSourceItemds_itemjava.util.ArrayList<java.lang.Integer>filterprotected booleanis_cachedprotected booleanis_new_recordprotected booleanis_thread_cachingbooleanisFilteredprotected DataRecordSetrecordSetFields inherited from class javax.swing.table.AbstractTableModel
listenerList -
Constructor Summary
Constructors Constructor Description DataTableModel()DataTableModel(DataRecordSet r)DataTableModel(DataSourceItem item)DataTableModel(DataSource ds, DataSourceItem item) -
Method Summary
Modifier and Type Method Description booleanaddNewRecord()Adds a new record to the model and allows the user to enter input into it.booleanapplyFilter(java.util.ArrayList<? extends java.lang.Comparable> list, java.lang.String filter_field)booleancancelUpdate()Cancels the current updatebooleandeleteRows(int[] rows)Attempts to delete the specified rows from the underlying data source itemprotected voidfillCache(int row)protected voidfillCacheBlocking(int row, int start)protected java.lang.ObjectgetCached(int row, int col)java.lang.ClassgetColumnClass(int col)intgetColumnCount()java.lang.StringgetColumnName(int c)booleangetIsCached()DataRecordSetgetRecordSet()intgetRowCount()java.lang.ObjectgetSource()Returns the source of data for this table.java.lang.ObjectgetValueAt(int row, int col)protected java.lang.ObjectgetValueFromRecordSetAt(int row, int col)booleanisCellEditable(int row, int col)voidprefillCache()voidremoveFilter()protected voidresetCache()protected voidsetCacheValue(java.lang.Object value, int row, int column)voidsetDataSourceItem(DataSourceItem item)voidsetIsCached(boolean b)voidsetProgressUpdater(ProgressUpdater updater)voidsetValueAt(java.lang.Object value, int row, int column)booleanupdateRecordSet()Instructs the record set to update its valuesMethods inherited from class mgui.interfaces.tables.InterfaceTableModel
_init, clean, destroy, getAttribute, getAttributes, getAttributeValue, getName, getTreeLabel, isDestroyed, issueTreeNode, setAttribute, setAttributes, setName, setTreeNodeMethods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
ds_item
-
recordSet
-
isFiltered
public boolean isFiltered -
filter
public java.util.ArrayList<java.lang.Integer> filter -
is_cached
protected boolean is_cached -
cache
protected volatile java.util.ArrayList<java.util.ArrayList<java.lang.Object>> cache -
is_thread_caching
protected volatile boolean is_thread_caching -
is_new_record
protected boolean is_new_record
-
-
Constructor Details
-
DataTableModel
public DataTableModel() -
DataTableModel
- Throws:
DataSourceException
-
DataTableModel
- Throws:
DataSourceException
-
DataTableModel
-
-
Method Details
-
getRecordSet
-
getSource
public java.lang.Object getSource()Description copied from class:InterfaceTableModelReturns the source of data for this table.- Specified by:
getSourcein classInterfaceTableModel- Returns:
-
setDataSourceItem
- Throws:
DataSourceException
-
setProgressUpdater
-
applyFilter
public boolean applyFilter(java.util.ArrayList<? extends java.lang.Comparable> list, java.lang.String filter_field) throws DataSourceException- Throws:
DataSourceException
-
addNewRecord
public boolean addNewRecord()Adds a new record to the model and allows the user to enter input into it. The record is not actually appended to the data source untilupdateRecordSetis called. -
updateRecordSet
public boolean updateRecordSet()Instructs the record set to update its values- Returns:
-
cancelUpdate
public boolean cancelUpdate()Cancels the current update- Returns:
-
removeFilter
public void removeFilter() -
setIsCached
public void setIsCached(boolean b) -
getIsCached
public boolean getIsCached() -
resetCache
protected void resetCache() -
getColumnCount
public int getColumnCount() -
getRowCount
public int getRowCount() -
fillCache
- Throws:
DataSourceException
-
fillCacheBlocking
- Throws:
DataSourceException
-
getCached
protected java.lang.Object getCached(int row, int col) throws java.sql.SQLException, DataSourceException- Throws:
java.sql.SQLExceptionDataSourceException
-
prefillCache
- Throws:
DataSourceException
-
getValueAt
public java.lang.Object getValueAt(int row, int col) -
getValueFromRecordSetAt
protected java.lang.Object getValueFromRecordSetAt(int row, int col) -
setValueAt
public void setValueAt(java.lang.Object value, int row, int column)- Specified by:
setValueAtin interfacejavax.swing.table.TableModel- Overrides:
setValueAtin classjavax.swing.table.AbstractTableModel
-
setCacheValue
protected void setCacheValue(java.lang.Object value, int row, int column) -
getColumnName
public java.lang.String getColumnName(int c)- Specified by:
getColumnNamein interfacejavax.swing.table.TableModel- Overrides:
getColumnNamein classjavax.swing.table.AbstractTableModel
-
getColumnClass
public java.lang.Class getColumnClass(int col)- Specified by:
getColumnClassin interfacejavax.swing.table.TableModel- Overrides:
getColumnClassin classjavax.swing.table.AbstractTableModel
-
isCellEditable
public boolean isCellEditable(int row, int col)- Specified by:
isCellEditablein interfacejavax.swing.table.TableModel- Overrides:
isCellEditablein classjavax.swing.table.AbstractTableModel
-
deleteRows
public boolean deleteRows(int[] rows)Attempts to delete the specified rows from the underlying data source item- Parameters:
rows-- Returns:
-