org.skunk.swing
Class TreeNodeChooser

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.skunk.swing.TreeNodeChooser
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
DAVFileChooser, LocalFileChooser

public class TreeNodeChooser
extends javax.swing.JPanel

a chooser that can be used as a filechooser, but which can display any tree of objects

See Also:
Serialized Form

Inner Class Summary
protected  class TreeNodeChooser.ComboRenderer
           
static class TreeNodeChooser.SelectionMode
          an enumerated type to represent chooser selection modes
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.lang.String DEFAULT_BRANCH_LABEL
           
static java.lang.String DEFAULT_ENTRY_LABEL
           
static java.lang.String DEFAULT_LEAF_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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TreeNodeChooser(javax.swing.tree.TreeModel treeModel)
          constructs a TreeNodeChooser from a TreeModel
 
Method Summary
 java.lang.String getEntryFieldText()
          returns the text of the entry field
 javax.swing.tree.TreeModel getModel()
          returns the chooser's TreeModel
 java.lang.String getNodeSeparator()
          Returns the separator used by the default renderer for the combo box in expressing the current TreePath as a file-path-like string.
 java.lang.Object getSelectedBranch()
          returns the selected item in the JList of branch nodes
 java.lang.Object getSelectedLeaf()
          returns the selected item in the JList of leaf nodes
 javax.swing.tree.TreePath getSelectedPath()
          returns the selected path
 TreeNodeChooser.SelectionMode getSelectionMode()
          returns the chooser's selection mode -- LEAF_ONLY, BRANCH_ONLY, or LEAF_AND_BRANCH
 boolean isEntryFieldEditable()
          indicates whether the file name text field is editable
 boolean isEntryFieldTextSticky()
          indicates whether the text of the entry field is persistent when the chooser's directory is changed.
 boolean isRootVisible()
          indicates whether the root of the tree model is visible in the chooser
 void setBranchLabelText(java.lang.String branchLabelText)
          sets the text of the label of list of branch nodes.
 void setComboBoxCellRenderer(javax.swing.ListCellRenderer cellRenderer)
          install a custom renderer for the combo box.
 void setCurrentPath(javax.swing.tree.TreePath currentPath)
          sets the selected path and displays it in the chooser
 void setEntryFieldEditable(boolean editable)
          determine whether the file name text field is editable
 void setEntryFieldText(java.lang.String text)
          sets the text of the entry field
 void setEntryFieldTextSticky(boolean sticky)
          determine whether the text of the entry field is persistent when the chooser's directory is changed.
 void setEntryLabelText(java.lang.String entryLabelText)
          sets the text of the label of the entry field.
 void setLeafLabelText(java.lang.String leafLabelText)
          sets the text of the label of list of leaf nodes.
 void setListCellRenderer(javax.swing.ListCellRenderer cellRenderer)
          install a custom renderer for both list boxes.
 void setNodeSeparator(java.lang.String nodeSeparator)
          sets the separator used by the default renderer for the combo box.
 void setRootVisible(boolean rootVisible)
          determine the visibility of the root node of the tree model
 void setSelectedBranch(java.lang.Object branchObj)
          sets the selected item in the JList of branch nodes
 void setSelectedLeaf(java.lang.Object leafObj)
          sets the selected item in the JList of leaf nodes
 void setSelectedPath(javax.swing.tree.TreePath selectedPath)
          sets the selected path property, without adjusting the state of the JLists or combo box.
 void setSelectionMode(TreeNodeChooser.SelectionMode selectionMode)
          sets the chooser's selection mode
 
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, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, 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, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, 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

DEFAULT_ENTRY_LABEL

public static final java.lang.String DEFAULT_ENTRY_LABEL

DEFAULT_BRANCH_LABEL

public static final java.lang.String DEFAULT_BRANCH_LABEL

DEFAULT_LEAF_LABEL

public static final java.lang.String DEFAULT_LEAF_LABEL
Constructor Detail

TreeNodeChooser

public TreeNodeChooser(javax.swing.tree.TreeModel treeModel)
constructs a TreeNodeChooser from a TreeModel
Parameters:
treeModel - the treeModel
Method Detail

getModel

public javax.swing.tree.TreeModel getModel()
returns the chooser's TreeModel
Returns:
the tree model

getNodeSeparator

