|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
de.schlichtherle.io.swing.JFileTree
public class JFileTree
A custom JTree
to browse files and directories.
There are a couple of file creation/modification/removal methods added
which notify the tree of any changes in the file system and update the
current path expansions and selection.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JTree |
---|
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JFileTree()
Creates an empty JFileTree with no root. |
|
JFileTree(File root)
Creates a new JFileTree which traverses the given
root File . |
|
JFileTree(FileTreeModel model)
Creates a new JFileTree which traverses the given
FileTreeModel . |
Method Summary | |
---|---|
boolean |
archiveCopyAllTo(File oldNode,
File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible. |
boolean |
archiveCopyTo(File oldNode,
File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the copied node
is selected and visible. |
void |
cancelEditing()
|
String |
convertValueToText(Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
|
boolean |
copyAllTo(File oldNode,
File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible. |
boolean |
copyFrom(File node,
InputStream in)
Forwards the call to the FileTreeModel
and scrolls the tree so that the copied node
is selected and visible. |
boolean |
copyTo(File oldNode,
File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the copied node
is selected and visible. |
boolean |
createNewFile(File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the newly created file
is selected and visible. |
protected TreeCellRenderer |
createTreeCellRenderer()
Returns a new tree cell renderer. |
boolean |
delete(File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible. |
boolean |
deleteAll(File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible. |
String |
getDefaultSuffix()
Getter for bound property defaultSuffix. |
File |
getEditedNode()
Returns the node that is currently edited, if any. |
boolean |
isDisplayingSuffixes()
Getter for bound property displayingSuffixes. |
boolean |
isEditing()
|
boolean |
isEditingSuffixes()
Getter for bound property editingSuffixes. |
boolean |
mkdir(File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the newly created directory
is selected and visible. |
boolean |
mkdirs(File node)
Forwards the call to the FileTreeModel
and scrolls the tree so that the newly created directory
is selected and visible. |
protected void |
onEditingStopped(ChangeEvent evt)
Called when the editing of a cell has been stopped. |
void |
refresh()
Refreshes the entire tree, restores the expanded and selected paths and scrolls to the lead selection path if necessary. |
void |
refresh(File node)
Refreshes the subtree for the given node, restores the expanded and selected paths and scrolls to the lead selection path if necessary. |
void |
refresh(TreePath[] paths)
Refreshes the subtree for the given paths, restores the expanded and selected paths and scrolls to the lead selection path if necessary. |
boolean |
renameTo(File oldNode,
File node)
Forwards the call to the FileTreeModel ,
restores the expanded paths, selects node and scrolls to
it if necessary. |
void |
scrollNodeToVisible(File node)
|
void |
setDefaultSuffix(String defaultSuffix)
Setter for bound property defaultSuffixes. |
void |
setDisplayingSuffixes(boolean displayingSuffixes)
Setter for bound property displayingSuffixes. |
void |
setEditable(boolean editable)
|
void |
setEditingSuffixes(boolean editingSuffixes)
Setter for bound property editingSuffixes. |
void |
setModel(TreeModel model)
|
void |
setSelectionNode(File node)
|
void |
setSelectionNodes(File[] nodes)
|
void |
startEditingAtPath(TreePath path)
|
boolean |
stopEditing()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JFileTree()
JFileTree
with no root.
You shouldn't use this constructor.
It's only provided to implement the JavaBean pattern.
public JFileTree(File root)
JFileTree
which traverses the given
root File
.
The ZipDetector of the given file is used to detect and configure any
ZIP compatible files in this directory tree.
File.getDefaultArchiveDetector()
,
File.setDefaultArchiveDetector(ArchiveDetector)
public JFileTree(FileTreeModel model)
JFileTree
which traverses the given
FileTreeModel
.
Method Detail |
---|
protected TreeCellRenderer createTreeCellRenderer()
This implementation simply returns a new FileTreeCellRenderer
.
public void setModel(TreeModel model)
setModel
in class JTree
ClassCastException
- If model
is not an instance
of FileTreeModel
.public void setEditable(boolean editable)
setEditable
in class JTree
public boolean isDisplayingSuffixes()
public void setDisplayingSuffixes(boolean displayingSuffixes)
false
, the suffix of files will not be displayed
in this tree.
Defaults to true
.
displayingSuffixes
- New value of property displayingSuffixes.public boolean isEditingSuffixes()
public void setEditingSuffixes(boolean editingSuffixes)
false
, the suffix of a file will be truncated
before editing its name starts.
Defaults to true
.
editingSuffixes
- New value of property editingSuffixes.public String getDefaultSuffix()
public void setDefaultSuffix(String defaultSuffix)
null
and is ignored for
directories.
defaultSuffix
- The new default suffix.
If not null
, this parameter is fixed to always
start with a '.'
.public File getEditedNode()
public boolean isEditing()
isEditing
in class JTree
public void startEditingAtPath(TreePath path)
startEditingAtPath
in class JTree
public void cancelEditing()
cancelEditing
in class JTree
public boolean stopEditing()
stopEditing
in class JTree
protected void onEditingStopped(ChangeEvent evt)
evt
- The change event passed to
CellEditorListener.editingStopped(ChangeEvent)
.public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
convertValueToText
in class JTree
public void refresh()
public void refresh(File node)
node
- The file or directory to refresh.
This may not be null
.public void refresh(TreePath[] paths)
paths
- The array of TreePath
s to refresh.
This may be null
.public boolean createNewFile(File node) throws IOException
FileTreeModel
and scrolls the tree so that the newly created file
is selected and visible.
If you would like to create a new file with initial content, please
check copyFrom(de.schlichtherle.io.File, InputStream)
.
IOException
public boolean mkdir(File node)
FileTreeModel
and scrolls the tree so that the newly created directory
is selected and visible.
public boolean mkdirs(File node)
FileTreeModel
and scrolls the tree so that the newly created directory
is selected and visible.
public boolean copyFrom(File node, InputStream in)
FileTreeModel
and scrolls the tree so that the copied node
is selected and visible.
public boolean copyTo(File oldNode, File node)
FileTreeModel
and scrolls the tree so that the copied node
is selected and visible.
public boolean copyAllTo(File oldNode, File node)
FileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible.
public boolean archiveCopyTo(File oldNode, File node)
FileTreeModel
and scrolls the tree so that the copied node
is selected and visible.
public boolean archiveCopyAllTo(File oldNode, File node)
FileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible.
public boolean renameTo(File oldNode, File node)
FileTreeModel
,
restores the expanded paths, selects node
and scrolls to
it if necessary.
public boolean delete(File node)
FileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible.
public boolean deleteAll(File node)
FileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible.
public void setSelectionNode(File node)
public void setSelectionNodes(File[] nodes)
public void scrollNodeToVisible(File node)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |