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 booleanprotected booleanprotected intprotected CommonDataListprotected Listprotected Componentprotected ListFields inherited from class rma.swing.table.AbstractRmaTableModel
m_columnNames, m_displayUnitSystem, m_gmtOffset, m_unitSystemFields inherited from class javax.swing.table.AbstractTableModel
listenerListFields inherited from interface rma.swing.table.RmaTableModelInterface
UNDEF_COLUMN_PARAM_ID -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidadd a column to the table with the header colNamevoidadd a column to the table with header columnName and data ColumnDatavoidaddRow()protected voidvoidadd a row to the table with data in the Vector newRowvoidclearAll()remove all data from the tablevoidClears all of the edits by removing everything from the edit buffer.protected voidbooleancommitDataObject(DataObject dobj) Commits a particular object to the data list.voidcommitImmediatly(boolean ci) This allows for the model to commit whenever it gets a setValueAt() call from the table.booleanCommits all objects in the editing buffer.voiddeleteRow(int row) Deletes a row from the editing buffer.intfirstIndexOf(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) intThe method returns the number of columns in the table.getColumnName(int column) Returns a String array of column names.intgetColumnParameter(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 VectorintReturns the number of rows that are in the editing buffer.intreturns the unit system for this data.getValueAt(int rowIndex, int columnIndex) Returns the value for a particular row and column in the data model.voidinsert a row in the table at Row row with data rowDatabooleanisCellEditable(int rowIndex, int columnIndex) Returns true if the cell at rowIndex and columnIndex is editable.booleanisValidRecord(DataObject dobj) Tests to see if the data object is a valid.intlastIndexOf(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.voidsetColEnabled(boolean enabled, int col) the the Column col enabled or disabledvoidsetColumnClass(int col, Class cls) st the column col's class to be clsvoidsetColumnNames(String[] colNames) voidsetColumnNames(Vector colNames) voidsetColumnParameters(int[] params) voidAllows the user to set the parent table or any component that uses this model.voidsetRowEnabled(boolean enabled, int row) set the Row row enabled or disabledvoidsetValueAt(Object aValue, int rowIndex, int columnIndex) This does nothing.booleanuniqueNameInEditBuffer(String name) Methods inherited from class rma.swing.table.AbstractRmaTableModel
getDisplayUnitSystem, getGmtOffset, insertRows, resetRowEnabled, setDisplayUnitsSystem, setUnitSystemMethods 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, waitMethods inherited from interface rma.swing.table.RmaTableModelInterface
setCellEnabledMethods 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:
getColumnCountin interfaceTableModel- Overrides:
getColumnCountin 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:
getRowCountin interfaceTableModel- Overrides:
getRowCountin 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:
getValueAtin interfaceTableModel- Overrides:
getValueAtin classAbstractRmaTableModel- Parameters:
rowIndex-columnIndex-- Returns:
- NULL
-
setValueAt
This does nothing. Should be overridden to provide the correct implementation.- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin 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
-1if 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
-1if no object matches the search criteria.
-
getColumnName
Returns a String array of column names.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractRmaTableModel- Parameters:
column-
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin 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:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein 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:RmaTableModelInterfaceadd a column to the table with the header colName- Specified by:
addColumnin interfaceRmaTableModelInterface- Overrides:
addColumnin classAbstractRmaTableModel
-
addColumn
Description copied from interface:RmaTableModelInterfaceadd a column to the table with header columnName and data ColumnData- Specified by:
addColumnin interfaceRmaTableModelInterface- Overrides:
addColumnin classAbstractRmaTableModel
-
addRow
public void addRow() -
addRow
-
addRow
Description copied from interface:RmaTableModelInterfaceadd a row to the table with data in the Vector newRow- Specified by:
addRowin interfaceRmaTableModelInterface- Overrides:
addRowin classAbstractRmaTableModel
-
setColumnNames
- Specified by:
setColumnNamesin interfaceRmaTableModelInterface- Overrides:
setColumnNamesin classAbstractRmaTableModel
-
setColumnNames
- Specified by:
setColumnNamesin interfaceRmaTableModelInterface- Overrides:
setColumnNamesin classAbstractRmaTableModel
-
setColumnParameters
public void setColumnParameters(int[] params) - Specified by:
setColumnParametersin interfaceRmaTableModelInterface- Overrides:
setColumnParametersin classAbstractRmaTableModel
-
getColumnParameter
public int getColumnParameter(int col) Description copied from class:AbstractRmaTableModelReturns 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:
getColumnParameterin interfaceRmaTableModelInterface- Overrides:
getColumnParameterin 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:
getUnitSystemin interfaceRmaTableModelInterface- Overrides:
getUnitSystemin 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:
deleteRowin interfaceRmaTableModelInterface- Overrides:
deleteRowin classAbstractRmaTableModel- Parameters:
row-
-
setRowEnabled
public void setRowEnabled(boolean enabled, int row) Description copied from interface:RmaTableModelInterfaceset the Row row enabled or disabled- Specified by:
setRowEnabledin interfaceRmaTableModelInterface- Overrides:
setRowEnabledin classAbstractRmaTableModel
-
setColEnabled
public void setColEnabled(boolean enabled, int col) Description copied from interface:RmaTableModelInterfacethe the Column col enabled or disabled- Specified by:
setColEnabledin interfaceRmaTableModelInterface- Overrides:
setColEnabledin classAbstractRmaTableModel
-
setColumnClass
Description copied from interface:RmaTableModelInterfacest the column col's class to be cls- Specified by:
setColumnClassin interfaceRmaTableModelInterface- Overrides:
setColumnClassin classAbstractRmaTableModel
-
clearAll
public void clearAll()Description copied from interface:RmaTableModelInterfaceremove all data from the table- Specified by:
clearAllin interfaceRmaTableModelInterface- Overrides:
clearAllin classAbstractRmaTableModel
-
getRow
Description copied from interface:RmaTableModelInterfaceget the row of data at rowNum and return in a Vector- Specified by:
getRowin interfaceRmaTableModelInterface- Overrides:
getRowin classAbstractRmaTableModel
-
insertRow
Description copied from interface:RmaTableModelInterfaceinsert a row in the table at Row row with data rowData- Specified by:
insertRowin interfaceRmaTableModelInterface- Overrides:
insertRowin classAbstractRmaTableModel
-
getDataVector
Description copied from interface:RmaTableModelInterfacereturn the table data in a vector- Specified by:
getDataVectorin interfaceRmaTableModelInterface- Overrides:
getDataVectorin 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
-