ftp.ui
Class FileTreeViewer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--ftp.ui.FileTreeViewer
Direct Known Subclasses:
RemoteFileTreeViewer

public class FileTreeViewer
extends javax.swing.JPanel
implements java.util.Observer

This class is a container of a FileTree.

See Also:
Serialized Form

Inner Class Summary
protected  class FileTreeViewer.MenuAction
          Inner class: Deals with menu action.
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  FileTreeCellEditor cellEditor
          tree cell editor
protected  FileTree fileTree
          FileTree which the receiver contains
protected  long focusTime
          the last focus gained time
protected  javax.swing.JTextField pathView
          component showing selected path
protected  javax.swing.JPopupMenu popup
          pop up menu
protected  javax.swing.JLabel status
          status label
 
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
 
Constructor Summary
  FileTreeViewer()
          Constructs a FileTreeViewer object.
protected FileTreeViewer(boolean local)
          This is a formal constructor.
 
Method Summary
protected  void addCellEditorListener()
          Adds CellEditorListener.
protected  void addCollapsePopup()
          Adds pop up menu for collapse use.
protected  void addDeletePopup()
          Adds pop up menu for delete use.
protected  void addDragDropListener()
          Adds listener to detect drag-drop action.
protected  void addFocusListener()
          Adds FocusListener.
protected  void addKeyListener()
          Adds KeyListener.
protected  void addListeners()
          Adds all event listeners.
protected  void addLoadPopup()
          Adds pop up menu for upload use.
protected  void addMkdirPopup()
          Adds pop up menu for mkdir use.
protected  void addMouseListener()
          Adds MouseListener.
protected  void addPopups()
          Adds all pop up menus.
protected  void addRefreshPopup()
          Adds pop up menu for refresh use.
protected  void addRenamePopup()
          Adds pop up menu for rename use.
protected  void addTreeExpansionListener()
          Adds TreeExpansionListener.
protected  void addTreeSelectionListener()
          Adds TreeSelectionListener.
protected  void addTreeWillExpandListener()
          Adds TreeWillExpandListener.
 void collapse()
          Collapses the selected path.
 void collapse(javax.swing.tree.TreePath path)
          Collapses the path.
 void delete()
          Deletes selected treeNodes with confirmation.
 void expandToLocalHome()
          Expands to local home.
 void expandToPath(java.lang.String path)
          Expands file tree to a given path.
 FileTree getFileTree()
          Returns FileTree the receiver contains.
 long getFocusTime()
          Returns the last focus gained time.
 javax.swing.JPopupMenu getPopupMenu()
          Returns pop up menu the receiver contains.
 FileTreeNode getSelectedTreeNode()
          Returns the selected tree node.
 FileTreeNode[] getSelectedTreeNodes()
          Returns all the selected tree nodes excluding those nodes whose ancestors are already selected.
 FileTreeNode[] getSelectionTreeNodes()
          Returns all the selected tree nodes.
protected  void initialize()
          Initalizes by setting layout, adding pop up menus.
protected  void insertPreholder(FileTreeNode parent, FileTreeNode newNode)
          Inserts a temporary node into tree.
 void mkdir()
          Makes a directory beneath current selected path.
 void mkdir(javax.swing.tree.TreePath path)
          Makes a directory beneath path.
 void refresh()
          Refreshes the selected path.
 void refresh(javax.swing.tree.TreePath path)
          Refreshes the path.
 void rename()
          Renames or moves the selected file.
 void rename(javax.swing.tree.TreePath path)
          Renames or moves the file at the path.
 void setStatus(java.lang.String info)
          Sets the status info.
 void update(java.util.Observable o, java.lang.Object arg)
          Implements the Observer's method.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fileTree

protected FileTree fileTree
FileTree which the receiver contains

popup

protected javax.swing.JPopupMenu popup
pop up menu

cellEditor

protected FileTreeCellEditor cellEditor
tree cell editor

focusTime

protected long focusTime
the last focus gained time

pathView

protected javax.swing.JTextField pathView
component showing selected path

status

protected javax.swing.JLabel status
status label
Constructor Detail

FileTreeViewer

public FileTreeViewer()
Constructs a FileTreeViewer object.

FileTreeViewer

protected FileTreeViewer(boolean local)
This is a formal constructor. It does nothing but to let its subclasses call instead of the default constructor.
Parameters:
local - formal argument.
Method Detail

