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 Document` | `doc` | DOM Document
    `protected EventListener` | `domListener` | DOM EventListener
    `protected Map<Node,​TreeNode>` | `domNodeMap` |
    `protected NodeFilter` | `nodeFilter` | NodeFilter for TreeWalker, default is null
    `protected 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 MutableTreeNode` | `buildTree​(TreeWalker tw)` | buildTree implementation.
    `protected void` | `domNodeHandleEvent​(Event evt)` | Detect the change in DOM document and update the TreeModel accordingly
    `Document` | `getDocument()` | Return DOM Document
    `Node` | `getDOMNode​(TreeNode treeNode)` |
    `NodeFilter` | `getNodeFilter()` | Return NodeFilter
    `TreeNode` | `getTreeNode​(Node domNode)` |
    `boolean` | `isLeaf​(Object node)` | Returns whether the specified node is a leaf node.
    `void` | `moveNodeDown​(TreeNode node)` |
    `void` | `moveNodeUp​(TreeNode node)` |
    `void` | `reload​(TreeNode node)` | Invoke this method if you've modified the TreeNodes upon which this model depends.
    `void` | `removeNode​(TreeNode node)` |
    `void` | `setDocument​(Document doc)` | Set DOM Document
    `void` | `setNodeFilter​(NodeFilter nodeFilter)` | NodeFilter which is used by TreeWalker, default is null It refreshes the tree.
    `void` | `valueForPathChanged​(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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### doc

          protected Document doc

      DOM Document

    - #### domListener

          protected EventListener domListener

      DOM EventListener

    - #### treeNodeMap

          protected Map<TreeNode,​Node> treeNodeMap

    - #### domNodeMap

          protected Map<Node,​TreeNode> domNodeMap

    - #### nodeFilter

          protected NodeFilter nodeFilter

      NodeFilter for TreeWalker, default is null

  - ### Constructor Detail

    - #### DOMTreeModel

          public DOMTreeModel()

      Creates a new instance of DOMTreeModel

  - ### 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:
        `isLeaf` in interface `TreeModel`
      Overrides:
        `isLeaf` in class `DefaultTreeModel`
      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:
        `valueForPathChanged` in interface `TreeModel`
      Overrides:
        `valueForPathChanged` in class `DefaultTreeModel`
      Parameters:
        `path` - path to the node that the user has altered
        `newValue` - 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 node `node`.
      Overrides:
        `reload` in class `DefaultTreeModel`
      Parameters:
        `node` - The node to reload

    - #### getTreeNode

          public TreeNode getTreeNode​(Node domNode)

    - #### getDOMNode

          public Node getDOMNode​(TreeNode treeNode)

    - #### 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