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.ObjectgetChild(java.lang.Object node, int i)TreeModel method to locate a particular child of the specified node.intgetChildCount(java.lang.Object node)TreeModel method to return the number of children of a particular node.java.lang.ClassgetColumnClass(int column)Returns the column class for columncolumn.intgetColumnCount()Returns the number of column names passed into the constructor.java.lang.StringgetColumnName(int column)Returns the column name passed into the constructor.java.lang.ObjectgetValueAt(java.lang.Object node, int column)Returns the value for the columncolumnand objectnode.booleanisCellEditable(java.lang.Object node, int column)Returns true if there is a setter method name for columncolumn.booleanisLeaf(java.lang.Object node)TreeModel method to determine if a node is a leaf.voidsetValueAt(java.lang.Object aValue, java.lang.Object node, int column)Sets the value toaValuefor the objectnodein 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. Sincenodeis 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. Sincenodeis 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. Sincenodeis a TreeNode, this can be answered via the TreeNode methodisLeaf.- Specified by:
isLeafin interfacejavax.swing.tree.TreeModel- Overrides:
isLeafin 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:
getColumnClassin interfaceTreeTableModel- Overrides:
getColumnClassin classAbstractTreeTableModel
-
getValueAt
public java.lang.Object getValueAt(java.lang.Object node, int column)Returns the value for the columncolumnand 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:
isCellEditablein interfaceTreeTableModel- Overrides:
isCellEditablein classAbstractTreeTableModel
-
setValueAt
public void setValueAt(java.lang.Object aValue, java.lang.Object node, int column)Sets the value toaValuefor the objectnodein columncolumn. This is done by using the setter method name, and coercing the passed in value to the specified type.- Specified by:
setValueAtin interfaceTreeTableModel- Overrides:
setValueAtin classAbstractTreeTableModel
-
-