initialize

protected void initialize()
Initalizes by setting layout, adding pop up menus.

getFileTree

public FileTree getFileTree()
Returns FileTree the receiver contains.
Returns:
FileTree the receiver contains.

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()
Returns pop up menu the receiver contains.
Returns:
pop up menu the receiver contains.

getFocusTime

public long getFocusTime()
Returns the last focus gained time.
Returns:
last focus gained time

getSelectedTreeNode

public FileTreeNode getSelectedTreeNode()
Returns the selected tree node.
Returns:
the selected tree node

getSelectionTreeNodes

public FileTreeNode[] getSelectionTreeNodes()
Returns all the selected tree nodes.
Returns:
all the selected tree nodes

getSelectedTreeNodes

public FileTreeNode[] getSelectedTreeNodes()
Returns all the selected tree nodes excluding those nodes whose ancestors are already selected.
Returns:
all the effectively selected tree nodes
See Also:
FileTree.getSelectedTreeNodes(boolean)

setStatus

public void setStatus(java.lang.String info)
Sets the status info.
Parameters:
info - the status info

addPopups

protected void addPopups()
Adds all pop up menus.

addLoadPopup

protected void addLoadPopup()
Adds pop up menu for upload use.

addRenamePopup

protected void addRenamePopup()
Adds pop up menu for rename use.

addDeletePopup

protected void addDeletePopup()
Adds pop up menu for delete use.

addMkdirPopup

protected void addMkdirPopup()
Adds pop up menu for mkdir use.

addRefreshPopup

protected void addRefreshPopup()
Adds pop up menu for refresh use.

addCollapsePopup

protected void addCollapsePopup()
Adds pop up menu for collapse use.

addListeners

protected void addListeners()
Adds all event listeners.

addKeyListener

protected void addKeyListener()
Adds KeyListener.

addTreeWillExpandListener

protected void addTreeWillExpandListener()
Adds TreeWillExpandListener.

addTreeExpansionListener

protected void addTreeExpansionListener()
Adds TreeExpansionListener.

addTreeSelectionListener

protected void addTreeSelectionListener()
Adds TreeSelectionListener.

addMouseListener

protected void addMouseListener()
Adds MouseListener.

addCellEditorListener

protected void addCellEditorListener()
Adds CellEditorListener. Especially used for rename a file or create a new directory.

addDragDropListener

protected void addDragDropListener()
Adds listener to detect drag-drop action.

addFocusListener

protected void addFocusListener()
Adds FocusListener.

delete

public void delete()
Deletes selected treeNodes with confirmation. Supports directory deletion and mutiple deletion.

mkdir

public void mkdir()
Makes a directory beneath current selected path. Prepares cell editor for user to edit new directory's name.

mkdir

public void mkdir(javax.swing.tree.TreePath path)
Makes a directory beneath path. Prepares cell editor for user to edit new directory's name.
Parameters:
path - the parent path of new directory
Throws:
java.lang.IllegalArgumentException - if path is null

rename

public void rename()
Renames or moves the selected file.

rename

public void rename(javax.swing.tree.TreePath path)
Renames or moves the file at the path.
Parameters:
path - where the file is

refresh

public void refresh()
Refreshes the selected path.

refresh

public void refresh(javax.swing.tree.TreePath path)
Refreshes the path.
Parameters:
path - the path to be reloaded

collapse

public void collapse()
Collapses the selected path.

collapse

public void collapse(javax.swing.tree.TreePath path)
Collapses the path.
Parameters:
path - the path to be collapsed

expandToLocalHome

public void expandToLocalHome()
Expands to local home.

expandToPath

public void expandToPath(java.lang.String path)
Expands file tree to a given path.
Parameters:
path - the path to be expanded

insertPreholder

protected void insertPreholder(FileTreeNode parent,
                               FileTreeNode newNode)
Inserts a temporary node into tree. when making a new directory, this can let user edit directory name he wants.
Parameters:
parent - parent tree node
newNode - temporary node

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Implements the Observer's method. Updates GUI when tree structure was changed by command line instead of graphical action. It will take no effect if arg is not instance of DownloadEvent.
Specified by:
update in interface java.util.Observer
See Also:
Observer.update(java.util.Observable, java.lang.Object)