public java.lang.String getNodeSeparator()
Returns the separator used by the default renderer for the combo box in expressing the current TreePath as a file-path-like string. By default, nodeSeparator equals File.separator. If a custom renderer is added for the comboBox, this property may be ignored.
Returns:
the node separator

setNodeSeparator

public void setNodeSeparator(java.lang.String nodeSeparator)
sets the separator used by the default renderer for the combo box.
Parameters:
nodeSeparator - the new node separator

isEntryFieldTextSticky

public boolean isEntryFieldTextSticky()
indicates whether the text of the entry field is persistent when the chooser's directory is changed.
Returns:
whether the text field's value is sticky

setEntryFieldTextSticky

public void setEntryFieldTextSticky(boolean sticky)
determine whether the text of the entry field is persistent when the chooser's directory is changed.
Parameters:
sticky - whether the text field's value should be sticky

isEntryFieldEditable

public boolean isEntryFieldEditable()
indicates whether the file name text field is editable
Returns:
whether the text field is editable

setEntryFieldEditable

public void setEntryFieldEditable(boolean editable)
determine whether the file name text field is editable
Parameters:
editable - the editability of the text field

isRootVisible

public boolean isRootVisible()
indicates whether the root of the tree model is visible in the chooser
Returns:
the visibility of the root node

setRootVisible

public void setRootVisible(boolean rootVisible)
determine the visibility of the root node of the tree model
Parameters:
rootVisible - the visibility of the root node

getSelectionMode

public TreeNodeChooser.SelectionMode getSelectionMode()
returns the chooser's selection mode -- LEAF_ONLY, BRANCH_ONLY, or LEAF_AND_BRANCH
Returns:
the selection node

setSelectionMode

public void setSelectionMode(TreeNodeChooser.SelectionMode selectionMode)
sets the chooser's selection mode
Parameters:
selectionMode - the new selection mode

setEntryLabelText

public void setEntryLabelText(java.lang.String entryLabelText)
sets the text of the label of the entry field. every internationalized application should set this, as the default is the English string "Selection: "
Parameters:
entryLabelText - the new text for the label

setBranchLabelText

public void setBranchLabelText(java.lang.String branchLabelText)
sets the text of the label of list of branch nodes. every internationalized application should set this, as the default is the English string "Directories: "
Parameters:
branchLabelText - the new text for the label

setLeafLabelText

public void setLeafLabelText(java.lang.String leafLabelText)
sets the text of the label of list of leaf nodes. every internationalized application should set this, as the default is the English string "Files: "
Parameters:
leafLabelText - the new text for the label

setListCellRenderer

public void setListCellRenderer(javax.swing.ListCellRenderer cellRenderer)
install a custom renderer for both list boxes.
Parameters:
cellRenderer - the new ListCellRenderer for the JLists

setComboBoxCellRenderer

public void setComboBoxCellRenderer(javax.swing.ListCellRenderer cellRenderer)
install a custom renderer for the combo box.
Parameters:
cellRenderer - the new ListCellRenderer for the JComboBox

getSelectedLeaf

public java.lang.Object getSelectedLeaf()
returns the selected item in the JList of leaf nodes
Returns:
the selected item

setSelectedLeaf

public void setSelectedLeaf(java.lang.Object leafObj)
sets the selected item in the JList of leaf nodes
Parameters:
leafObj - the leaf node to select

getSelectedBranch

public java.lang.Object getSelectedBranch()
returns the selected item in the JList of branch nodes
Returns:
the selected item

setSelectedBranch

public void setSelectedBranch(java.lang.Object branchObj)
sets the selected item in the JList of branch nodes
Parameters:
branchObj - the branch node to select

getSelectedPath

public javax.swing.tree.TreePath getSelectedPath()
returns the selected path
Returns:
the selected path

setSelectedPath

public void setSelectedPath(javax.swing.tree.TreePath selectedPath)
sets the selected path property, without adjusting the state of the JLists or combo box.
Parameters:
selectedPath - the selected path
See Also:
setCurrentPath

setCurrentPath

public void setCurrentPath(javax.swing.tree.TreePath currentPath)
sets the selected path and displays it in the chooser
Parameters:
currentPath - the new path to display

setEntryFieldText

public void setEntryFieldText(java.lang.String text)
sets the text of the entry field
Parameters:
text - the text for the entry field

getEntryFieldText

public java.lang.String getEntryFieldText()
returns the text of the entry field
Returns:
the entry field text