de.esprit.appsuite.gui.pathtree

## Class PathTreeModel<C extends ApplicationContext,N extends PathTreeNode>

- java.lang.Object
- - javax.swing.tree.DefaultTreeModel
  - - de.esprit.appsuite.gui.pathtree.PathTreeModel<C,N>

- All Implemented Interfaces:
    ApplicationObject<C>, Resettable, java.io.Serializable, javax.swing.tree.TreeModel

      public class PathTreeModel<C extends ApplicationContext,N extends PathTreeNode>
      extends javax.swing.tree.DefaultTreeModel
      implements ApplicationObject<C>, Resettable

  This `TreeModel` implementation stores the `PathTreeNode`s of a file system tree which is watched by a watch-service and thus reflects any changes in the file-system immediately.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class javax.swing.tree.DefaultTreeModel

      `asksAllowsChildren, listenerList, root`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PathTreeModel(PathTreeModelDriver<C> driver, N rootTreeNode)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected N` | `createPathTreeNode(N parent, PathInfo childPathInfo)` Same as `createPathTreeNode(PathTreeNode, PathInfo, Comparator)` whereas the Comparator is just overtaken from the parent node.
    `protected N` | `createPathTreeNode(N parent, PathInfo childPathInfo, java.util.Comparator<PathTreeNode> comparator)` Creates the `PathTreeNode` to be inserted in the tree model.
    `N` | `findPathTreeNode(java.nio.file.Path path)`
    `N` | `findPathTreeNode(PathInfo pathInfo)`
    `javax.swing.tree.TreePath` | `findTreePath(java.nio.file.Path path)`
    `C` | `getApplicationContext()`
    `PathTreeNode` | `getChild(java.lang.Object parent, int index)`
    `int` | `getChildCount(java.lang.Object parent)`
    `PathTreeModelDriver` | `getDriver()`
    `int` | `getIndexOfChild(java.lang.Object parent, java.lang.Object child)`
    `N` | `getRoot()`
    `boolean` | `isLeaf(java.lang.Object node)`
    `void` | `renamePath(java.nio.file.Path oldPath, java.nio.file.Path newPath)`
    `void` | `reset()` Resets the root node of the tree.
    `void` | `setRoot(javax.swing.tree.TreeNode root)`

    - ### Methods inherited from class javax.swing.tree.DefaultTreeModel

      `addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getListeners, getPathToRoot, getPathToRoot, getTreeModelListeners, insertNodeInto, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, valueForPathChanged`

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

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

- - ### Constructor Detail

    - #### PathTreeModel

          public PathTreeModel(PathTreeModelDriver<C> driver,
                       N rootTreeNode)

  - ### Method Detail

    - #### getApplicationContext

          public C getApplicationContext()

      Specified by:
        `getApplicationContext` in interface `ApplicationObject<C extends ApplicationContext>`

    - #### getRoot

          public final N getRoot()

      Specified by:
        `getRoot` in interface `javax.swing.tree.TreeModel`
      Overrides:
        `getRoot` in class `javax.swing.tree.DefaultTreeModel`

    - #### getDriver

          public PathTreeModelDriver getDriver()

    - #### setRoot

          public final void setRoot(javax.swing.tree.TreeNode root)

      Overrides:
        `setRoot` in class `javax.swing.tree.DefaultTreeModel`

    - #### reset

          public final void reset()

      Resets the root node of the tree. This collapses the tree and forgets all its children.
      Specified by:
        `reset` in interface `Resettable`

    - #### getChild

          public PathTreeNode getChild(java.lang.Object parent,
                              int index)

      Specified by:
        `getChild` in interface `javax.swing.tree.TreeModel`
      Overrides:
        `getChild` in class `javax.swing.tree.DefaultTreeModel`

    - #### getChildCount

          public int getChildCount(java.lang.Object parent)

      Specified by:
        `getChildCount` in interface `javax.swing.tree.TreeModel`
      Overrides:
        `getChildCount` in class `javax.swing.tree.DefaultTreeModel`

    - #### isLeaf

          public boolean isLeaf(java.lang.Object node)

      Specified by:
        `isLeaf` in interface `javax.swing.tree.TreeModel`
      Overrides:
        `isLeaf` in class `javax.swing.tree.DefaultTreeModel`

    - #### getIndexOfChild

          public int getIndexOfChild(java.lang.Object parent,
                            java.lang.Object child)

      Specified by:
        `getIndexOfChild` in interface `javax.swing.tree.TreeModel`
      Overrides:
        `getIndexOfChild` in class `javax.swing.tree.DefaultTreeModel`

    - #### findPathTreeNode

          public final N findPathTreeNode(java.nio.file.Path path)

    - #### findPathTreeNode

          public final N findPathTreeNode(PathInfo pathInfo)

    - #### findTreePath

          public final javax.swing.tree.TreePath findTreePath(java.nio.file.Path path)

    - #### createPathTreeNode

          protected N createPathTreeNode(N parent,
                             PathInfo childPathInfo)

      Same as `createPathTreeNode(PathTreeNode, PathInfo, Comparator)` whereas the Comparator is just overtaken from the parent node.

    - #### createPathTreeNode

          protected N createPathTreeNode(N parent,
                             PathInfo childPathInfo,
                             java.util.Comparator<PathTreeNode> comparator)

      Creates the `PathTreeNode` to be inserted in the tree model. This method may be overridden to create a subclass instance of `PathTreeNode`. Note that this method needs to be overridden if a special PathTreeNode is desired.

    - #### renamePath

          public void renamePath(java.nio.file.Path oldPath,
                        java.nio.file.Path newPath)
                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.