Class SynchronizingMutableTreeNode<E>

java.lang.Object
javax.swing.tree.DefaultMutableTreeNode
com.aoapps.hodgepodge.swing.SynchronizingMutableTreeNode<E>
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode

public class SynchronizingMutableTreeNode<E> extends DefaultMutableTreeNode
When requested, it will recursively synchronize its children to an externally- provided tree. The is useful when the data source is obtained elsewhere and the tree-based component needs to be synchronized.

Since these updates may occur while a user is manipulating the components, only the minimum number of changes to the elements is made. Thus selections and other aspects of the component remain intact. Most importantly, if nothing in the list has changed, the component is not changed.

Author:
AO Industries, Inc.
See Also:
  • Constructor Details

    • SynchronizingMutableTreeNode

      public SynchronizingMutableTreeNode()
    • SynchronizingMutableTreeNode

      public SynchronizingMutableTreeNode(Object userObject)
    • SynchronizingMutableTreeNode

      public SynchronizingMutableTreeNode(Object userObject, boolean allowsChildren)
  • Method Details

    • synchronize

      public void synchronize(DefaultTreeModel treeModel, Tree<E> tree) throws IOException, SQLException
      Synchronizes the children of this node with the roots of the provided tree while adding and removing only a minimum number of nodes. Comparisons are performed using equals on the value objects. This must be called from the Swing event dispatch thread.
      Throws:
      IOException
      SQLException
    • synchronize

      public void synchronize(DefaultTreeModel treeModel, List<Node<E>> children) throws IOException, SQLException
      Synchronizes the children of this node with the provided children while adding and removing only a minimum number of nodes. Comparisons are performed using equals on the value objects. This must be called from the Swing event dispatch thread.
      Parameters:
      children - If children is null, then doesn't allow children.
      Throws:
      IOException
      SQLException