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:
ImageObserver
,MenuContainer
,Serializable
,Accessible
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, 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
ConstructorsConstructorDescriptionConstructs 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
Modifier and TypeMethodDescriptionvoid
addConnection
(ConnectorAction connAct) Adds a new branch representing a connection to a remote service to this chooser.void
Populate this browser with a default set of branches.Returns the currently selected branch.Returns a mutable list of the connector instances used by this chooser.getModel()
Returns an object which contains the state of this chooser.Action[]
Returns the actions which allow the user to do additional navigation.Returns the action which is equivalent to hitting an OK button, that is performing a selection.Returns the single selected node.Node[]
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
void
Ensures that the list contains the correct children for the currently selected branch.void
Sets the current selected branch.void
setEnabled
(boolean enabled) void
setModel
(ComboBoxModel<Branch> 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
-
Constructor Details
-
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
Constructs a new chooser pointing to a given branch.- Parameters:
branch
- initial branch
-
-
Method Details
-
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
Returns the action which is equivalent to hitting an OK button, that is performing a selection.- Returns:
- OK action
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabled
in classJComponent
-
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
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
Returns the currently selected branch.- Returns:
- current branch
-
addConnection
Adds a new branch representing a connection to a remote service to this chooser.- Parameters:
connAct
- connector action
-
getSelectedNodes
Returns the array of all nodes currently selected.- Returns:
- array of selected nodes
-
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
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
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 ComboBoxModel in here; it must be one obtained from agetModel()
call on another FilestoreChooser.- Parameters:
model
- data model to use
-
leafSelected
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
-