@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) 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.| Modifier and Type | Class and Description |
|---|---|
private class |
TFileTree.Controller |
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirectorJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
private TFileTree.Controller |
controller |
private String |
defaultSuffix |
private boolean |
displayingSuffixes |
private TFile |
editedNode |
private boolean |
editingSuffixes |
private static String |
PROPERTY_DEFAULT_SUFFIX
The name of the property
defaultSuffix. |
private static String |
PROPERTY_DISPLAYING_SUFFIXES
The name of the property
displayingSuffixes. |
private static String |
PROPERTY_EDITING_SUFFIXES
The name of the property
editingSuffixes. |
private static long |
serialVersionUID |
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, visibleRowCountaccessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, 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 |
getDefaultSuffix()
Getter for bound property defaultSuffix.
|
(package private) TFile |
getEditedNode()
Returns the node that is currently edited, if any.
|
TFileTreeModel |
getModel() |
private String |
getSuffix(String base) |
boolean |
isDisplayingSuffixes()
Getter for bound property displayingSuffixes.
|
boolean |
isEditing() |
boolean |
isEditingSuffixes()
Getter for bound property editingSuffixes.
|
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 |
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.
|
private void |
setExpandedDescendants(Enumeration<TreePath> expansions) |
void |
setModel(TreeModel model)
|
void |
setSelectionNode(TFile node) |
void |
setSelectionNodes(TFile[] nodes) |
void |
startEditingAtPath(TreePath path) |
boolean |
stopEditing() |
private TreePath |
substPath(TreePath tp,
TreePath oldPath,
TreePath path) |
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, updateUIaddAncestorListener, 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, 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, updateadd, 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, validateTreeaction, 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, hide, 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, transferFocusUpCycleprivate final TFileTree.Controller controller
@CheckForNull private String defaultSuffix
private boolean displayingSuffixes
@CheckForNull private transient TFile editedNode
private boolean editingSuffixes
private static final String PROPERTY_DEFAULT_SUFFIX
defaultSuffix.private static final String PROPERTY_DISPLAYING_SUFFIXES
displayingSuffixes.private static final String PROPERTY_EDITING_SUFFIXES
editingSuffixes.private static final long serialVersionUID
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 JTreepublic String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
convertValueToText in class JTreepublic void cp_p(TFile oldNode, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible.IOException - if any I/O error occurs.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 - if any I/O error occurs.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 - if any I/O error occurs.public void cp(InputStream in, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible.IOException - if any I/O error occurs.public void cp(TFile oldNode, TFile node) throws IOException
TFileTreeModel
and scrolls the tree so that the copied node
is selected and visible.IOException - if any I/O error occurs.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 - if any I/O error occurs.@Nullable public String getDefaultSuffix()
@Nullable TFile getEditedNode()
public TFileTreeModel getModel()
public boolean isDisplayingSuffixes()
public boolean isEditingSuffixes()
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 - if any I/O error occurs.public void mv(TFile oldNode, TFile node) throws IOException
TFileTreeModel,
restores the expanded paths, selects node and scrolls to
it if necessary.IOException - if any I/O error occurs.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 TreePaths 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 - if any I/O error occurs.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 - if any I/O error occurs.public void scrollNodeToVisible(TFile node)
public void setDefaultSuffix(@CheckForNull
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 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 void setEditable(boolean editable)
setEditable in class JTreepublic 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.private void setExpandedDescendants(Enumeration<TreePath> expansions)
public void setModel(TreeModel model)
setModel in class JTreeClassCastException - 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 JTreepublic boolean stopEditing()
stopEditing in class JTreeCopyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.