|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
com.wordpress.tipsforjava.swing.table.RowTableModel
com.wordpress.tipsforjava.swing.table.BeanTableModel
public class BeanTableModel extends RowTableModel
The BeanTableModel will use reflection to determine the columns of data to be displayed in the table model. Reflection is used to find all the methods declared in the specified bean. The criteria used for adding columns to the model are: a) the method name must start with either "get" or "is" b) the parameter list for the method must contain 0 parameters You can also specify an ancestor class in which case the declared methods of the ancestor and all its descendents will be included in the model. A column name will be assigned to each column based on the method name. The cell will be considered editable when a corresponding "set" method name is found. Reflection will also be used to implement the getValueAt() and setValueAt() methods.
| Nested Class Summary | |
|---|---|
private class |
BeanTableModel.ColumnInformation
|
| Field Summary | |
|---|---|
private Class |
ancestorClass
|
private Class |
beanClass
|
private List |
columns
|
private static Map |
primitives
|
| Fields inherited from class RowTableModel | |
|---|---|
| columnClasses, columnNames, isColumnEditable, isModelEditable, modelData, rowClass |
| Constructor Summary | |
BeanTableModel(Class beanClass)
Constructs an empty |
|
BeanTableModel(Class beanClass, Class ancestorClass)
Constructs an empty |
|
BeanTableModel(Class beanClass, List modelData)
Constructs an empty |
|
BeanTableModel(Class beanClass, Class ancestorClass, List modelData)
Constructs an empty |
|
| Method Summary | |
|---|---|
private void
|
buildColumnInformation(Method theMethod, String theMethodName)
|
private void
|
createColumnInformation()
|
private Class
|
getReturnType(Method theMethod)
|
Object
|
getValueAt(int row, int column)
Returns an attribute value for the cell at |
private void
|
resetModelDefaults()
|
void
|
setColumnClass(int column, Class columnClass)
You are not allowed to change the class of any column. |
void
|
setColumnEditable(int column, boolean isEditable)
Sets the editability for the specified column. |
void
|
setColumnName(int column, String name)
Convenience method to change the generated column header name. |
void
|
setValueAt(Object value, int row, int column)
Sets the object value for the cell at |
void
|
sortColumnNames()
|
| Methods inherited from class RowTableModel | |
|---|---|
| addRow, formatColumnName, getColumnClass, getColumnCount, getColumnName, getRow, getRowCount, getRowsAsArray, getRowsAsList, insertRow, insertRows, insertRows, isCellEditable, moveRow, removeRowRange, removeRows, replaceRow, setColumnClass, setColumnEditable, setDataAndColumnNames, setModelEditable, setRowClass |
| Field Detail |
|---|
private Class ancestorClass
private Class beanClass
private List columns
private static Map primitives
| Constructor Detail |
|---|
public BeanTableModel(Class beanClass)
BeanTableModel for the specified bean.
beanClass - class of the beans that will be added to the model.
The class is also used to determine the columns that
will be displayed in the model
public BeanTableModel(Class beanClass, Class ancestorClass)
BeanTableModel for the specified bean.
beanClass - class of the beans that will be added to the model.ancestorClass - the methods of this class and its descendents down
to the bean class can be included in the model.
public BeanTableModel(Class beanClass, List modelData)
BeanTableModel for the specified bean.
beanClass - class of the beans that will be added to the model.modelData - the data of the table
public BeanTableModel(Class beanClass, Class ancestorClass, List modelData)
BeanTableModel for the specified bean.
beanClass - class of the beans that will be added to the model.ancestorClass - the methods of this class and its descendents down
to the bean class can be included in the model.modelData - the data of the table
| Method Detail |
|---|
ssWarnings("unchecked")
private
private void buildColumnInformation(Method theMethod, String theMethodName)
ssWarnings("unchecked")
private
private void createColumnInformation()
private Class getReturnType(Method theMethod)
de public public Object getValueAt(int row, int column)
row
and column.
row - the row whose value is to be queriedcolumn - the column whose value is to be queried
private void resetModelDefaults()
de public public void setColumnClass(int column, Class columnClass)
de public public void setColumnEditable(int column, boolean isEditable)
column - the column whose Class is being changedisEditable - indicates if the column is editable or not
public void setColumnName(int column, String name)
column - the column whose value is to be queried
de public public void setValueAt(Object value, int row, int column)
column and
row. value is the new value. This method
will generate a tableChanged notification.
value - the new value; this can be nullrow - the row whose value is to be changedcolumn - the column whose value is to be changed
public void sortColumnNames()
Groovy Documentation