@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public final class TFileTreeModel extends Object implements TreeModel
TreeModel which traverses TFile instances.
The TArchiveDetector of the root of this tree model is used to
detect any archive files in the directory tree.| Modifier and Type | Field and Description |
|---|---|
private Map<TFile,TFile[]> |
cache
Used to cache the contents of directories.
|
private Comparator<? super TFile> |
comparator
A comparator for
TFile or super classes. |
private FileFilter |
filter |
private EventListenerList |
listeners |
private TFile |
root |
| Constructor and Description |
|---|
TFileTreeModel(TFile root,
FileFilter filter,
Comparator<? super TFile> comparator)
Creates a new
TFileTreeModel which browses the specified
root file. |
| Modifier and Type | Method and Description |
|---|---|
void |
addTreeModelListener(TreeModelListener l)
Adds a listener to this model.
|
void |
cp_p(TFile oldNode,
TFile node)
Copies
oldNode to node
preserving its last modification time
and updates the tree accordingly. |
void |
cp_r(TFile oldNode,
TFile node)
Copies
oldNode to node recursively
and updates the tree accordingly. |
void |
cp_rp(TFile oldNode,
TFile node)
Copies
oldNode to node recursively
preserving its last modification time
and updates the tree accordingly. |
void |
cp(InputStream in,
TFile node)
Copies
in to node
and updates the tree accordingly. |
void |
cp(TFile oldNode,
TFile node)
Copies
oldNode to node
and updates the tree accordingly. |
boolean |
createNewFile(TFile node)
Creates
node as a new file in the file system
and updates the tree accordingly. |
protected void |
fireTreeNodesChanged(TreeModelEvent evt)
This method calls
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel. |
protected void |
fireTreeNodesInserted(TreeModelEvent evt)
This method calls
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel. |
protected void |
fireTreeNodesRemoved(TreeModelEvent evt)
This method calls
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel. |
protected void |
fireTreeStructureChanged(TreeModelEvent evt)
This method calls
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel. |
(package private) void |
forget(TFile node)
Clears the internal cache associated with
node and all
of its children. |
private void |
forget(TFile node,
boolean childrenToo)
Clears the internal cache associated with
node. |
TFile |
getChild(Object parent,
int index) |
int |
getChildCount(Object parent) |
private TFile[] |
getChildren(TFile parent) |
int |
getIndexOfChild(Object parent,
Object child) |
TFile |
getRoot() |
boolean |
isLeaf(Object node) |
void |
mkdir(TFile node,
boolean recursive)
Ensures that
node exists as a (virtual) directory in the
(federated) file system and updates the tree accordingly. |
void |
mv(TFile oldNode,
TFile node)
Moves
oldNode to node
and updates the tree accordingly. |
private TFile[] |
newPath(TFile node)
Returns an array of
TFile objects indicating the path
from the root to the given node. |
private TFile[] |
newPath(TFile node,
int level) |
(package private) TreePath |
newTreePath(TFile node)
|
void |
nodeChanged(TFile node)
Updates the given node in the tree.
|
void |
nodeInserted(TFile node)
Inserts the given node in the tree.
|
void |
nodeInsertedOrStructureChanged(TFile node)
Inserts the given node in the tree or reloads the tree structure for
the given node if it already exists.
|
void |
nodeRemoved(TFile node)
Removes the given node from the tree.
|
void |
refresh()
Refreshes the tree structure for the entire tree.
|
void |
refresh(TFile node)
Alias for
structureChanged(TFile). |
void |
removeTreeModelListener(TreeModelListener l)
Removes a listener from this model.
|
void |
rm_r(TFile node)
Deletes the file or (probably not empty) directory
node
and updates the tree accordingly. |
void |
rm(TFile node)
Deletes the file or empty directory
node
and updates the tree accordingly. |
void |
structureChanged(TFile node)
Reloads the tree structure for the given node.
|
void |
valueForPathChanged(TreePath path,
Object newValue) |
private final Comparator<? super TFile> comparator
TFile or super classes.@CheckForNull private final FileFilter filter
private final EventListenerList listeners
@CheckForNull private final TFile root
public TFileTreeModel(@CheckForNull
TFile root,
@CheckForNull
FileFilter filter,
Comparator<? super TFile> comparator)
TFileTreeModel which browses the specified
root file.
If file is an instance of TFile,
its archive detector is used to detect any archive files in the
directory tree.root - The root of this TFileTreeModel.
If this is null, an empty tree is created.filter - Used to filter the files and directories which are
present in this TreeModel.
If this is null, all files are accepted.comparator - A comparator for TFile instances
or super classes.
This must not be null.NullPointerException - If comparator is null.IllegalArgumentException - If root isn't
null and comparing it to itself didn't result in
0.ClassCastException - If root isn't
null and comparator isn't a
Comparator for TFile or super
class instances.public void addTreeModelListener(TreeModelListener l)
addTreeModelListener in interface TreeModell - The listener to add.public void cp_p(TFile oldNode, TFile node) throws IOException
oldNode to node
preserving its last modification time
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.public void cp_r(TFile oldNode, TFile node) throws IOException
oldNode to node recursively
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.public void cp_rp(TFile oldNode, TFile node) throws IOException
oldNode to node recursively
preserving its last modification time
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.public void cp(InputStream in, TFile node) throws IOException
in to node
and updates the tree accordingly.
Note that the given stream is always closed and
that the current selection may get lost.IOException - if any I/O error occurs.public void cp(TFile oldNode, TFile node) throws IOException
oldNode to node
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.public boolean createNewFile(TFile node) throws IOException
node as a new file in the file system
and updates the tree accordingly.
If you would like to create a new file with initial content, please
use cp(InputStream, TFile) instead.
Note that the current selection may get lost.IOException - if any I/O error occurs.protected void fireTreeNodesChanged(TreeModelEvent evt)
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.
May be used to tell the listeners about a change in the file system.protected void fireTreeNodesInserted(TreeModelEvent evt)
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.
May be used to tell the listeners about a change in the file system.protected void fireTreeNodesRemoved(TreeModelEvent evt)
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.
May be used to tell the listeners about a change in the file system.protected void fireTreeStructureChanged(TreeModelEvent evt)
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.
May be used to tell the listeners about a change in the file system.void forget(TFile node)
node and all
of its children.private void forget(@Nullable
TFile node,
boolean childrenToo)
node.childrenToo - If and only if true, the internal
cache for all children is cleared, too.public int getChildCount(Object parent)
getChildCount in interface TreeModelpublic int getIndexOfChild(Object parent, Object child)
getIndexOfChild in interface TreeModelpublic void mkdir(TFile node, boolean recursive) throws IOException
node exists as a (virtual) directory in the
(federated) file system and updates the tree accordingly.
Note that the current selection may get lost.recursive - whether or not any missing ancestor directories shall
get created if required.IOException - if any I/O error occurs.public void mv(TFile oldNode, TFile node) throws IOException
oldNode to node
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.@Nullable private TFile[] newPath(TFile node)
TFile objects indicating the path
from the root to the given node.node - The TFile object to get the path for.TFile objects, suitable as a constructor
argument for TreePath or null if
node is not part of this file tree or is
null.public void nodeChanged(TFile node)
TreeModelListener.treeNodesChanged(TreeModelEvent)
on all listeners of this TreeModel.public void nodeInserted(TFile node)
node already exists, nothing happens.
This method calls TreeModelListener.treeNodesInserted(TreeModelEvent)
on all listeners of this TreeModel.public void nodeInsertedOrStructureChanged(TFile node)
TreeModelListener.treeNodesInserted(TreeModelEvent)
on all listeners of this TreeModel.public void nodeRemoved(TFile node)
TreeModelListener.treeNodesRemoved(TreeModelEvent)
on all listeners of this TreeModel.public void refresh()
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.public final void refresh(TFile node)
structureChanged(TFile).public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener in interface TreeModell - The listener to remove.public void rm_r(TFile node) throws IOException
node
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.public void rm(TFile node) throws IOException
node
and updates the tree accordingly.
Note that the current selection may get lost.IOException - if any I/O error occurs.public void structureChanged(TFile node)
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.public void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged in interface TreeModelCopyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.