Package uk.ac.starlink.connect

## Class FilestoreChooser

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JPanel
        - - uk.ac.starlink.connect.FilestoreChooser

All Implemented Interfaces:
  `java.awt.image.ImageObserver`, `java.awt.MenuContainer`, `java.io.Serializable`, `javax.accessibility.Accessible`

    public class FilestoreChooser
    extends javax.swing.JPanel

Generalised file browser which can browse virtual remote filesystems as well as the local filesystem. The objects it holds are instances of the `Node` interface.

Though written from scratch, this class is effectively a generalisation of `JFileChooser`. JFileChooser looks like it ought to be generalisable by providing alternative `FileSystemView` implementations, but I've tried it, and that way lies misery.

Since:
  18 Feb 2005
Author:
  Mark Taylor (Starlink)
See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class javax.swing.JPanel

`javax.swing.JPanel.AccessibleJPanel`

### Nested classes/interfaces inherited from class javax.swing.JComponent

`javax.swing.JComponent.AccessibleJComponent`

### Nested classes/interfaces inherited from class java.awt.Container

`java.awt.Container.AccessibleAWTContainer`

### Nested classes/interfaces inherited from class java.awt.Component

`java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

### Field Summary

### Fields inherited from class javax.swing.JComponent

`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

`accessibleContext, 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

Constructors
`FilestoreChooser()` Constructs a FilestoreChooser with navigation buttons included.
`FilestoreChooser​(boolean includeButtons)` Constructs a FilestoreChooser with navigation buttons optionally included.
`FilestoreChooser​(Branch branch)` Constructs a new chooser pointing to a given branch.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addConnection​(ConnectorAction connAct)` Adds a new branch representing a connection to a remote service to this chooser.
`void` `addDefaultBranches()` Populate this browser with a default set of branches.
`Branch` `getBranch()` Returns the currently selected branch.
`java.util.List<ConnectorAction>` `getConnectorActions()` Returns a mutable list of the connector instances used by this chooser.
`javax.swing.ComboBoxModel` `getModel()` Returns an object which contains the state of this chooser.
`javax.swing.Action[]` `getNavigationActions()` Returns the actions which allow the user to do additional navigation.
`javax.swing.Action` `getOkAction()` Returns the action which is equivalent to hitting an OK button, that is performing a selection.
`Node` `getSelectedNode()` Returns the single selected node.
`Node[]` `getSelectedNodes()` Returns the array of all nodes currently selected.
`protected void` `leafSelected​(Leaf leaf)` This method is called if a successful selection of a single leaf has taken place.
`static void` `main​(java.lang.String[] args)`
`void` `refreshList()` Ensures that the list contains the correct children for the currently selected branch.
`void` `setBranch​(Branch branch)` Sets the current selected branch.
`void` `setEnabled​(boolean enabled)`
`void` `setModel​(javax.swing.ComboBoxModel model)` Sets the model which contains the state of this chooser.

### Methods inherited from class javax.swing.JPanel

`getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI`

### Methods inherited from class javax.swing.JComponent

`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, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, 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`

### 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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### FilestoreChooser

    public FilestoreChooser()

Constructs a FilestoreChooser with navigation buttons included.

#### FilestoreChooser

    public FilestoreChooser​(boolean includeButtons)

Constructs a FilestoreChooser with navigation buttons optionally included.

Parameters:
  `includeButtons` - whether to include navigation buttons in the component

#### FilestoreChooser

    public FilestoreChooser​(Branch branch)

Constructs a new chooser pointing to a given branch.

Parameters:
  `branch` - initial branch

### Method Detail

#### getConnectorActions

    public java.util.List<ConnectorAction> getConnectorActions()

Returns a mutable list of the connector instances used by this chooser. You can manipulate this list either by adding/removing items from it or overriding this method.

Returns:
  mutable list of `ConnectorAction` objects

#### getOkAction

    public javax.swing.Action getOkAction()

Returns the action which is equivalent to hitting an OK button, that is performing a selection.

Returns:
  OK action

#### getNavigationActions

    public javax.swing.Action[] getNavigationActions()

Returns the actions which allow the user to do additional navigation.

Returns:
  navigation actions

#### setEnabled

    public void setEnabled​(boolean enabled)

Overrides:
  `setEnabled` in class `javax.swing.JComponent`

#### addDefaultBranches

    public void addDefaultBranches()

Populate this browser with a default set of branches. This includes the current directory and possibly some connectors for remote filestores. The selection is also set to a sensible initial value (probably the current directory).

#### setBranch

    public void setBranch​(Branch branch)

Sets the current selected branch. This may or may not add a new branch to the selector.

Parameters:
  `branch` - branch

#### refreshList

    public void refreshList()

Ensures that the list contains the correct children for the currently selected branch.

#### getBranch

    public Branch getBranch()

Returns the currently selected branch.

Returns:
  current branch

#### addConnection

    public void addConnection​(ConnectorAction connAct)

Adds a new branch representing a connection to a remote service to this chooser.

Parameters:
  `connAct` - connector action

#### getSelectedNodes

    public Node[] getSelectedNodes()

Returns the array of all nodes currently selected.

Returns:
  array of selected nodes

#### getSelectedNode

    public Node getSelectedNode()

Returns the single selected node. If more than one is selected, null is returned. A node is considered selected if its name is currently entered in the text field (as well as if it's been selected in the list in the usual way).

Returns:
  unique selected node, or null

#### getModel

    public javax.swing.ComboBoxModel getModel()

Returns an object which contains the state of this chooser. The object is the ComboBoxModel which defines the state of the selector at the top of the window which selects the current branch.

Returns:
  data model for this chooser

#### setModel

    public void setModel​(javax.swing.ComboBoxModel model)

Sets the model which contains the state of this chooser. The object is the ComboBoxModel which defines the state of the selector at the top of the window which selects the current branch. Note you can't just bung any old CombBoxModel in here; it must be one obtained from a `getModel()` call on another `FilestoreChooser`.

Parameters:
  `model` - data model to use

#### leafSelected

    protected void leafSelected​(Leaf leaf)

This method is called if a successful selection of a single leaf has taken place. The default implementation does nothing.

Parameters:
  `leaf` - selected leaf (not null)

#### main

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