Package kiyut.swing.tree.dom
Class DOMTreeModel
- java.lang.Object
-
- javax.swing.tree.DefaultTreeModel
-
- kiyut.swing.tree.dom.DOMTreeModel
-
- All Implemented Interfaces:
Serializable,TreeModel
public class DOMTreeModel extends DefaultTreeModel
DOMTreeModel- Author:
- KIYUT
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DocumentdocDOM Documentprotected EventListenerdomListenerDOM EventListenerprotected Map<Node,TreeNode>domNodeMapprotected NodeFilternodeFilterNodeFilter for TreeWalker, default is nullprotected Map<TreeNode,Node>treeNodeMap-
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
-
-
Constructor Summary
Constructors Constructor Description DOMTreeModel()Creates a new instance of DOMTreeModel
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MutableTreeNodebuildTree(TreeWalker tw)buildTree implementation.protected voiddomNodeHandleEvent(Event evt)Detect the change in DOM document and update the TreeModel accordinglyDocumentgetDocument()Return DOM DocumentNodegetDOMNode(TreeNode treeNode)NodeFiltergetNodeFilter()Return NodeFilterTreeNodegetTreeNode(Node domNode)booleanisLeaf(Object node)Returns whether the specified node is a leaf node.voidmoveNodeDown(TreeNode node)voidmoveNodeUp(TreeNode node)voidreload(TreeNode node)Invoke this method if you've modified the TreeNodes upon which this model depends.voidremoveNode(TreeNode node)voidsetDocument(Document doc)Set DOM DocumentvoidsetNodeFilter(NodeFilter nodeFilter)NodeFilter which is used by TreeWalker, default is null It refreshes the tree.voidvalueForPathChanged(TreePath path, Object newValue)This sets the user object of the TreeNode identified by path and posts a node changed.-
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot
-
-
-
-
Field Detail
-
doc
protected Document doc
DOM Document
-
domListener
protected EventListener domListener
DOM EventListener
-
nodeFilter
protected NodeFilter nodeFilter
NodeFilter for TreeWalker, default is null
-
-
Method Detail
-
setDocument
public void setDocument(Document doc)
Set DOM Document- Parameters:
doc- The DOM Document
-
getDocument
public Document getDocument()
Return DOM Document- Returns:
- DOM Document
-
setNodeFilter
public void setNodeFilter(NodeFilter nodeFilter)
NodeFilter which is used by TreeWalker, default is null It refreshes the tree.- Parameters:
nodeFilter- The NodeFilter
-
getNodeFilter
public NodeFilter getNodeFilter()
Return NodeFilter- Returns:
- NodeFilter
-
buildTree
protected MutableTreeNode buildTree(TreeWalker tw)
buildTree implementation. It is recursiverly walkthrough the passed TreeWalker- Parameters:
tw- The TreeWalker- Returns:
- MutableTreeNode
-
isLeaf
public boolean isLeaf(Object node)
Returns whether the specified node is a leaf node.- Specified by:
isLeafin interfaceTreeModel- Overrides:
isLeafin classDefaultTreeModel- Parameters:
node- the node to check- Returns:
- true if the node is a leaf node
-
valueForPathChanged
public void valueForPathChanged(TreePath path, Object newValue)
This sets the user object of the TreeNode identified by path and posts a node changed. If you use custom user objects in the TreeModel you're going to need to subclass this and set the user object of the changed node to something meaningful.- Specified by:
valueForPathChangedin interfaceTreeModel- Overrides:
valueForPathChangedin classDefaultTreeModel- Parameters:
path- path to the node that the user has alterednewValue- the new value from the TreeCellEditor
-
reload
public void reload(TreeNode node)
Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed below the nodenode.- Overrides:
reloadin classDefaultTreeModel- Parameters:
node- The node to reload
-
moveNodeUp
public void moveNodeUp(TreeNode node)
-
moveNodeDown
public void moveNodeDown(TreeNode node)
-
removeNode
public void removeNode(TreeNode node)
-
domNodeHandleEvent
protected void domNodeHandleEvent(Event evt)
Detect the change in DOM document and update the TreeModel accordingly- Parameters:
evt- The dom Event
-
-