Quaqua 7.4.2 2011-07-05

ch.randelshofer.quaqua.filechooser
Class FileSystemTreeModel.Node

java.lang.Object
  extended by ch.randelshofer.quaqua.filechooser.FileSystemTreeModel.Node
All Implemented Interfaces:
FileInfo, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode
Direct Known Subclasses:
FileSystemTreeModel.AliasNode, FileSystemTreeModel.DirectoryNode
Enclosing class:
FileSystemTreeModel

public class FileSystemTreeModel.Node
extends java.lang.Object
implements javax.swing.tree.MutableTreeNode, FileInfo

This is the implementation for a file node (a leaf node).


Field Summary
protected  java.text.CollationKey collationKey
           
protected  java.io.File file
           
protected  int fileLabel
          Holds a Finder label for the file represented by this node.
protected  javax.swing.Icon icon
          Holds the icon of the file.
protected  java.lang.Boolean isAcceptable
          Contains Boolean.TRUE or Boolean.FALSE, if the file has been accepted or rejected by the FileFilter of the JFileChooser.
protected  boolean isHidden
          Contains the hidden state of the file
protected  javax.swing.tree.TreeNode parent
           
protected  java.lang.String userName
           
 
Constructor Summary
FileSystemTreeModel.Node(java.io.File f, boolean isHidden)
           
FileSystemTreeModel.Node(java.io.File f, java.lang.String userName, boolean isHidden)
           
 
Method Summary
 java.util.Enumeration children()
           
 boolean getAllowsChildren()
           
 javax.swing.tree.TreeNode getChildAt(int childIndex)
           
 int getChildCount()
           
 java.text.CollationKey getCollationKey()
           
 java.io.File getFile()
          Returns the unresolved file object.
 java.lang.String getFileKind()
          Returns the kind of the file.
 int getFileLabel()
          Returns the (color) label of the file.
 long getFileLength()
          Returns the length of the file.
 javax.swing.Icon getIcon()
          Returns the icon of the file.
 int getIndex(javax.swing.tree.TreeNode node)
           
 javax.swing.tree.TreeNode getParent()
           
 javax.swing.tree.TreeNode[] getPath()
           
protected  javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode, int depth)
           
 java.io.File getResolvedFile()
          Returns the resolved file object.
 javax.swing.tree.TreeNode getRoot()
          Returns the root of the tree that contains this node.
 java.lang.String getUserName()
          Returns the user name of the file.
 void insert(javax.swing.tree.MutableTreeNode child, int index)
           
 void invalidateChildren()
          Marks this node as invalid.
 void invalidateInfo()
          Clears cached info
 void invalidateTree()
          Marks this subtree as invalid.
 boolean isAcceptable()
          Returns false, if the node is not accepted by the file filter of the JFileChooser.
 boolean isAlias()
           
 boolean isHidden()
          Returns true, if the file object is hidden.
 boolean isLeaf()
           
 boolean isNodeAncestor(javax.swing.tree.TreeNode anotherNode)
           
 boolean isTraversable()
          Returns true, if the file object is traversable.
 boolean isValidating()
          Returns true if a worker thread is validating the information provided by this file info object.
 boolean isValidatingChildren()
           
 java.io.File lazyGetResolvedFile()
          Lazily resolves the file.
 void lazyInvalidateChildren()
          Marks this node as invalid if the node is not currently being updated.
 void remove(int index)
           
 void remove(javax.swing.tree.MutableTreeNode node)
           
 void removeFromParent()
           
 void setParent(javax.swing.tree.MutableTreeNode newParent)
           
 void setTraversable(boolean newValue)
          Changes the traversability of a directory node.
 void setUserObject(java.lang.Object object)
           
 void stopValidationSubtree()
           
 java.lang.String toString()
           
 void validateChildren()
          Validates this node if it is invalid.
 void validateInfo()
          Updates values, that may change in a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected javax.swing.tree.TreeNode parent

file

protected java.io.File file

userName

protected java.lang.String userName

collationKey

protected java.text.CollationKey collationKey

fileLabel

protected int fileLabel
Holds a Finder label for the file represented by this node. The label is a value in the interval from 0 through 7. The value -1 is used, if the label has not (yet) been retrieved, or if it couldn't be determined due to the lack of native support.


icon

protected javax.swing.Icon icon
Holds the icon of the file. The value null is used, if the icon has not (yet) been retrieved, or if it couldn't be determined due to the lack of native support.


isAcceptable

protected java.lang.Boolean isAcceptable
Contains Boolean.TRUE or Boolean.FALSE, if the file has been accepted or rejected by the FileFilter of the JFileChooser. Contains null, if the acceptance has not been determined yet.


isHidden

protected boolean isHidden
Contains the hidden state of the file

Constructor Detail

FileSystemTreeModel.Node

