Class FilestoreChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FilestoreChooser extends 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:
  • 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

      public FilestoreChooser(Branch branch)
      Constructs a new chooser pointing to a given branch.
      Parameters:
      branch - initial branch
  • Method Details

    • getConnectorActions

      public 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 Action getOkAction()
      Returns the action which is equivalent to hitting an OK button, that is performing a selection.
      Returns:
      OK action
    • getNavigationActions

      public 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 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 ComboBoxModel<Branch> 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(ComboBoxModel<Branch> 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 ComboBoxModel 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(String[] args)