Class NodeExpander


  • public class NodeExpander
    extends java.lang.Object
    Object which can obtain children from a node and add them to a TreeModel as they become available. While working, members of this class will check periodically whether they are still responsible for expanding nodes by seeing whether the ModelNode on whose behalf they are working still owns them as its NodeExpander. If not, they will assume that they are no longer doing useful work and will stop working. Subclasses ought to observe the same behaviour.
    Author:
    Mark Taylor (Starlink)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void expandNode()
      Performs the actual node expansion.
      boolean isComplete()
      Indicates whether node expansion completed successfully.
      boolean isStopped()
      Indicates whether node expansion has stopped happening.
      void stop()
      Interrupts the work of this expander.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NodeExpander

        public NodeExpander​(DataNodeTreeModel treeModel,
                            TreeModelNode modelNode)
        Constructs a new expander.
        Parameters:
        modelNode - the node to be expanded
        treeModel - the model into which children are to be added
    • Method Detail

      • expandNode

        public void expandNode()
        Performs the actual node expansion. All children of the model node's data node are acquired and synchronously inserted into the tree model. The tree model's listeners are notified asynchronously.

        If this expander ceases to be active (is not owned by its model node) then expansion may be stopped.

        This may be a slow operation, so should not be done in the event dispatch thread.

      • stop

        public void stop()
        Interrupts the work of this expander. It will not add any more children to its node. It should stop using processing resources to this end, but that may not happen immediately.
      • isStopped

        public boolean isStopped()
        Indicates whether node expansion has stopped happening.
        Returns:
        true iff this expander is no longer working on expanding its node
      • isComplete

        public boolean isComplete()
        Indicates whether node expansion completed successfully.
        Returns:
        true iff all child nodes have been added to the parent