Package jadex.commons.gui.jtreetable
Class DynamicTreeTableModel
- java.lang.Object
-
- jadex.commons.gui.jtreetable.AbstractTreeTableModel
-
- jadex.commons.gui.jtreetable.DynamicTreeTableModel
-
- All Implemented Interfaces:
TreeTableModel
,javax.swing.tree.TreeModel
public class DynamicTreeTableModel extends AbstractTreeTableModel
An implementation of TreeTableModel that uses reflection to answer TableModel methods. This works off a handful of values. A TreeNode is used to answer all the TreeModel related methods (similiar to AbstractTreeTableModel and DefaultTreeModel). The column names are specified in the constructor. The values for the columns are dynamically obtained via reflection, you simply provide the method names. The methods used to set a particular value are also specified as an array of method names, a null method name, or null array indicates the column isn't editable. And the class types, used for the TableModel method getColumnClass are specified in the constructor.
-
-
Field Summary
-
Fields inherited from class jadex.commons.gui.jtreetable.AbstractTreeTableModel
listenerList, root
-
-
Constructor Summary
Constructors Constructor Description DynamicTreeTableModel(javax.swing.tree.TreeNode root, java.lang.String[] columnNames, java.lang.String[] getterMethodNames, java.lang.String[] setterMethodNames, java.lang.Class[] cTypes)
Constructor for creating a DynamicTreeTableModel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getChild(java.lang.Object node, int i)
TreeModel method to locate a particular child of the specified node.int
getChildCount(java.lang.Object node)
TreeModel method to return the number of children of a particular node.java.lang.Class
getColumnClass(int column)
Returns the column class for columncolumn
.int
getColumnCount()
Returns the number of column names passed into the constructor.java.lang.String
getColumnName(int column)
Returns the column name passed into the constructor.java.lang.Object
getValueAt(java.lang.Object node, int column)
Returns the value for the columncolumn
and objectnode
.boolean
isCellEditable(java.lang.Object node, int column)
Returns true if there is a setter method name for columncolumn
.boolean
isLeaf(java.lang.Object node)
TreeModel method to determine if a node is a leaf.void
setValueAt(java.lang.Object aValue, java.lang.Object node, int column)
Sets the value toaValue
for the objectnode
in columncolumn
.-
Methods inherited from class jadex.commons.gui.jtreetable.AbstractTreeTableModel
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getPathToRoot, getPathToRoot, getRoot, reload, removeTreeModelListener, valueForPathChanged
-
-
-
-
Method Detail
-
getChildCount
public int getChildCount(java.lang.Object node)
TreeModel method to return the number of children of a particular node. Sincenode
is a TreeNode, this can be answered via the TreeNode methodgetChildCount
.
-
getChild
public java.lang.Object getChild(java.lang.Object node, int i)
TreeModel method to locate a particular child of the specified node. Sincenode
is a TreeNode, this can be answered via the TreeNode methodgetChild
.
-
isLeaf
public boolean isLeaf(java.lang.Object node)
TreeModel method to determine if a node is a leaf. Sincenode
is a TreeNode, this can be answered via the TreeNode methodisLeaf
.- Specified by:
isLeaf
in interfacejavax.swing.tree.TreeModel
- Overrides:
isLeaf
in classAbstractTreeTableModel
-
getColumnCount
public int getColumnCount()
Returns the number of column names passed into the constructor.
-
getColumnName
public java.lang.String getColumnName(int column)
Returns the column name passed into the constructor.
-
getColumnClass
public java.lang.Class getColumnClass(int column)
Returns the column class for columncolumn
. This is set in the constructor.- Specified by:
getColumnClass
in interfaceTreeTableModel
- Overrides:
getColumnClass
in classAbstractTreeTableModel
-
getValueAt
public java.lang.Object getValueAt(java.lang.Object node, int column)
Returns the value for the columncolumn
and objectnode
. The return value is determined by invoking the method specified in constructor for the passed in column.
-
isCellEditable
public boolean isCellEditable(java.lang.Object node, int column)
Returns true if there is a setter method name for columncolumn
. This is set in the constructor.- Specified by:
isCellEditable
in interfaceTreeTableModel
- Overrides:
isCellEditable
in classAbstractTreeTableModel
-
setValueAt
public void setValueAt(java.lang.Object aValue, java.lang.Object node, int column)
Sets the value toaValue
for the objectnode
in columncolumn
. This is done by using the setter method name, and coercing the passed in value to the specified type.- Specified by:
setValueAt
in interfaceTreeTableModel
- Overrides:
setValueAt
in classAbstractTreeTableModel
-
-