Package hec.model
Class AbstractDataListTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
rma.swing.table.AbstractRmaTableModel
hec.model.AbstractDataListTableModel
- All Implemented Interfaces:
Serializable
,TableModel
,RmaTableModelInterface
The AbstractDataListTable model provied a default implementation to display and edit a data list in a RmaJTable/JTable.
The model wraps around a datalist object. When a cell is rendered by the table, the model gets a data object from the
data list and places it into a editing buffer. The contents of the buffer is not saved until the programmer calls the
commit method on the model. Blank rows are displayed by DataObjects with no names. Changes to the table are as follows,
(1) If the name is blank and the id is undefined, it must be a blank row.
(2) If the name is filled and the id is undefined, it is a new object
(3) If the name is filled and the id is defined, it is an update.
- Since:
- 1 February 2001
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
protected int
protected CommonDataList
protected List
protected Component
protected List
Fields inherited from class rma.swing.table.AbstractRmaTableModel
m_columnNames, m_displayUnitSystem, m_gmtOffset, m_unitSystem
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
Fields inherited from interface rma.swing.table.RmaTableModelInterface
UNDEF_COLUMN_PARAM_ID
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoid
add a column to the table with the header colNamevoid
add a column to the table with header columnName and data ColumnDatavoid
addRow()
protected void
void
add a row to the table with data in the Vector newRowvoid
clearAll()
remove all data from the tablevoid
Clears all of the edits by removing everything from the edit buffer.protected void
boolean
commitDataObject
(DataObject dobj) Commits a particular object to the data list.void
commitImmediatly
(boolean ci) This allows for the model to commit whenever it gets a setValueAt() call from the table.boolean
Commits all objects in the editing buffer.void
deleteRow
(int row) Deletes a row from the editing buffer.int
firstIndexOf
(String match, int index, boolean wrap, boolean wholeWord, boolean caseSensitive) Returns the index of an object in this list using a string match.getColumnClass
(int columnIndex) int
The method returns the number of columns in the table.getColumnName
(int column) Returns a String array of column names.int
getColumnParameter
(int col) Returns the parameter for a given column.return the table data in a vectorgetRow
(int row) get the row of data at rowNum and return in a Vectorint
Returns the number of rows that are in the editing buffer.int
returns the unit system for this data.getValueAt
(int rowIndex, int columnIndex) Returns the value for a particular row and column in the data model.void
insert a row in the table at Row row with data rowDataboolean
isCellEditable
(int rowIndex, int columnIndex) Returns true if the cell at rowIndex and columnIndex is editable.boolean
isValidRecord
(DataObject dobj) Tests to see if the data object is a valid.int
lastIndexOf
(String match, int index, boolean wholeWord, boolean caseSensitive) Iterating from rear to front, returns the first occurance of an object in this list using a string match.void
setColEnabled
(boolean enabled, int col) the the Column col enabled or disabledvoid
setColumnClass
(int col, Class cls) st the column col's class to be clsvoid
setColumnNames
(String[] colNames) void
setColumnNames
(Vector colNames) void
setColumnParameters
(int[] params) void
Allows the user to set the parent table or any component that uses this model.void
setRowEnabled
(boolean enabled, int row) set the Row row enabled or disabledvoid
setValueAt
(Object aValue, int rowIndex, int columnIndex) This does nothing.boolean
uniqueNameInEditBuffer
(String name) Methods inherited from class rma.swing.table.AbstractRmaTableModel
getDisplayUnitSystem, getGmtOffset, insertRows, resetRowEnabled, setDisplayUnitsSystem, setUnitSystem
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 rma.swing.table.RmaTableModelInterface
setCellEnabled
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
-
Field Details
-
_committingTable
protected boolean _committingTable -
m_dataList
-
m_objects
-
m_tempObjects
-
m_commitImmediatly
protected boolean m_commitImmediatly -
m_parentComponent
-
m_currentEditRow
protected int m_currentEditRow
-
-
Constructor Details
-
AbstractDataListTableModel
public AbstractDataListTableModel() -
AbstractDataListTableModel
-
AbstractDataListTableModel
-
-
Method Details
-
getColumnCount
public int getColumnCount()The method returns the number of columns in the table. This is defines by the values in the column names array (m_columnNames)- Specified by:
getColumnCount
in interfaceTableModel
- Overrides:
getColumnCount
in classAbstractRmaTableModel
-
getRowCount
public int getRowCount()Returns the number of rows that are in the editing buffer. If an object has not been rendered, it is represented by a NULL value in the buffer. This is included in the row count.- Specified by:
getRowCount
in interfaceTableModel
- Overrides:
getRowCount
in classAbstractRmaTableModel
- Returns:
- the row count.
-
getValueAt
Returns the value for a particular row and column in the data model. The default implementation returns NULL. This method showl be overridden- Specified by:
getValueAt
in interfaceTableModel
- Overrides:
getValueAt
in classAbstractRmaTableModel
- Parameters:
rowIndex
-columnIndex
-- Returns:
- NULL
-
setValueAt
This does nothing. Should be overridden to provide the correct implementation.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractRmaTableModel
- Parameters:
aValue
-rowIndex
-columnIndex
-
-
firstIndexOf
public int firstIndexOf(String match, int index, boolean wrap, boolean wholeWord, boolean caseSensitive) Returns the index of an object in this list using a string match.- Parameters:
match
- The string to match.index
- The index to start the search at.wrap
- When the end of the model is reached do we wrap to the front?wholeWord
- Whether to match only whole words or not.caseSensitive
- Is the match case sensitive?- Returns:
- the index of the first object that matches the search
criteria; returns
-1
if no object matches the search criteria.
-
lastIndexOf
Iterating from rear to front, returns the first occurance of an object in this list using a string match.- Parameters:
match
- The string to match.index
- The index to start the search at.wholeWord
- Whether to match only whole words or not.caseSensitive
- Is the match case sensitive?- Returns:
- the index of the last object that matches the search
criteria; returns
-1
if no object matches the search criteria.
-
getColumnName
Returns a String array of column names.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractRmaTableModel
- Parameters:
column
-
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractRmaTableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractRmaTableModel
- Parameters:
rowIndex
- the row whose value is to be looked upcolumnIndex
- the column whose value is to be looked up- Returns:
- true if the cell is editable.
- See Also:
-
addColumn
Description copied from interface:RmaTableModelInterface
add a column to the table with the header colName- Specified by:
addColumn
in interfaceRmaTableModelInterface
- Overrides:
addColumn
in classAbstractRmaTableModel
-
addColumn
Description copied from interface:RmaTableModelInterface
add a column to the table with header columnName and data ColumnData- Specified by:
addColumn
in interfaceRmaTableModelInterface
- Overrides:
addColumn
in classAbstractRmaTableModel
-
addRow
public void addRow() -
addRow
-
addRow
Description copied from interface:RmaTableModelInterface
add a row to the table with data in the Vector newRow- Specified by:
addRow
in interfaceRmaTableModelInterface
- Overrides:
addRow
in classAbstractRmaTableModel
-
setColumnNames
- Specified by:
setColumnNames
in interfaceRmaTableModelInterface
- Overrides:
setColumnNames
in classAbstractRmaTableModel
-
setColumnNames
- Specified by:
setColumnNames
in interfaceRmaTableModelInterface
- Overrides:
setColumnNames
in classAbstractRmaTableModel
-
setColumnParameters
public void setColumnParameters(int[] params) - Specified by:
setColumnParameters
in interfaceRmaTableModelInterface
- Overrides:
setColumnParameters
in classAbstractRmaTableModel
-
getColumnParameter
public int getColumnParameter(int col) Description copied from class:AbstractRmaTableModel
Returns the parameter for a given column. If no parameter is defined -1 is returned. The parameter ID returned can be decoded with the hec.data.Parameter class.- Specified by:
getColumnParameter
in interfaceRmaTableModelInterface
- Overrides:
getColumnParameter
in classAbstractRmaTableModel
-
getUnitSystem
public int getUnitSystem()returns the unit system for this data. The value is retrieved from the DataList which this object is wrapped around- Specified by:
getUnitSystem
in interfaceRmaTableModelInterface
- Overrides:
getUnitSystem
in classAbstractRmaTableModel
-
deleteRow
public void deleteRow(int row) Deletes a row from the editing buffer. If an object exists in the buffer it is deleted from the datalist. This method is called from the table, so the buffer should not have a null value because it should have been rendered- Specified by:
deleteRow
in interfaceRmaTableModelInterface
- Overrides:
deleteRow
in classAbstractRmaTableModel
- Parameters:
row
-
-
setRowEnabled
public void setRowEnabled(boolean enabled, int row) Description copied from interface:RmaTableModelInterface
set the Row row enabled or disabled- Specified by:
setRowEnabled
in interfaceRmaTableModelInterface
- Overrides:
setRowEnabled
in classAbstractRmaTableModel
-
setColEnabled
public void setColEnabled(boolean enabled, int col) Description copied from interface:RmaTableModelInterface
the the Column col enabled or disabled- Specified by:
setColEnabled
in interfaceRmaTableModelInterface
- Overrides:
setColEnabled
in classAbstractRmaTableModel
-
setColumnClass
Description copied from interface:RmaTableModelInterface
st the column col's class to be cls- Specified by:
setColumnClass
in interfaceRmaTableModelInterface
- Overrides:
setColumnClass
in classAbstractRmaTableModel
-
clearAll
public void clearAll()Description copied from interface:RmaTableModelInterface
remove all data from the table- Specified by:
clearAll
in interfaceRmaTableModelInterface
- Overrides:
clearAll
in classAbstractRmaTableModel
-
getRow
Description copied from interface:RmaTableModelInterface
get the row of data at rowNum and return in a Vector- Specified by:
getRow
in interfaceRmaTableModelInterface
- Overrides:
getRow
in classAbstractRmaTableModel
-
insertRow
Description copied from interface:RmaTableModelInterface
insert a row in the table at Row row with data rowData- Specified by:
insertRow
in interfaceRmaTableModelInterface
- Overrides:
insertRow
in classAbstractRmaTableModel
-
getDataVector
Description copied from interface:RmaTableModelInterface
return the table data in a vector- Specified by:
getDataVector
in interfaceRmaTableModelInterface
- Overrides:
getDataVector
in classAbstractRmaTableModel
-
commitImmediatly
public void commitImmediatly(boolean ci) This allows for the model to commit whenever it gets a setValueAt() call from the table. The particular implementation of the commit is left to the sub-class.- Parameters:
ci
-
-
commitTable
public boolean commitTable()Commits all objects in the editing buffer. If the object has a non-blank name but no ID it is added to the datalist. If it has a non-blank name and a valid id the object is updated. -
commitDataObject
Commits a particular object to the data list.- Parameters:
dobj
-
-
setParentComponent
Allows the user to set the parent table or any component that uses this model. It is used for displaying messages to the user to get information about transaction rules. -
uniqueNameInEditBuffer
-
isValidRecord
Tests to see if the data object is a valid. This method will return false if the object is either null, or its ID is undefined and its name is equal to "". Returns true if it is, other wise false. -
clearEdits
public void clearEdits()Clears all of the edits by removing everything from the edit buffer. -
clearList
-