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>>
cache
protected DataSourceItem
ds_item
java.util.ArrayList<java.lang.Integer>
filter
protected boolean
is_cached
protected boolean
is_new_record
protected boolean
is_thread_caching
boolean
isFiltered
protected DataRecordSet
recordSet
Fields 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 boolean
addNewRecord()
Adds a new record to the model and allows the user to enter input into it.boolean
applyFilter(java.util.ArrayList<? extends java.lang.Comparable> list, java.lang.String filter_field)
boolean
cancelUpdate()
Cancels the current updateboolean
deleteRows(int[] rows)
Attempts to delete the specified rows from the underlying data source itemprotected void
fillCache(int row)
protected void
fillCacheBlocking(int row, int start)
protected java.lang.Object
getCached(int row, int col)
java.lang.Class
getColumnClass(int col)
int
getColumnCount()
java.lang.String
getColumnName(int c)
boolean
getIsCached()
DataRecordSet
getRecordSet()
int
getRowCount()
java.lang.Object
getSource()
Returns the source of data for this table.java.lang.Object
getValueAt(int row, int col)
protected java.lang.Object
getValueFromRecordSetAt(int row, int col)
boolean
isCellEditable(int row, int col)
void
prefillCache()
void
removeFilter()
protected void
resetCache()
protected void
setCacheValue(java.lang.Object value, int row, int column)
void
setDataSourceItem(DataSourceItem item)
void
setIsCached(boolean b)
void
setProgressUpdater(ProgressUpdater updater)
void
setValueAt(java.lang.Object value, int row, int column)
boolean
updateRecordSet()
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, setTreeNode
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 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:InterfaceTableModel
Returns the source of data for this table.- Specified by:
getSource
in 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 untilupdateRecordSet
is 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.SQLException
DataSourceException
-
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:
setValueAt
in interfacejavax.swing.table.TableModel
- Overrides:
setValueAt
in 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:
getColumnName
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnName
in classjavax.swing.table.AbstractTableModel
-
getColumnClass
public java.lang.Class getColumnClass(int col)- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
- Overrides:
getColumnClass
in classjavax.swing.table.AbstractTableModel
-
isCellEditable
public boolean isCellEditable(int row, int col)- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
- Overrides:
isCellEditable
in 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:
-