|
|||||||||
| Home >> All >> allensoft >> gui >> [ treetable overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
allensoft.gui.treetable
Class FileSystemModel2

java.lang.Objectallensoft.gui.treetable.AbstractTreeTableModel
allensoft.gui.treetable.FileSystemModel2
- All Implemented Interfaces:
- javax.swing.tree.TreeModel, TreeTableModel
- public class FileSystemModel2
- extends AbstractTreeTableModel
FileSystemModel2 is a TreeTableModel representing a hierarchical file system.
This will recursively load all the children from the path it is created with. The loading is done with the method reloadChildren, and happens in another thread. The method isReloading can be invoked to check if there are active threads. The total size of all the files are also accumulated.
By default links are not descended. java.io.File does not have a way to distinguish links, so a file is assumed to be a link if its canonical path does not start with its parent path. This may not cover all cases, but works for the time being.
Reloading happens such that all the files of the directory are loaded and immediately available. The background thread then recursively loads all the files of each of those directories. When each directory has finished loading all its sub files they are attached and an event is generated in the event dispatching thread. A more ambitious approach would be to attach each set of directories as they are loaded and generate an event. Then, once all the direct descendants of the directory being reloaded have finished loading, it is resorted based on total size.
While you can invoke reloadChildren as many times as you want, care should be taken in doing this. You should not invoke reloadChildren on a node that is already being reloaded, or going to be reloaded (meaning its parent is reloading but it hasn't started reloading that directory yet). If this is done odd results may happen. FileSystemModel2 does not enforce any policy in this manner, and it is up to the user of FileSystemModel2 to ensure it doesn't happen.
- Version:
- 1.12 05/12/98
| Nested Class Summary | |
(package private) class |
FileSystemModel2.FileNode
A FileNode is a derivative of the File class - though we delegate to the File object rather than subclassing it. |
(package private) class |
FileSystemModel2.FileNodeLoader
FileNodeLoader can be used to reload all the children of a particular node. |
(package private) static class |
FileSystemModel2.SizeSorter
Sorts the contents, which must be instances of FileNode based on totalSize. |
| Field Summary | |
protected static java.lang.String[] |
cNames
|
protected static java.lang.Class[] |
cTypes
|
protected boolean |
descendLinks
Returns true if links are to be descended. |
protected static FileSystemModel2.FileNode[] |
EMPTY_CHILDREN
|
private static MergeSort |
fileMS
|
protected boolean |
isValid
True if the receiver is valid, once set to false all Threads loading files will stop. |
(package private) int |
reloadCount
> 0 indicates reloading some nodes. |
protected FileSystemModel2.FileNode |
reloadNode
Node currently being reloaded, this becomes somewhat muddy if reloading is happening in multiple threads. |
(package private) static java.util.Stack |
sorters
An array of MergeSorter sorters, that will sort based on size. |
static java.lang.Integer |
ZERO
|
| Fields inherited from class allensoft.gui.treetable.AbstractTreeTableModel |
listenerList, root |
| Constructor Summary | |
FileSystemModel2()
Creates a FileSystemModel2 rooted at File.separator, which is usually the root of the file system. |
|
FileSystemModel2(java.lang.String rootPath)
Creates a FileSystemModel2 with the root being rootPath. |
|
| Method Summary | |
java.lang.Object |
getChild(java.lang.Object node,
int i)
Returns the child of node at index i. |
int |
getChildCount(java.lang.Object node)
Returns the number of children of node. |
protected java.lang.Object[] |
getChildren(java.lang.Object node)
|
java.lang.Class |
getColumnClass(int column)
Returns the class for the particular column. |
int |
getColumnCount()
Returns the number of columns. |
java.lang.String |
getColumnName(int column)
Returns the name for a particular column. |
boolean |
getDescendsLinks()
Returns true if links are to be automatically descended. |
protected java.io.File |
getFile(java.lang.Object node)
|
java.lang.Object |
getNodeLoading()
Returns the node being loaded. |
java.lang.String |
getPath(java.lang.Object node)
Returns the path node represents. |
javax.swing.tree.TreePath |
getPathLoading()
Returns the path to the node that is being loaded. |
protected static MergeSort |
getSizeSorter()
Returns a MergeSort that can sort on the totalSize of a FileNode. |
long |
getTotalSize(java.lang.Object node)
Returns the total size of the receiver. |
java.lang.Object |
getValueAt(java.lang.Object node,
int column)
Returns the value of the particular column. |
boolean |
isLeaf(java.lang.Object node)
Returns true if the passed in object represents a leaf, false otherwise. |
boolean |
isReloading()
Returns true if the receiver is loading any children. |
protected static void |
recycleSorter(MergeSort sorter)
Should be invoked when a MergeSort is no longer needed. |
void |
reloadChildren(java.lang.Object node)
Reloads the children of the specified node. |
void |
setDescendsLinks(boolean newValue)
If newValue is true, links are descended. |
void |
stopLoading()
Stops and waits for all threads to finish loading. |
| Methods inherited from class allensoft.gui.treetable.AbstractTreeTableModel |
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getRoot, isCellEditable, removeTreeModelListener, setValueAt, valueForPathChanged |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
cNames
protected static java.lang.String[] cNames
cTypes
protected static java.lang.Class[] cTypes
ZERO
public static final java.lang.Integer ZERO
sorters
static java.util.Stack sorters
- An array of MergeSorter sorters, that will sort based on size.
isValid
protected boolean isValid
- True if the receiver is valid, once set to false all Threads
loading files will stop.
reloadNode
protected FileSystemModel2.FileNode reloadNode
- Node currently being reloaded, this becomes somewhat muddy if
reloading is happening in multiple threads.
reloadCount
int reloadCount
- > 0 indicates reloading some nodes.
descendLinks
protected boolean descendLinks
- Returns true if links are to be descended.
EMPTY_CHILDREN
protected static FileSystemModel2.FileNode[] EMPTY_CHILDREN
fileMS
private static MergeSort fileMS
| Constructor Detail |
FileSystemModel2
public FileSystemModel2()
- Creates a FileSystemModel2 rooted at File.separator, which is usually
the root of the file system. This does not load it, you should invoke
reloadChildrenwith the root to start loading.
FileSystemModel2
public FileSystemModel2(java.lang.String rootPath)
- Creates a FileSystemModel2 with the root being
rootPath. This does not load it, you should invokereloadChildrenwith the root to start loading.
| Method Detail |
getSizeSorter
protected static MergeSort getSizeSorter()
- Returns a MergeSort that can sort on the totalSize of a FileNode.
recycleSorter
protected static void recycleSorter(MergeSort sorter)
- Should be invoked when a MergeSort is no longer needed.
getChildCount
public int getChildCount(java.lang.Object node)
- Returns the number of children of
node.
getChild
public java.lang.Object getChild(java.lang.Object node, int i)
- Returns the child of
nodeat indexi.
isLeaf
public boolean isLeaf(java.lang.Object node)
- Returns true if the passed in object represents a leaf, false
otherwise.
- Specified by:
isLeafin interfacejavax.swing.tree.TreeModel- Overrides:
isLeafin classAbstractTreeTableModel
getColumnCount
public int getColumnCount()
- Returns the number of columns.
getColumnName
public java.lang.String getColumnName(int column)
- Returns the name for a particular column.
getColumnClass
public java.lang.Class getColumnClass(int column)
- Returns the class for the particular column.
- Specified by:
getColumnClassin interfaceTreeTableModel- Overrides:
getColumnClassin classAbstractTreeTableModel
getValueAt
public java.lang.Object getValueAt(java.lang.Object node, int column)
- Returns the value of the particular column.
reloadChildren
public void reloadChildren(java.lang.Object node)
- Reloads the children of the specified node.
stopLoading
public void stopLoading()
- Stops and waits for all threads to finish loading.
setDescendsLinks
public void setDescendsLinks(boolean newValue)
- If
newValueis true, links are descended. Odd results may happen if you set this while other threads are loading.
getDescendsLinks
public boolean getDescendsLinks()
- Returns true if links are to be automatically descended.
getPath
public java.lang.String getPath(java.lang.Object node)
- Returns the path
noderepresents.
getTotalSize
public long getTotalSize(java.lang.Object node)
- Returns the total size of the receiver.
isReloading
public boolean isReloading()
- Returns true if the receiver is loading any children.
getPathLoading
public javax.swing.tree.TreePath getPathLoading()
- Returns the path to the node that is being loaded.
getNodeLoading
public java.lang.Object getNodeLoading()
- Returns the node being loaded.
getFile
protected java.io.File getFile(java.lang.Object node)
getChildren
protected java.lang.Object[] getChildren(java.lang.Object node)
|
|||||||||
| Home >> All >> allensoft >> gui >> [ treetable overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC