public final class TFileTree extends JTree
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.JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TFileTree()
Creates an empty
TFileTree with no root. |
TFileTree(TFile root)
Creates a new
TFileTree which traverses the given
root root file. |
TFileTree(TFileTreeModel model)
Creates a new
TFileTree which traverses the given
TFileTreeModel . |
Modifier and Type | Method and Description |
---|---|
void |
cancelEditing() |
String |
convertValueToText(Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) |
void |
cp_p(TFile oldNode,
TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible. |
void |
cp_r(TFile oldNode,
TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible. |
void |
cp_rp(TFile oldNode,
TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible. |
void |
cp(InputStream in,
TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible. |
void |
cp(TFile oldNode,
TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible. |
boolean |
createNewFile(TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the newly created file
is selected and visible. |
String |
getDefaultExtension()
Getter for bound property defaultExtension.
|
TFileTreeModel |
getModel() |
boolean |
isDisplayingExtensions()
Getter for bound property displayingExtensions.
|
boolean |
isEditing() |
boolean |
isEditingExtensions()
Getter for bound property editingExtensions.
|
void |
mkdir(TFile node,
boolean recursive)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the newly created directory
is selected and visible. |
void |
mv(TFile oldNode,
TFile node)
Forwards the call to the
TFileTreeModel ,
restores the expanded paths, selects node and scrolls to
it if necessary. |
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(TFile 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.
|
void |
rm_r(TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible. |
void |
rm(TFile node)
Forwards the call to the
TFileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible. |
void |
scrollNodeToVisible(TFile node) |
void |
setDefaultExtension(String defaultExtension)
Setter for bound property defaultExtension.
|
void |
setDisplayingExtensions(boolean displayingExtensions)
Setter for bound property displayingExtensions.
|
void |
setEditable(boolean editable) |
void |
setEditingExtensions(boolean editingExtensions)
Setter for bound property editingExtensions.
|
void |
setModel(TreeModel model) |
void |
setSelectionNode(TFile node) |
void |
setSelectionNodes(TFile[] nodes) |
void |
startEditingAtPath(TreePath path) |
boolean |
stopEditing() |
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, clearSelection, clearToggledPaths, collapsePath, collapseRow, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setDropMode, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, treeDidChange, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public TFileTree()
TFileTree
with no root.
You shouldn't use this constructor.
It's only provided to implement the JavaBean pattern.public TFileTree(TFile root)
TFileTree
which traverses the given
root root
file.public TFileTree(TFileTreeModel model)
TFileTree
which traverses the given
TFileTreeModel
.public void cancelEditing()
cancelEditing
in class JTree
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
convertValueToText
in class JTree
public void cp_p(TFile oldNode, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible.IOException
- on any I/O error.public void cp_r(TFile oldNode, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible.IOException
- on any I/O error.public void cp_rp(TFile oldNode, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the recursively copied node
is selected and visible.IOException
- on any I/O error.public void cp(@WillClose InputStream in, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible.IOException
- on any I/O error.public void cp(TFile oldNode, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible.IOException
- on any I/O error.public boolean createNewFile(TFile node) throws IOException
TFileTreeModel
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 cp(InputStream, TFile)
.IOException
- on any I/O error.@Nullable public String getDefaultExtension()
public TFileTreeModel getModel()
public boolean isDisplayingExtensions()
public boolean isEditingExtensions()
public void mkdir(TFile node, boolean recursive) throws IOException
TFileTreeModel
and scrolls the tree so that the newly created directory
is selected and visible.IOException
- on any I/O error.public void mv(TFile oldNode, TFile node) throws IOException
TFileTreeModel
,
restores the expanded paths, selects node
and scrolls to
it if necessary.IOException
- on any I/O error.protected void onEditingStopped(ChangeEvent evt)
evt
- The change event passed to
CellEditorListener.editingStopped(ChangeEvent)
.public void refresh()
public void refresh(TFile 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 void rm_r(TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible.IOException
- on any I/O error.public void rm(TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the successor to the deleted node
is selected and visible.IOException
- on any I/O error.public void scrollNodeToVisible(TFile node)
public void setDefaultExtension(@CheckForNull String defaultExtension)
null
and is ignored for
directories.defaultExtension
- The new default extension.
If not null
, this parameter is fixed to always
start with a '.'
.public void setDisplayingExtensions(boolean displayingExtensions)
false
, the extension of files will not be displayed
in this tree.
Defaults to true
.displayingExtensions
- New value of property displayingExtensions.public void setEditable(boolean editable)
setEditable
in class JTree
public void setEditingExtensions(boolean editingExtensions)
false
, the extension of a file will be truncated
before editing its name starts.
Defaults to true
.editingExtensions
- New value of property editingExtensions.public void setModel(TreeModel model)
setModel
in class JTree
ClassCastException
- if model
is not an instance
of TFileTreeModel
.public void setSelectionNode(TFile node)
public void setSelectionNodes(TFile[] nodes)
public void startEditingAtPath(TreePath path)
startEditingAtPath
in class JTree
public boolean stopEditing()
stopEditing
in class JTree
Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.