org.gerhardb.lib.filetree
Class DirectoryTreeNode

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended byorg.gerhardb.lib.filetree.DirectoryTreeNode
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode

public class DirectoryTreeNode
extends javax.swing.tree.DefaultMutableTreeNode

A directory node designed to count its files and populate all of its sub-directories.

The sub-directory population occurs in a depth-first fashion. Specifically, for a given root, its children are identified and files counted. Then the same recursively occurs for each sub-directory of the root.

This allows the highest level directory to be displayed immediately while other directories are populating. If a user chooses an unpopulated sub-directory, then that sub-directory is immediately populated, but its children are not recursed until the normal time.

Hence this can have serveral states:
UNPOPULATED - no population has beguon. POPULATING - counting the files and subdirectories for this node. POPULATED - finished counting files and subdirectories for this node, but have not started on recursive subdirectory population. KIDS_POPULATING - POPULATED plus recursion of kids has started. KIDS_POPULATED - Fully populated for this node. This is ALWAYS a directory and is tested on construction.

See Also:
Serialized Form

Field Summary
static int KIDS_POPULATED
           
static int KIDS_POPULATING
           
protected  java.io.File myDirectory
           
protected  java.lang.String myDisplayName
           
protected  int myFileCount
           
protected  int myStatus
           
protected  DirectoryTree myTree
           
static int POPULATED
           
static int POPULATING
           
static int UNPOPULATED
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
DirectoryTreeNode(DirectoryTree tree, java.io.File f)
           
 
Method Summary
 void addNode(java.lang.String dirName)
          Adding a new file or directory after constructing the FileTree.
static void cancelRecursiveLoading()
           
 void decrementChildCount()
           
 void deleteDir()
           
 void doChildCount()
           
 java.lang.String getAbsolutePath()
           
 java.io.File getFile()
           
 java.lang.String getName()
           
 void incrementChildCount()
           
 boolean isLeaf()
           
 void newSubDir()
           
 void quickPopulate()
           
 void recount()
           
 void renameDir()
           
static void resetRecursiveLoading()
           
 int status()
           
 java.lang.String toString()
           
 void updateTreeLabels()
           
 
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, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNPOPULATED

public static final int UNPOPULATED
See Also:
Constant Field Values

POPULATING

public static final int POPULATING
See Also:
Constant Field Values

POPULATED

public static final int POPULATED
See Also:
Constant Field Values

KIDS_POPULATING

public static final int KIDS_POPULATING
See Also:
Constant Field Values

KIDS_POPULATED

public static final int KIDS_POPULATED
See Also:
Constant Field Values

myStatus

protected int myStatus

myTree

protected DirectoryTree myTree

myDisplayName

protected java.lang.String myDisplayName

myDirectory

protected java.io.File myDirectory

myFileCount

protected int myFileCount
Constructor Detail

DirectoryTreeNode

public DirectoryTreeNode(DirectoryTree tree,
                         java.io.File f)
                  throws java.io.FileNotFoundException
Method Detail

cancelRecursiveLoading

public static void cancelRecursiveLoading()

resetRecursiveLoading

public static void resetRecursiveLoading()

status

public int status()

isLeaf

public boolean isLeaf()

getAbsolutePath

public java.lang.String getAbsolutePath()

getFile

public java.io.File getFile()

getName

public java.lang.String getName()

incrementChildCount

public void incrementChildCount()

decrementChildCount

public void decrementChildCount()

quickPopulate

public void quickPopulate()

doChildCount

public void doChildCount()

recount

public void recount()

addNode

public void addNode(java.lang.String dirName)
Adding a new file or directory after constructing the FileTree. Returns the index of the inserted node.


newSubDir

public void newSubDir()

renameDir

public void renameDir()

deleteDir

public void deleteDir()

updateTreeLabels

public void updateTreeLabels()

toString

public java.lang.String toString()


Copyright © 2002 Gerhard Beck. All rights reserved. Subject to GPL.