public FileSystemTreeModel.Node(java.io.File f,
                                boolean isHidden)

FileSystemTreeModel.Node

public FileSystemTreeModel.Node(java.io.File f,
                                java.lang.String userName,
                                boolean isHidden)
Method Detail

lazyGetResolvedFile

public java.io.File lazyGetResolvedFile()
Lazily resolves the file. This method returns null, if the File has not been resolved yet.

Specified by:
lazyGetResolvedFile in interface FileInfo

getFile

public java.io.File getFile()
Description copied from interface: FileInfo
Returns the unresolved file object.

Specified by:
getFile in interface FileInfo

getFileLength

public long getFileLength()
Description copied from interface: FileInfo
Returns the length of the file. Returns -1 if the length has not (yet) been determined.

Specified by:
getFileLength in interface FileInfo

getUserName

public java.lang.String getUserName()
Description copied from interface: FileInfo
Returns the user name of the file.

Specified by:
getUserName in interface FileInfo

getFileLabel

public int getFileLabel()
Description copied from interface: FileInfo
Returns the (color) label of the file. Returns -1 if the label has not (yet) been determined.

Specified by:
getFileLabel in interface FileInfo

getIcon

public javax.swing.Icon getIcon()
Description copied from interface: FileInfo
Returns the icon of the file. Returns a proxy icon if the real icon has not yet been fetched from the file system.

Specified by:
getIcon in interface FileInfo

getCollationKey

public java.text.CollationKey getCollationKey()

isAlias

public boolean isAlias()

setTraversable

public void setTraversable(boolean newValue)
Changes the traversability of a directory node. This method has no effect on non-directory nodes.


isAcceptable

public boolean isAcceptable()
Returns false, if the node is not accepted by the file filter of the JFileChooser.

Specified by:
isAcceptable in interface FileInfo

isHidden

public boolean isHidden()
Description copied from interface: FileInfo
Returns true, if the file object is hidden.

Specified by:
isHidden in interface FileInfo

getFileKind

public java.lang.String getFileKind()
Description copied from interface: FileInfo
Returns the kind of the file. Returns null if the kind has not (yet) been determined.

Specified by:
getFileKind in interface FileInfo

invalidateInfo

public void invalidateInfo()
Clears cached info


validateInfo

public void validateInfo()
Updates values, that may change in a file.


invalidateChildren

public void invalidateChildren()
Marks this node as invalid. If the node denotes not a directory, nothing happens.


lazyInvalidateChildren

public void lazyInvalidateChildren()
Marks this node as invalid if the node is not currently being updated. If the node denotes not a directory, nothing happens.


stopValidationSubtree

public void stopValidationSubtree()

invalidateTree

public void invalidateTree()
Marks this subtree as invalid.


validateChildren

public void validateChildren()
Validates this node if it is invalid. If this node is invalid, a worker thread is launched, which reads the directory denoted by this node and merges it with the existing children of this node. If the node denotes not a directory, nothing happens.


isValidating

public boolean isValidating()
Description copied from interface: FileInfo
Returns true if a worker thread is validating the information provided by this file info object.

Specified by:
isValidating in interface FileInfo

isValidatingChildren

public boolean isValidatingChildren()

getParent

public javax.swing.tree.TreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode

setParent

public void setParent(javax.swing.tree.MutableTreeNode newParent)
Specified by:
setParent in interface javax.swing.tree.MutableTreeNode

removeFromParent

public void removeFromParent()
Specified by:
removeFromParent in interface javax.swing.tree.MutableTreeNode

setUserObject

public void setUserObject(java.lang.Object object)
Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode

getPath

public javax.swing.tree.TreeNode[] getPath()

getPathToRoot

protected javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode,
                                                    int depth)

getRoot

public javax.swing.tree.TreeNode getRoot()
Returns the root of the tree that contains this node. The root is the ancestor with a null parent.

Returns:
the root of the tree that contains this node
See Also:
isNodeAncestor(javax.swing.tree.TreeNode)

isNodeAncestor

public boolean isNodeAncestor(javax.swing.tree.TreeNode anotherNode)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

children

public java.util.Enumeration children()
Specified by:
children in interface javax.swing.tree.TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Specified by:
getIndex in interface javax.swing.tree.TreeNode

insert

public void insert(javax.swing.tree.MutableTreeNode child,
                   int index)
Specified by:
insert in interface javax.swing.tree.MutableTreeNode

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode

remove

public void remove(javax.swing.tree.MutableTreeNode node)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

remove

public void remove(int index)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

isTraversable

public boolean isTraversable()
Description copied from interface: FileInfo
Returns true, if the file object is traversable.

Specified by:
isTraversable in interface FileInfo

getResolvedFile

public java.io.File getResolvedFile()
Description copied from interface: FileInfo
Returns the resolved file object.

Specified by:
getResolvedFile in interface FileInfo

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.