org.formaria.swing.tree
Class TreeModelAdapter

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by org.formaria.swing.tree.TreeModelAdapter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode, ModelAdapter
Direct Known Subclasses:
TreePojoModelAdapter

public class TreeModelAdapter
extends javax.swing.tree.DefaultMutableTreeNode
implements ModelAdapter

An adapter to allow the DataModel to be used with tree controls

Copyright (c) Formaria Ltd., 2008

See Also:
Serialized Form

Field Summary
protected  DataModel model
          The model node
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
TreeModelAdapter()
          Constructs a new adapter
 
Method Summary
 java.lang.Object get(int i)
          Gets the individual list item value
 DataModel getDataModel()
          Get the model being used by this adapter
 int getNumChildren()
          Get the number of children belong to the model node that this object adapts
 java.lang.Object getSelected()
          Gets the value of the selected item from the list.
 java.lang.String getTagName()
          Gets the name of the model node
protected  void populateTreeModel(DataModel src)
          Add the children of this node to the tree model
 void set(java.lang.Object o)
          Set the value of the listitem
 void setDataModel(DataModel src)
          Set the adapter source
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

model

protected DataModel model
The model node

Constructor Detail

TreeModelAdapter

public TreeModelAdapter()
Constructs a new adapter

Method Detail

getNumChildren

public int getNumChildren()
Get the number of children belong to the model node that this object adapts

Specified by:
getNumChildren in interface ModelAdapter
Returns:
the number of children

get

public java.lang.Object get(int i)
Gets the individual list item value

Specified by:
get in interface ModelAdapter
Parameters:
i - The index of the listitem
Returns:
The value of the listitem

set

public void set(java.lang.Object o)
Set the value of the listitem

Specified by:
set in interface ModelAdapter
Parameters:
o - The new value

getSelected

public java.lang.Object getSelected()
Gets the value of the selected item from the list.

Specified by:
getSelected in interface ModelAdapter
Returns:
the selected list item/node

setDataModel

public void setDataModel(DataModel src)
Set the adapter source

Specified by:
setDataModel in interface ModelAdapter
Parameters:
src - the model

getDataModel

public DataModel getDataModel()
Get the model being used by this adapter

Specified by:
getDataModel in interface ModelAdapter
Returns:
the model node

getTagName

public java.lang.String getTagName()
Gets the name of the model node

Returns:
the name

populateTreeModel

protected void populateTreeModel(DataModel src)
Add the children of this node to the tree model

Parameters:
src - the source model node