org.formaria.swing.treetable
Class TreeTableModelNode

java.lang.Object
  extended by org.formaria.swing.treetable.AbstractTreeTableModel
      extended by org.formaria.swing.treetable.TreeTableModelNode
All Implemented Interfaces:
javax.swing.tree.TreeModel, TreeTableModel

public class TreeTableModelNode
extends AbstractTreeTableModel

A tree node wrapper for an DataModel node

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.8 $


Nested Class Summary
 class TreeTableModelNode.Node
          A Node is a derivative of the File class - though we delegate to the File object rather than subclassing it.
 
Field Summary
protected static TreeTableModelNode.Node[] EMPTY_CHILDREN
           
static java.lang.Integer ZERO
           
 
Fields inherited from class org.formaria.swing.treetable.AbstractTreeTableModel
listenerList, root
 
Constructor Summary
TreeTableModelNode()
          Creates a TreeTableModelNode rooted at File.separator, which is usually the root of the file system.
TreeTableModelNode(DataModel rootModel)
          Creates a TreeTableModelNode with the root being rootPath.
TreeTableModelNode(DataModel rootModel, javax.swing.table.TableModel aTableModel)
           
 
Method Summary
 java.lang.Object getChild(java.lang.Object node, int i)
          Returns the child of node at index i.
 int getChildCount(java.lang.Object node)
          Returns the number of children of node.
protected  java.lang.Object[] getChildren(java.lang.Object node)
           
 java.lang.Class getColumnClass(int column)
          Returns the class for the particular column.
 int getColumnCount()
          Return the number of columns.
 java.lang.String getColumnName(int columnIndex)
          Returns the name for a particular column.
protected  DataModel getModel(java.lang.Object node)
           
 java.lang.String getPath(java.lang.Object node)
          Returns the path node represents.
 java.lang.Object getValueAt(java.lang.Object node, int columnIndex)
          Returns the value of the particular column.
 boolean isCellEditable(java.lang.Object node, int columnIndex)
          By default, make the column with the Tree in it the only editable one.
 boolean isLeaf(java.lang.Object node)
          Returns true if the passed in object represents a leaf, false otherwise.
protected  void loadChildren(TreeTableModelNode.Node node)
           
 void nodeLoader(TreeTableModelNode.Node node)
           
 void reloadChildren(java.lang.Object node)
          Reloads the children of the specified node.
 void setValueAt(java.lang.Object value, java.lang.Object node, int columnIndex)
          Sets the value for node node, at column number column.
 
Methods inherited from class org.formaria.swing.treetable.AbstractTreeTableModel
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getRoot, removeTreeModelListener, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CHILDREN

protected static TreeTableModelNode.Node[] EMPTY_CHILDREN

ZERO

public static final java.lang.Integer ZERO
Constructor Detail

TreeTableModelNode

public TreeTableModelNode()
Creates a TreeTableModelNode rooted at File.separator, which is usually the root of the file system. This does not load it, you should invoke reloadChildren with the root to start loading.


TreeTableModelNode

public TreeTableModelNode(DataModel rootModel)
Creates a TreeTableModelNode with the root being rootPath. This does not load it, you should invoke reloadChildren with the root to start loading.


TreeTableModelNode

public TreeTableModelNode(DataModel rootModel,
                          javax.swing.table.TableModel aTableModel)
Method Detail

getChildCount

public int getChildCount(java.lang.Object node)
Returns the number of children of node.


getChild

public java.lang.Object getChild(java.lang.Object node,
                                 int i)
Returns the child of node at index i.


isLeaf

public boolean isLeaf(java.lang.Object node)
Returns true if the passed in object represents a leaf, false otherwise.

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Overrides:
isLeaf in class AbstractTreeTableModel

getColumnCount

public int getColumnCount()
Return the number of columns.


getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name for a particular column.


getColumnClass

public java.lang.Class getColumnClass(int column)
Returns the class for the particular column.

Specified by:
getColumnClass in interface TreeTableModel
Overrides:
getColumnClass in class AbstractTreeTableModel

getValueAt

public java.lang.Object getValueAt(java.lang.Object node,
                                   int columnIndex)
Returns the value of the particular column.


setValueAt

public void setValueAt(java.lang.Object value,
                       java.lang.Object node,
                       int columnIndex)
Description copied from interface: TreeTableModel
Sets the value for node node, at column number column.

Specified by:
setValueAt in interface TreeTableModel
Overrides:
setValueAt in class AbstractTreeTableModel

isCellEditable

public boolean isCellEditable(java.lang.Object node,
                              int columnIndex)
Description copied from class: AbstractTreeTableModel
By default, make the column with the Tree in it the only editable one. Making this column editable causes the JTable to forward mouse and keyboard events in the Tree column to the underlying JTree.

Specified by:
isCellEditable in interface TreeTableModel
Overrides:
isCellEditable in class AbstractTreeTableModel

reloadChildren

public void reloadChildren(java.lang.Object node)
Reloads the children of the specified node.

Specified by:
reloadChildren in class AbstractTreeTableModel
Parameters:
level - the depth of the tree

getPath

public java.lang.String getPath(java.lang.Object node)
Returns the path node represents.


getModel

protected DataModel getModel(java.lang.Object node)

getChildren

protected java.lang.Object[] getChildren(java.lang.Object node)

nodeLoader

public void nodeLoader(TreeTableModelNode.Node node)

loadChildren

protected void loadChildren(TreeTableModelNode.Node node)