Module com.aoapps.hodgepodge
Package com.aoapps.hodgepodge.swing
Class SynchronizingMutableTreeNode<E>
java.lang.Object
javax.swing.tree.DefaultMutableTreeNode
com.aoapps.hodgepodge.swing.SynchronizingMutableTreeNode<E>
- All Implemented Interfaces:
Serializable
,Cloneable
,MutableTreeNode
,TreeNode
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:
-
Field Summary
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
-
Constructor Summary
ConstructorDescriptionSynchronizingMutableTreeNode
(Object userObject) SynchronizingMutableTreeNode
(Object userObject, boolean allowsChildren) -
Method Summary
Modifier and TypeMethodDescriptionvoid
synchronize
(DefaultTreeModel treeModel, Tree<E> tree) Synchronizes the children of this node with the roots of the provided tree while adding and removing only a minimum number of nodes.void
synchronize
(DefaultTreeModel treeModel, List<Node<E>> children) Synchronizes the children of this node with the provided children while adding and removing only a minimum number of nodes.Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
-
Constructor Details
-
SynchronizingMutableTreeNode
public SynchronizingMutableTreeNode() -
SynchronizingMutableTreeNode
-
SynchronizingMutableTreeNode
-
-
Method Details
-
synchronize
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
-