org.opensourcephysics.tools
Class LibraryTreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by org.opensourcephysics.tools.LibraryTreeNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class LibraryTreeNode
extends javax.swing.tree.DefaultMutableTreeNode

A DefaultMutableTreeNode for a library collection tree.

Version:
1.0
Author:
Douglas Brown
See Also:
Serialized Form

Field Summary
protected  boolean editable
           
protected static java.util.HashMap<java.lang.String,java.net.URL> htmlURLs
           
protected  LibraryResource record
           
protected  java.util.ArrayList<LibraryResource> resources
           
protected static java.util.HashMap<java.lang.String,java.net.URL> targetURLs
           
protected  LibraryTreePanel treePanel
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
protected LibraryTreeNode(LibraryResource resource, LibraryTreePanel treePanel)
          Constructs a node with a LibraryResource.
 
Method Summary
protected  boolean createChildNodes()
          Creates the child nodes of this node if this is a collection node.
protected  java.lang.String getAbsoluteTarget()
          Returns the absolute target path of this node's resource.
protected  java.lang.String getBasePath()
          Returns the base path of this node's resource.
protected  java.util.ArrayList<LibraryResource> getChildResources(java.lang.String[] types)
          Returns this node's child resources, if any, of a given set of types.
protected  java.lang.String getHTMLPath()
          Returns the html path of this node's resource.
protected  java.lang.String getHTMLString()
          Returns an HTML string that describes this node's resource.
protected  java.net.URL getHTMLURL()
          Returns the html URL of this node's resource, or null if html path is empty or invalid.
protected  java.lang.String getName()
          Returns the name of this node's resource.
protected  java.lang.String getTarget()
          Returns the target of this node's resource.
protected  java.net.URL getTargetURL()
          Returns the target URL of this node's resource, or null if target path is empty or invalid.
protected  boolean isEditable()
          Determines if this node is editable.
protected  void setBasePath(java.lang.String path)
          Sets the base path of this node's resource.
protected  void setEditable(boolean edit)
          Sets the editable property for this node.
protected  void setHTMLPath(java.lang.String path)
          Sets the html path of this node's resource.
protected  void setName(java.lang.String name)
          Sets the name of this node's resource.
protected  void setTarget(java.lang.String path)
          Sets the target of this node's resource.
protected  void setType(java.lang.String type)
          Sets the type of this node's resource.
 java.lang.String toString()
          Used by the tree node to get the display name.
 
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

htmlURLs

protected static java.util.HashMap<java.lang.String,java.net.URL> htmlURLs

targetURLs

protected static java.util.HashMap<java.lang.String,java.net.URL> targetURLs

record

protected LibraryResource record

editable

protected boolean editable

treePanel

protected LibraryTreePanel treePanel

resources

protected java.util.ArrayList<LibraryResource> resources
Constructor Detail

LibraryTreeNode

protected LibraryTreeNode(LibraryResource resource,
                          LibraryTreePanel treePanel)
Constructs a node with a LibraryResource.

Parameters:
resource - the resource
treePanel - the LibraryTreePanel that will use the node
Method Detail

createChildNodes

protected boolean createChildNodes()
Creates the child nodes of this node if this is a collection node.

Returns:
true if children were added

getName

protected java.lang.String getName()
Returns the name of this node's resource.

Returns:
the name

getBasePath

protected java.lang.String getBasePath()
Returns the base path of this node's resource.

Returns:
the base path

getHTMLPath

protected java.lang.String getHTMLPath()
Returns the html path of this node's resource.

Returns:
the html path

getHTMLURL

protected java.net.URL getHTMLURL()
Returns the html URL of this node's resource, or null if html path is empty or invalid.

Returns:
the URL

getHTMLString

protected java.lang.String getHTMLString()
Returns an HTML string that describes this node's resource. This is displayed if no html URL is available.

Returns:
the html string

getTarget

protected java.lang.String getTarget()
Returns the target of this node's resource. The target may be absolute or relative to base path.

Returns:
the target

getAbsoluteTarget

protected java.lang.String getAbsoluteTarget()
Returns the absolute target path of this node's resource.

Returns:
the absolute target path

getTargetURL

protected java.net.URL getTargetURL()
Returns the target URL of this node's resource, or null if target path is empty or invalid.

Returns:
the URL

toString

public java.lang.String toString()
Used by the tree node to get the display name.

Overrides:
toString in class javax.swing.tree.DefaultMutableTreeNode
Returns:
the display name of the node

isEditable

protected boolean isEditable()
Determines if this node is editable. Note: returns true only if this and its parent are editable.

Returns:
true of editable

setEditable

protected void setEditable(boolean edit)
Sets the editable property for this node.

Parameters:
edit - true to make this node editable

setName

protected void setName(java.lang.String name)
Sets the name of this node's resource.

Parameters:
name - the name

setTarget

protected void setTarget(java.lang.String path)
Sets the target of this node's resource. May be absolute or relative path.

Parameters:
path - the target path

setHTMLPath

protected void setHTMLPath(java.lang.String path)
Sets the html path of this node's resource.

Parameters:
path - the html path

setBasePath

protected void setBasePath(java.lang.String path)
Sets the base path of this node's resource.

Parameters:
path - the base path

setType

protected void setType(java.lang.String type)
Sets the type of this node's resource. The types are static constants defined by LibraryResource.

Parameters:
type - the type

getChildResources

protected java.util.ArrayList<LibraryResource> getChildResources(java.lang.String[] types)
Returns this node's child resources, if any, of a given set of types. The types are static constants defined by LibraryResource.

Parameters:
types - an array of resource types
Returns:
a list of LibraryResources