public class FileSystemModel2 extends AbstractTreeTableModel
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.
| Modifier and Type | Field and Description |
|---|---|
protected static String[] |
cNames |
protected static Class[] |
cTypes |
protected boolean |
descendLinks
Returns true if links are to be descended.
|
protected static de.cismet.tools.gui.treetable.FileSystemModel2.FileNode[] |
EMPTY_CHILDREN |
protected boolean |
isValid
True if the receiver is valid, once set to false all Threads loading files will stop.
|
protected de.cismet.tools.gui.treetable.FileSystemModel2.FileNode |
reloadNode
Node currently being reloaded, this becomes somewhat muddy if reloading is happening in multiple threads.
|
static Integer |
ZERO |
listenerList, root| Constructor and Description |
|---|
FileSystemModel2()
Creates a FileSystemModel2 rooted at File.separator, which is usually the root of the file system.
|
FileSystemModel2(String rootPath)
Creates a FileSystemModel2 with the root being
rootPath. |
| Modifier and Type | Method and Description |
|---|---|
Object |
getChild(Object node,
int i)
Returns the child of
node at index i. |
int |
getChildCount(Object node)
Returns the number of children of
node. |
protected Object[] |
getChildren(Object node)
DOCUMENT ME!
|
Class |
getColumnClass(int column)
Returns the class for the particular column.
|
int |
getColumnCount()
Returns the number of columns.
|
String |
getColumnName(int column)
Returns the name for a particular column.
|
boolean |
getDescendsLinks()
Returns true if links are to be automatically descended.
|
protected File |
getFile(Object node)
DOCUMENT ME!
|
Object |
getNodeLoading()
Returns the node being loaded.
|
String |
getPath(Object node)
Returns the path
node represents. |
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(Object node)
Returns the total size of the receiver.
|
Object |
getValueAt(Object node,
int column)
Returns the value of the particular column.
|
boolean |
isLeaf(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(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.
|
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getRoot, isCellEditable, removeTreeModelListener, setValueAt, valueForPathChangedprotected static String[] cNames
protected static Class[] cTypes
public static final Integer ZERO
protected static de.cismet.tools.gui.treetable.FileSystemModel2.FileNode[] EMPTY_CHILDREN
protected boolean isValid
protected de.cismet.tools.gui.treetable.FileSystemModel2.FileNode reloadNode
protected boolean descendLinks
public FileSystemModel2()
reloadChildren with the root to start loading.public FileSystemModel2(String rootPath)
rootPath. This does not load it, you should invoke
reloadChildren with the root to start loading.rootPath - DOCUMENT ME!protected static MergeSort getSizeSorter()
protected static void recycleSorter(MergeSort sorter)
sorter - DOCUMENT ME!public int getChildCount(Object node)
node.node - DOCUMENT ME!public Object getChild(Object node, int i)
node at index i.node - DOCUMENT ME!i - DOCUMENT ME!public boolean isLeaf(Object node)
isLeaf in interface TreeModelisLeaf in class AbstractTreeTableModelnode - DOCUMENT ME!public int getColumnCount()
public String getColumnName(int column)
column - DOCUMENT ME!public Class getColumnClass(int column)
getColumnClass in interface TreeTableModelgetColumnClass in class AbstractTreeTableModelcolumn - DOCUMENT ME!public Object getValueAt(Object node, int column)
node - DOCUMENT ME!column - DOCUMENT ME!public void reloadChildren(Object node)
node - DOCUMENT ME!public void stopLoading()
public void setDescendsLinks(boolean newValue)
newValue is true, links are descended. Odd results may happen if you set this while other threads
are loading.newValue - DOCUMENT ME!public boolean getDescendsLinks()
public String getPath(Object node)
node represents.node - DOCUMENT ME!public long getTotalSize(Object node)
node - DOCUMENT ME!public boolean isReloading()
public TreePath getPathLoading()
public Object getNodeLoading()
protected File getFile(Object node)
node - DOCUMENT ME!Copyright © 2012–2026 cismet GmbH. All rights reserved.