Class DataNodeJTree

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class DataNodeJTree extends JTree
A JTree configured to display a DataNodeTreeModel. This class doesn't add much to JTree, but provides by default a suitable cell renderer and guarantees that its model is a DataNodeTreeModel.
Author:
Mark Taylor (Starlink)
See Also:
  • Constructor Details

    • DataNodeJTree

      public DataNodeJTree(DataNodeTreeModel model)
      Constructs a new DataNodeJTree from a suitable model.
      Parameters:
      model - the model representing the tree contents
    • DataNodeJTree

      public DataNodeJTree(DataNode root)
      Constructs a new DataNodeJTree from a given root node.
      Parameters:
      root - the root data node
  • Method Details

    • setModel

      public void setModel(TreeModel model)
      Sets the model for this JTree to a given DataNodeTreeModel.
      Overrides:
      setModel in class JTree
      Parameters:
      model - a DataNodeTreeModel object
      Throws:
      ClassCastException - if model is not a DataNodeTreeModel
    • recursiveExpand

      public Thread recursiveExpand(DataNode dataNode)
      Recursively expands a given data node. As with normal expansion, this happens asynchronously. A new thread is created and started in which the model expansion (though not the JTree notification) is done synchronously. This thread is available as the method's return value. The JTree is expanded to show the new nodes.
      Parameters:
      dataNode - the node to expand
      Returns:
      the Thread in which the expansion is done
    • expandPathLater

      public void expandPathLater(TreePath path)
      Submits a path expansion to the event queue for later invocation. In several cases it seems that invoking JTree.expandPath(javax.swing.tree.TreePath) on the JTree directly, even from the event dispatch thread, has the effect of messing up the tree's visual representation (leaving gaps between nodes). I'm guessing this is because JTree doesn't expect expandPath to be performed during tree gui processing which is already taking place. Doing it like this seems to alleviate the problem (I hope).
      Parameters:
      path - the path to expand
    • getDraggedNode

      public DataNode getDraggedNode()
      Returns the last place the mouse button was pressed on this component. This is required by the DataNodeTransferHandler, since otherwise there seems to be no way of knowing which node the drag gesture referred to. The way this is got hold of is not entirely reputable.
      Returns:
      the node corresponding to the last node dragged
    • getDropNode

      public DataNode getDropNode()
      Returns the current position of the mouse if it's being dragged on this component. This is required by the DataNodeTransferHandler.
      Returns:
      the node corresponding to the current drop position
    • getConnectionActions

      public Action[] getConnectionActions(DataNodeFactory factory)
      Returns a set of actions which can make connections to known virtual filestores, as supplied by ConnectorManager. Each action will result in the user being prompted for authorization information, and if this is satisfactory, a new node representing the root of the resulting virtual filestore being added to this tree.
      Parameters:
      factory - data node factory which will be used to create new data nodes for any connections which are opened