|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.tree.DefaultMutableTreeNode
com.metamatrix.console.ui.tree.ChildSortingTreeNode
com.metamatrix.console.ui.util.LazyBranchNode
public abstract class LazyBranchNode
LazyBranchNode is a specialization of DefaultMutableTreeNode that delays populating its child nodes until it is expanded. To use, extend this class (typically as an inner class) and implement the populate method to obtain the child nodes, construct new LazyBranchNodes for each child branch and new DefaultMutableTreeNodes for each leaf, and call add(newChild) for each child node. Example:
class MyLazyNode extends LazyBranchNode { MyLazyNode(Object id) { super(id); } public void populate() { if ( ! isPopulated() ) { // will be true if add() has ever been called on this node Iterator iter = MyDataManager.getChildrenOfNode(id).iterator(); while ( iter.hasNext() ) { Object obj = iter.next(); if ( obj instanceof ALeafNodeClass ) { this.add( new DefaultMutableTreeNode(node) ); // leaf nodes } else { this.add( new ResourceNode(node) ); // branch nodes } } } } }
LazyBranchListener
,
Serialized FormField Summary | |
---|---|
protected java.lang.Object |
id
|
protected boolean |
populated
|
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode |
---|
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject |
Fields inherited from interface com.metamatrix.console.ui.tree.SortsChildren |
---|
ALPHABETIC_SORT, NO_SORT, NUMERIC_SORT |
Constructor Summary | |
---|---|
LazyBranchNode(javax.swing.tree.DefaultTreeModel treeModel,
java.lang.Object id)
|
Method Summary | |
---|---|
void |
add(javax.swing.tree.MutableTreeNode newChild)
|
boolean |
isLeaf()
|
boolean |
isPopulated()
|
abstract void |
populate()
|
void |
resetPopulated()
|
void |
setPopulated()
|
Methods inherited from class com.metamatrix.console.ui.tree.ChildSortingTreeNode |
---|
getModel, getSortType, insert, isUsingUserObjectToString, setModel, setSortType, setUsingUserObjectToString, sortChildren, sortTree |
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode |
---|
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, 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 |
---|
protected java.lang.Object id
protected boolean populated
Constructor Detail |
---|
public LazyBranchNode(javax.swing.tree.DefaultTreeModel treeModel, java.lang.Object id)
Method Detail |
---|
public void add(javax.swing.tree.MutableTreeNode newChild)
add
in class ChildSortingTreeNode
public boolean isLeaf()
isLeaf
in interface javax.swing.tree.TreeNode
isLeaf
in class javax.swing.tree.DefaultMutableTreeNode
public boolean isPopulated()
public void setPopulated()
public void resetPopulated()
public abstract void populate() throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |