|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.io.swing.tree.FileTreeModel
public class FileTreeModel
A TreeModel which traverses java.io.File
instances.
If the root of this tree model is actually an instance of
de.schlichtherle.io.File, its archive
detector is used to detect any archive files in the directory tree.
This allows you to traverse archive files just like directories.
| Field Summary | |
|---|---|
private Map |
cache
Used to cache the contents of directories. |
private static Collator |
collator
A collator for file names which considers case according to the platform's standard. |
private Comparator |
comparator
A comparator for java.io.File or super classes. |
static Comparator |
FILE_NAME_COMPARATOR
A comparator which sorts directory entries to the beginning. |
private FileFilter |
filter
|
private EventListenerList |
listeners
|
private File |
root
|
| Constructor Summary | |
|---|---|
FileTreeModel()
Equivalent to FileTreeModel(null, null, FILE_NAME_COMPARATOR). |
|
FileTreeModel(File root)
Equivalent to FileTreeModel(root, null, FILE_NAME_COMPARATOR). |
|
FileTreeModel(File root,
FileFilter filter)
Equivalent to FileTreeModel(root, filter, FILE_NAME_COMPARATOR). |
|
FileTreeModel(File root,
FileFilter filter,
Comparator comparator)
Creates a new FileTreeModel which browses the specified
root file. |
|
| Method Summary | |
|---|---|
void |
addTreeModelListener(TreeModelListener l)
Adds a listener to this model. |
boolean |
archiveCopyAllTo(File oldNode,
File node)
Copies oldNode to node recursively, preserving
its last modification time
and updates the tree accordingly. |
boolean |
archiveCopyTo(File oldNode,
File node)
Copies oldNode to node, preserving
its last modification time
and updates the tree accordingly. |
boolean |
copyAllTo(File oldNode,
File node)
Copies oldNode to node recursively
and updates the tree accordingly. |
boolean |
copyFrom(File node,
InputStream in)
Creates node as a new file with the contents read from
in and updates the tree accordingly. |
boolean |
copyTo(File oldNode,
File node)
Copies oldNode to node
and updates the tree accordingly. |
boolean |
createNewFile(File node)
Creates node as a new file in the file system
and updates the tree accordingly. |
private File[] |
createPath(File node)
Returns an array of File objects indicating the path
from the root to the given node. |
private File[] |
createPath(File node,
int level)
|
TreePath |
createTreePath(File node)
Returns a TreePath for the given node or
null if the node is not part of this file tree. |
boolean |
delete(File node)
Deletes the file or empty directory node
and updates the tree accordingly. |
boolean |
deleteAll(File node)
Deletes the file or (probably not empty) directory node
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. |
void |
forget(File node)
Deprecated. This method is only public in order to make it available to JFileTree
- it is not intended for public use.
In particular, this method does not notify the
tree of any structural changes in the file system. |
private void |
forget(File node,
boolean childrenToo)
Clears the internal cache associated with node. |
Object |
getChild(Object parent,
int index)
|
int |
getChildCount(Object parent)
|
private File[] |
getChildren(File parent)
|
int |
getIndexOfChild(Object parent,
Object child)
|
Object |
getRoot()
Returns the root of this tree model. |
TreePath |
getTreePath(File node)
Deprecated. Use createTreePath(java.io.File) instead. |
boolean |
isLeaf(Object node)
|
boolean |
mkdir(File node)
Creates node as a new directory
and updates the tree accordingly. |
boolean |
mkdirs(File node)
Creates node as a new directory, including all parents,
and updates the tree accordingly. |
void |
nodeChanged(File node)
Updates the given node in the tree. |
void |
nodeInserted(File node)
Inserts the given node in the tree. |
void |
nodeInsertedOrStructureChanged(File node)
Inserts the given node in the tree or reloads the tree structure for the given node if it already exists. |
void |
nodeRemoved(File node)
Removes the given node from the tree. |
void |
refresh()
Refreshes the tree structure for the entire tree. |
void |
refresh(File node)
Alias for structureChanged(java.io.File). |
void |
removeTreeModelListener(TreeModelListener l)
Removes a listener from this model. |
boolean |
renameTo(File oldNode,
File newNode)
Renames oldNode to newNode
and updates the tree accordingly. |
void |
structureChanged(File node)
Reloads the tree structure for the given node. |
void |
valueForPathChanged(TreePath path,
Object newValue)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final Collator collator
public static final Comparator FILE_NAME_COMPARATOR
private final Map cache
File -> File[] instances.
private final File root
private final FileFilter filter
private final Comparator comparator
java.io.File or super classes.
private final EventListenerList listeners
| Constructor Detail |
|---|
public FileTreeModel()
FileTreeModel(null, null, FILE_NAME_COMPARATOR).
This constructor isn't particularly useful - it's only provided to
implement the JavaBean pattern.
public FileTreeModel(File root)
FileTreeModel(root, null, FILE_NAME_COMPARATOR).
public FileTreeModel(File root,
FileFilter filter)
FileTreeModel(root, filter, FILE_NAME_COMPARATOR).
public FileTreeModel(File root,
FileFilter filter,
Comparator comparator)
FileTreeModel which browses the specified
root file.
If file is an instance of File,
its archive detector is used to detect any archive files in the
directory tree.
root - The root of this FileTreeModel.
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 java.io.File 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 java.io.File or super
class instances.| Method Detail |
|---|
public Object getRoot()
java.io.File or
a subclass, like
de.schlichtherle.io.File.
getRoot in interface TreeModelFile object or null if this tree
model has not been created with a File object.
public Object getChild(Object parent,
int index)
getChild in interface TreeModelpublic int getChildCount(Object parent)
getChildCount in interface TreeModelpublic boolean isLeaf(Object node)
isLeaf in interface TreeModel
public void valueForPathChanged(TreePath path,
Object newValue)
valueForPathChanged in interface TreeModel
public int getIndexOfChild(Object parent,
Object child)
getIndexOfChild in interface TreeModelprivate File[] getChildren(File parent)
public TreePath getTreePath(File node)
createTreePath(java.io.File) instead.
createTreePath(java.io.File).
public TreePath createTreePath(File node)
TreePath for the given node or
null if the node is not part of this file tree.
private File[] createPath(File node)
File objects indicating the path
from the root to the given node.
node - The File object to get the path for.
File objects, suitable as a constructor
argument for TreePath or null if
node is not part of this file tree.
private File[] createPath(File node,
int level)
public boolean createNewFile(File node)
throws IOException
node as a new file in the file system
and updates the tree accordingly.
However, the current selection may get lost.
If you would like to create a new file with initial content, please
use copyFrom(de.schlichtherle.io.File, InputStream).
IOException - If an I/O error occurs.public boolean mkdir(File node)
node as a new directory
and updates the tree accordingly.
However, the current selection may get lost.
IOException - If an I/O error occurs.public boolean mkdirs(File node)
node as a new directory, including all parents,
and updates the tree accordingly.
However, the current selection may get lost.
IOException - If an I/O error occurs.
public boolean copyFrom(File node,
InputStream in)
node as a new file with the contents read from
in and updates the tree accordingly.
However, the current selection may get lost.
Note that the given stream is always closed.
IOException - If an I/O error occurs.
public boolean copyTo(File oldNode,
File node)
oldNode to node
and updates the tree accordingly.
However, the current selection may get lost.
public boolean copyAllTo(File oldNode,
File node)
oldNode to node recursively
and updates the tree accordingly.
However, the current selection may get lost.
public boolean archiveCopyTo(File oldNode,
File node)
oldNode to node, preserving
its last modification time
and updates the tree accordingly.
However, the current selection may get lost.
public boolean archiveCopyAllTo(File oldNode,
File node)
oldNode to node recursively, preserving
its last modification time
and updates the tree accordingly.
However, the current selection may get lost.
public boolean renameTo(File oldNode,
File newNode)
oldNode to newNode
and updates the tree accordingly.
However, the current selection may get lost.
public boolean delete(File node)
node
and updates the tree accordingly.
However, the current selection may get lost.
IOException - If an I/O error occurs.public boolean deleteAll(File node)
node
and updates the tree accordingly.
However, the current selection may get lost.
IOException - If an I/O error occurs.public void nodeInsertedOrStructureChanged(File node)
TreeModelListener.treeNodesInserted(TreeModelEvent)
on all listeners of this TreeModel.
public void nodeInserted(File node)
node already exists, nothing happens.
This method calls TreeModelListener.treeNodesInserted(TreeModelEvent)
on all listeners of this TreeModel.
public void nodeChanged(File node)
TreeModelListener.treeNodesChanged(TreeModelEvent)
on all listeners of this TreeModel.
public void nodeRemoved(File 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(File node)
structureChanged(java.io.File).
public void structureChanged(File node)
TreeModelListener.treeStructureChanged(TreeModelEvent)
on all listeners of this TreeModel.
public final void forget(File node)
JFileTree
- it is not intended for public use.
In particular, this method does not notify the
tree of any structural changes in the file system.
node and all
of its children.
private void forget(File node,
boolean childrenToo)
node.
childrenToo - If and only if true, the internal
cache for all children is cleared, too.public void addTreeModelListener(TreeModelListener l)
addTreeModelListener in interface TreeModell - The listener to add.public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener in interface TreeModell - The listener to remove.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.
|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||