|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tbee.swing.table.TableModelValueWrapper
public class TableModelValueWrapper
This class adds ValueWrapper support to a TableModel. The reason behind this is that there are situations where you want to work with describing objects. For example a JComboBox could want the following behaviour: - the actual value stored could be an integer - but the displayed value should be a text If Integer were not a final class, one could extend that class and add a description plus change the toString method. But alas, Integer is final. So the actual value needs to be wrapped in a class that adds the description. However the model's getValueAt and setValueAt want Integers and not the wrapping classes, so somewhere there has to be a conversion from and to the wrapper. In order to achief this, setValueAt and getValueAt in this class have been extended: - if setValueAt encounters (an instance of) the ValueWrapper, it will continue with the contained value. - if getValueAt gets the value for a column that has a ValueWrapperFactory set, it will wrap the value. (The factory is registered for a column via the setValueWrapper method.) In the JComboBox example, the combobox will work completely with ValueWrapper objects and thus showing the description. This class will unwrap the ValueWrapper to the actual values. You may of course extend ValueWrapper and alter its behaviour (it could have been an interface).
| Nested Class Summary | |
|---|---|
static class |
TableModelValueWrapper.ValueWrapper
This a special class to enable indirect renderers and editors like ComboBoxes. |
static interface |
TableModelValueWrapper.ValueWrapperFactory
The interface a ValueWrapper factory should implement |
| Field Summary | |
|---|---|
static String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Constructor Summary | |
|---|---|
TableModelValueWrapper(TableModelForEdit model)
|
|
| Method Summary | |
|---|---|
int |
addRowAt(int rowIndex)
|
void |
addTableModelListener(TableModelListener l)
|
void |
deleteRowAt(int rowIndex)
|
Class |
getColumnClass(int columnIndex)
If we return wrappers, we return wrappers (this is important for the TableSorter) |
int |
getColumnCount()
|
String |
getColumnName(int columnIndex)
|
String |
getErrorMessageAt(int row,
int col)
|
int |
getRowCount()
|
Object |
getValueAt(int row,
int column)
Returns the cell value at row and column. |
TableModelValueWrapper.ValueWrapperFactory |
getValueWrapper(int columnIdx)
Registration of the ValueWrapper factories |
String |
getWarnMessageAt(int row,
int col)
|
boolean |
isCellEditable(int rowIndex,
int columnIndex)
|
void |
removeTableModelListener(TableModelListener l)
|
void |
setValueAt(Object aValue,
int row,
int column)
Sets the value for the cell in the table model at row
and column. |
void |
setValueWrapper(int columnIdx,
TableModelValueWrapper.ValueWrapperFactory factory)
Registration of the ValueWrapper factories |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SOURCECODE_VERSION
| Constructor Detail |
|---|
public TableModelValueWrapper(TableModelForEdit model)
| Method Detail |
|---|
public Class getColumnClass(int columnIndex)
getColumnClass in interface TableModel
public Object getValueAt(int row,
int column)
row and column.
If for this column a ValueWrapperFactory is set, the value is wrapped and then returned.
getValueAt in interface TableModelrow - the row whose value is to be queriedcolumn - the column whose value is to be queried
public void setValueAt(Object aValue,
int row,
int column)
row
and column.
If the value is a ValueWrapper, then the wrapper value is written to the model.
setValueAt in interface TableModelaValue - the new valuerow - the row of the cell to be changedcolumn - the column of the cell to be changedgetValueAt(int, int)
public void setValueWrapper(int columnIdx,
TableModelValueWrapper.ValueWrapperFactory factory)
columnIdx - factory - public TableModelValueWrapper.ValueWrapperFactory getValueWrapper(int columnIdx)
columnIdx -
public int addRowAt(int rowIndex)
addRowAt in interface TableModelForEditpublic void addTableModelListener(TableModelListener l)
addTableModelListener in interface TableModelpublic void deleteRowAt(int rowIndex)
deleteRowAt in interface TableModelForEditpublic int getColumnCount()
getColumnCount in interface TableModelpublic String getColumnName(int columnIndex)
getColumnName in interface TableModel
public String getErrorMessageAt(int row,
int col)
getErrorMessageAt in interface TableModelForEdit
public String getWarnMessageAt(int row,
int col)
getWarnMessageAt in interface TableModelForEditpublic int getRowCount()
getRowCount in interface TableModel
public boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface TableModelpublic void removeTableModelListener(TableModelListener l)
removeTableModelListener in interface TableModel
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||