fri.gui.swing.polytreetable.samples
Class FileTreeTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--fri.gui.swing.polytreetable.samples.FileTreeTable
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, PolyTreeExpansionListener, PolyTreeWillExpandListener, java.io.Serializable

public class FileTreeTable
extends javax.swing.JPanel
implements PolyTreeExpansionListener, PolyTreeWillExpandListener, java.awt.event.ActionListener, javax.swing.event.ListSelectionListener

Sample application using PolyTreeTable, rendering and editing the filesystem (although most filesystems are not polyhierarchies).

This sample demonstrates how to use methods and callbacks of polytreetable. It lets insert new files, remove and rename existing files, and shows how to persist and restore expansion and focus state of the view. It lets change the look and feel and the Component orientation.

The nested class FileTreeTableUserObject implements the polytree file node object. It tries to catch multiple parents by testing if a file is a link (this will work on UNIX only).

See Also:
Serialized Form

Nested Class Summary
protected static class FileTreeTable.FileTreeTableUserObject
          The PolyTreeTableUserObject, extending java.io.File.
 
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
FileTreeTable()
          Create a treetable with start node System.getProperty("user.dir").
FileTreeTable(java.lang.String initFile)
          Create a treetable with given start node.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Implements interface ActionListener to set a new start node when a path was entered in textfield, and to insert or remove files.
 PolyTreeTable getTable()
          Returns the treetable.
 void init(java.lang.String file)
          Set a (new) start node into polytreetable.
 void loadPathes()
          Tries to load previously opened pathes from a file and open them again.
static void main(java.lang.String[] args)
          Application main
 void savePathes()
          Serializes opened pathes to a file.
 void treeCollapsed(PolyTreeExpansionEvent e)
          Called when the tree collapses.
 void treeExpanded(PolyTreeExpansionEvent e)
          Implements interface TreeExpansionListener to set default cursor after expansion.
 void treeStructureChanged(PolyTreeExpansionEvent e)
          Called when the tree changes root ("lead term").
 void treeWillCollapse(PolyTreeExpansionEvent e)
          Called when a tree node is about to be collapsed.
 void treeWillExpand(PolyTreeExpansionEvent e)
          Implements interface TreeWillExpandListener to set wait cursor during expansion.
 void treeWillStructureChange(PolyTreeExpansionEvent event)
          Called when the tree changes root ("lead term").
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          Implements interface ListSelectionListener to set lead selection to textfield.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileTreeTable

public FileTreeTable()
Create a treetable with start node System.getProperty("user.dir").


FileTreeTable

public FileTreeTable(java.lang.String initFile)
Create a treetable with given start node.

Method Detail

init

public void init(java.lang.String file)
Set a (new) start node into polytreetable.


getTable

public PolyTreeTable getTable()
Returns the treetable.


treeWillExpand

public void treeWillExpand(PolyTreeExpansionEvent e)
                    throws javax.swing.tree.ExpandVetoException
Implements interface TreeWillExpandListener to set wait cursor during expansion.

Specified by:
treeWillExpand in interface PolyTreeWillExpandListener
javax.swing.tree.ExpandVetoException

treeWillStructureChange

public void treeWillStructureChange(PolyTreeExpansionEvent event)
                             throws javax.swing.tree.ExpandVetoException
Description copied from interface: PolyTreeWillExpandListener
Called when the tree changes root ("lead term").

Specified by:
treeWillStructureChange in interface PolyTreeWillExpandListener
javax.swing.tree.ExpandVetoException

treeWillCollapse

public void treeWillCollapse(PolyTreeExpansionEvent e)
                      throws javax.swing.tree.ExpandVetoException
Description copied from interface: PolyTreeWillExpandListener
Called when a tree node is about to be collapsed. Throw an ExpandVetoException from here if this should not happen.

Specified by:
treeWillCollapse in interface PolyTreeWillExpandListener
javax.swing.tree.ExpandVetoException

treeExpanded

public void treeExpanded(PolyTreeExpansionEvent e)
Implements interface TreeExpansionListener to set default cursor after expansion.

Specified by:
treeExpanded in interface PolyTreeExpansionListener

treeCollapsed

public void treeCollapsed(PolyTreeExpansionEvent e)
Description copied from interface: PolyTreeExpansionListener
Called when the tree collapses.

Specified by:
treeCollapsed in interface PolyTreeExpansionListener

treeStructureChanged

public void treeStructureChanged(PolyTreeExpansionEvent e)
Description copied from interface: PolyTreeExpansionListener
Called when the tree changes root ("lead term").

Specified by:
treeStructureChanged in interface PolyTreeExpansionListener

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Implements interface ListSelectionListener to set lead selection to textfield.

Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Implements interface ActionListener to set a new start node when a path was entered in textfield, and to insert or remove files.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

loadPathes

public void loadPathes()
Tries to load previously opened pathes from a file and open them again.


savePathes

public void savePathes()
Serializes opened pathes to a file.


main

public static final void main(java.lang.String[] args)
Application main