org.opensourcephysics.tools
Class JarTreeModel

java.lang.Object
  extended by org.opensourcephysics.tools.JarTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class JarTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel

A tree model to display files and jar/zip contents.

Version:
1.0
Author:
Doug Brown

Field Summary
protected  java.util.Map<java.io.File,java.util.Map<java.lang.String,org.opensourcephysics.tools.JarTreeModel.JarNode>> pathMaps
           
protected  java.io.File root
           
protected  java.util.Map<java.io.File,org.opensourcephysics.tools.JarTreeModel.JarNode[]> topLevelNodeArrays
           
 
Constructor Summary
JarTreeModel(java.io.File root)
          Constructor.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
 java.lang.Object getChild(java.lang.Object parent, int index)
          Gets the child node at a specified index.
 java.lang.Object getChild(java.lang.Object parent, java.lang.String name)
          Gets a child node with a given name.
 int getChildCount(java.lang.Object parent)
          Determines the number of child nodes for the specified node.
protected  java.util.Collection<java.lang.Object[]> getDescendantPaths(java.lang.Object[] parentPath)
          Returns all descendant paths for a parent path.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Gets the index of the specified child node.
 org.opensourcephysics.tools.JarTreeModel.JarNode getJarNode(java.io.File jarFile, java.lang.String path)
           
 org.opensourcephysics.tools.JarTreeModel.JarNode[] getJarNodes(java.io.File jarFile)
           
 java.lang.Object getRoot()
          Gets the root of this tree model.
 boolean isLeaf(java.lang.Object node)
          Returns true if the specified node is a leaf.
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newvalue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected java.io.File root

topLevelNodeArrays

protected java.util.Map<java.io.File,org.opensourcephysics.tools.JarTreeModel.JarNode[]> topLevelNodeArrays

pathMaps

protected java.util.Map<java.io.File,java.util.Map<java.lang.String,org.opensourcephysics.tools.JarTreeModel.JarNode>> pathMaps
Constructor Detail

JarTreeModel

public JarTreeModel(java.io.File root)
Constructor.

Parameters:
root - a directory file
Method Detail

getRoot

public java.lang.Object getRoot()
Gets the root of this tree model.

Specified by:
getRoot in interface javax.swing.tree.TreeModel
Returns:
the root file

isLeaf

public boolean isLeaf(java.lang.Object node)
Returns true if the specified node is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - the tree node
Returns:
true if node is a leaf

getChildCount

public int getChildCount(java.lang.Object parent)
Determines the number of child nodes for the specified node.

Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Parameters:
parent - the parent node
Returns:
the number of child nodes

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Gets the child node at a specified index. Parent and child may be a File or JarNode.

Specified by:
getChild in interface javax.swing.tree.TreeModel
Parameters:
parent - the parent node
index - the index
Returns:
the child node

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Gets the index of the specified child node.

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Parameters:
parent - the parent node
child - the child node
Returns:
the index of the child

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newvalue)
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 java.lang.String name)
Gets a child node with a given name. Parent and child may be a File or JarNode.

Parameters:
parent - the parent node
name - the name
Returns:
the child node

getDescendantPaths

protected java.util.Collection<java.lang.Object[]> getDescendantPaths(java.lang.Object[] parentPath)
Returns all descendant paths for a parent path. Descendants include the parent path itself.

Parameters:
parent - the parent Object[] path
Returns:
a collection of descendant Object[] paths

getJarNode

public org.opensourcephysics.tools.JarTreeModel.JarNode getJarNode(java.io.File jarFile,
                                                                   java.lang.String path)

getJarNodes

public org.opensourcephysics.tools.JarTreeModel.JarNode[] getJarNodes(java.io.File jarFile)