hades.manager
Class TreeManager

java.lang.Object
  extended byhades.manager.TreeManager

public class TreeManager
extends java.lang.Object

The class responsible to build and manage the simobject/design tree for Colibri. This class also collects (almost) all methods to update the tree.


Field Summary
(package private)  java.util.Hashtable pathToNodeTable
           
 
Constructor Summary
TreeManager()
           
 
Method Summary
 SortedTreeNode checkCreateDirectoryNode(java.lang.String pathname)
          check in our pathToNodeTable whether we already have a tree node corresponding to 'pathname'.
 void checkCreateFileNode(java.lang.String pathname, java.lang.String name, SortedTreeNode zipRoot)
           
 void checkLinkParentNodes(java.lang.String pathname, SortedTreeNode zipRoot)
           
 SortedTreeNode createLeafNode(java.lang.String name)
          // FIXME: should use the Factory pattern here: TreeNodeFactory.create...
 void displayTree(SortedTreeNode root)
           
 void dumpHdsFiles(SortedTreeNode root)
           
 void dumpTree(SortedTreeNode root)
           
static java.lang.String getFullPathname(SortedTreeNode node)
           
 java.lang.String getGifPathame(java.lang.String pathname)
          construct the pathname for a GIF icon corresponding to 'pathname': we strip off the extension and replace it by ".gif".
 SortedTreeNode getRootNode()
           
 boolean isDesignFile(java.lang.String name)
           
static void main(java.lang.String[] argv)
           
static void msg(java.lang.String s)
           
 void registerZipFile(java.lang.String filename)
           
 void setRootNode(SortedTreeNode root)
           
 void sortIntoTree(SortedTreeNode parent, SortedTreeNode child)
           
 java.lang.String[] splitZipEntryName(java.lang.String name)
          split a zip entry name into the path and the filename with extension.
 java.lang.String stripDirectoryNames(java.lang.String pathname)
          assuming a '/' separated full "path+file+extension" name, strip off the path name and return the file name.
 void testFileSystem(java.lang.String filename, SortedTreeNode root)
           
 boolean traverseFileTree(java.io.File path, SortedTreeNode node)
          traverse the file structure, starting from 'path', and build a tree with all directories and files of the following types: .hds design files, .clb simobject component info files, .rom memory contents, .fsm finite state machines, .py python scripts.
 ZipRootTreeNode traverseZip(java.util.zip.ZipFile zipfile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pathToNodeTable

java.util.Hashtable pathToNodeTable
Constructor Detail

TreeManager

public TreeManager()
Method Detail

setRootNode

public void setRootNode(SortedTreeNode root)

getRootNode

public SortedTreeNode getRootNode()

traverseFileTree

public boolean traverseFileTree(java.io.File path,
                                SortedTreeNode node)
traverse the file structure, starting from 'path', and build a tree with all directories and files of the following types: .hds design files, .clb simobject component info files, .rom memory contents, .fsm finite state machines, .py python scripts. .txt text files README files On non-Unix platforms, we convert external filenames from their native filename separator chars like '\' to unix '/' chars. Returns whether files were added to the 'node' (sub)tree


sortIntoTree

public void sortIntoTree(SortedTreeNode parent,
                         SortedTreeNode child)

isDesignFile

public boolean isDesignFile(java.lang.String name)

stripDirectoryNames

public java.lang.String stripDirectoryNames(java.lang.String pathname)
assuming a '/' separated full "path+file+extension" name, strip off the path name and return the file name.

If the name already ends with a '/', we return the last

     For example:
     "/usr/local/hades/models/gates/And2.hds" -> "And2.hds"
     "/usr/local/hades/models/gates"          -> "gates"
     "/usr/local/"                            -> "local"
     "/"                                      -> ""
     "e:/java/hades/models/io/ClockGen.hds"   -> "ClockGen.hds"
     "c:/"                                    -> "c:"
     


createLeafNode

public SortedTreeNode createLeafNode(java.lang.String name)
// FIXME: should use the Factory pattern here: TreeNodeFactory.create...


traverseZip

public ZipRootTreeNode traverseZip(java.util.zip.ZipFile zipfile)

checkCreateDirectoryNode

public SortedTreeNode checkCreateDirectoryNode(java.lang.String pathname)
check in our pathToNodeTable whether we already have a tree node corresponding to 'pathname'. If so, return the node. If not, create the necessary entries and its parent entries.


checkCreateFileNode

public void checkCreateFileNode(java.lang.String pathname,
                                java.lang.String name,
                                SortedTreeNode zipRoot)

checkLinkParentNodes

public void checkLinkParentNodes(java.lang.String pathname,
                                 SortedTreeNode zipRoot)

splitZipEntryName

public java.lang.String[] splitZipEntryName(java.lang.String name)
split a zip entry name into the path and the filename with extension. This allows us to check and build the directory tree nodes fast. The method returns an array of Strings with the result[0] = pathname and result[1] = filename. This method also strips of a leading '/', if any.


getFullPathname

public static java.lang.String getFullPathname(SortedTreeNode node)

getGifPathame

public java.lang.String getGifPathame(java.lang.String pathname)
construct the pathname for a GIF icon corresponding to 'pathname': we strip off the extension and replace it by ".gif". FIXME: this should probably use a better algorithm.


registerZipFile

public void registerZipFile(java.lang.String filename)

testFileSystem

public void testFileSystem(java.lang.String filename,
                           SortedTreeNode root)

dumpTree

public void dumpTree(SortedTreeNode root)

dumpHdsFiles

public void dumpHdsFiles(SortedTreeNode root)

displayTree

public void displayTree(SortedTreeNode root)

msg

public static void msg(java.lang.String s)

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception