com.dlsc.flexgantt.model.treetable

## Class DefaultTreeTableModel<T extends ITreeTableNode>

- java.lang.Object
- - javax.swing.tree.DefaultTreeModel
  - - com.dlsc.flexgantt.model.treetable.DefaultTreeTableModel<T>

- Type Parameters:
    `T` - the type of the hierarchy nodes
  All Implemented Interfaces:
    ITreeTableModel<T>, Serializable, TreeModel
  Direct Known Subclasses:
    DefaultGanttChartModel

      public class DefaultTreeTableModel<T extends ITreeTableNode>
      extends DefaultTreeModel
      implements ITreeTableModel<T>

  The framework's default implementation of `ITreeTableModel`.
  Since:
    1.0
  Version:
    $Revision: 1.17 $
  Author:
    Dirk Lemmermann
  See Also:
    Serialized Form

- - ### Field Summary

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

      `asksAllowsChildren, listenerList, root`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultTreeTableModel(T root)` Constructs a new tree table model with the given root node.
    `DefaultTreeTableModel(T root, boolean asksAllowsChildren)` Constructs a new tree table model.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addTreeTableModelListener(ITreeTableModelListener l)` Adds a listener to the model, which will be informed when key or column values get changes.
    `protected void` | `fireTreeNodeKeyChanged(Object[] path, Object oldKey, Object newKey)` Fires a `TreeTableModelEvent` when a node's key value was changed.
    `protected void` | `fireTreeNodeValuesChanged(Object[] path, Object oldValue, Object newValue, int columnModelIndex)` Fires a `TreeTableModelEvent` when a node's column value was changed.
    `Object` | `getColumnValue(T node, int index)` Returns an object for the given node that will be displayed in a tree table column where the column's model index matches the given index.
    `Object` | `getKey(T node)` Returns an object for the given node that will be displayed in the tree table's key column.
    `T` | `getRoot()`
    `Object` | `getRowHeaderValue(T node)` Returns an object that will be visualized in the row header section of the Gantt chart.
    `void` | `removeTreeTableModelListener(ITreeTableModelListener l)` Removes a listener from the model.
    `void` | `setColumnValue(T node, Object newValue, int columnModelIndex)` Sets a new column value for the given node and model index.
    `void` | `setKey(T node, Object newKey)` Sets a new object to be used as the key object for the given tree table node.
    `void` | `setRoot(T root)` Overrides the parent method in order to implement type safety via the use of Generics.
    `void` | `setRoot(TreeNode node)` Deprecated.
    `void` | `setRowHeaderValue(T node, Object value)` Sets the value used for the row header.
    `void` | `sort()` Sorts the entire tree based on the key column and in ascending order.
    `void` | `sort(T node)` Sorts the given node#s children based on the key column and in ascending order.
    `void` | `sort(T node, int[] modelIndices)` Sorts the children of a node based on the given model indices and in ascending order.
    `void` | `sort(T node, int[] modelIndices, boolean[] sortDirection)` Invokes multi-column sorting on the tree table model.

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

      `addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getTreeModelListeners, insertNodeInto, isLeaf, 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`

    - ### Methods inherited from interface javax.swing.tree.TreeModel

      `addTreeModelListener, getChild, getChildCount, getIndexOfChild, isLeaf, removeTreeModelListener, valueForPathChanged`

- - ### Constructor Detail

    - #### DefaultTreeTableModel

          public DefaultTreeTableModel(T root)

      Constructs a new tree table model with the given root node. Creates a model in which any node can have children.
      Parameters:
        `root` - the model's root object
      Since:
        1.0

    - #### DefaultTreeTableModel

          public DefaultTreeTableModel(T root,
                                       boolean asksAllowsChildren)

      Constructs a new tree table model.
      Parameters:
        `root` - the model's root object
        `asksAllowsChildren` - a boolean, false if any node can have children, true if each node is asked to see if it can have children
      Since:
        1.0

  - ### Method Detail

    - #### getKey

          public Object getKey(T node)

      Description copied from interface: `ITreeTableModel`
      Returns an object for the given node that will be displayed in the tree table's key column.
      Specified by:
        `getKey` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `node` - the tree table's node for which to return a key object
      Returns:
        the key column object
      See Also:
        `ITreeTableModel.setKey(Object, Object)`

    - #### setKey

          public void setKey(T node,
                             Object newKey)

      Description copied from interface: `ITreeTableModel`
      Sets a new object to be used as the key object for the given tree table node.
      Specified by:
        `setKey` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `node` - the node for which to specify a new key object
        `newKey` - the node's new key object
      See Also:
        `ITreeTableModel.getKey(Object)`

    - #### getColumnValue

          public Object getColumnValue(T node,
                                       int index)

      Description copied from interface: `ITreeTableModel`
      Returns an object for the given node that will be displayed in a tree table column where the column's model index matches the given index.

      It is very important to note the difference between the model index and a columns index within a given column model. The model index usually never changes and is used to lookup the correct piece of information from some kind of data model. The other index is simply the columns current position within the model. This index can change if the user or the application rearranges the columns.
      Specified by:
        `getColumnValue` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `node` - the node for which to return a column value object
        `index` - the column's model index
      Returns:
        a value for the given node and model index
      See Also:
        `ITreeTableModel.setColumnValue(Object, Object, int)`

    - #### setColumnValue

          public void setColumnValue(T node,
                                     Object newValue,
                                     int columnModelIndex)

      Description copied from interface: `ITreeTableModel`
      Sets a new column value for the given node and model index.

      It is very important to note the difference between the model index and a columns index within a given column model. The model index usually never changes and is used to lookup the correct piece of information from some kind of data model. The other index is simply the columns current position within the model. This index can change if the user or the application rearranges the columns.

      Specified by:
        `setColumnValue` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `node` - the node that will receive a new column value
        `newValue` - the new column value
        `columnModelIndex` - the model index that will get changed
      See Also:
        `ITreeTableModel.getColumnValue(Object, int)`, `INodeEditPolicy.isValueEditable(Object, ITreeTableModel, int)`, `INodeEditPolicy.getChangeValueCommand(Object, ITreeTableModel, Object, int)`

    - #### getRowHeaderValue

          public Object getRowHeaderValue(T node)

      Description copied from interface: `ITreeTableModel`
      Returns an object that will be visualized in the row header section of the Gantt chart. This method is not allowed to return NULL. The default Gantt chart model implementation returns the node itself if no extra row header value is specified.
      Specified by:
        `getRowHeaderValue` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `node` - the node for which to return a header value
      Returns:
        an object that will be visualized in the row header

    - #### setRowHeaderValue

          public void setRowHeaderValue(T node,
                                        Object value)

      Sets the value used for the row header. This value can be picked up by the row header renderer in order to achieve a customized appearance.
      Parameters:
        `node` - the tree node
        `value` - the row header value
      Since:
        1.0
      See Also:
        `getRowHeaderValue(ITreeTableNode)`

    - #### addTreeTableModelListener

          public void addTreeTableModelListener(ITreeTableModelListener l)

      Description copied from interface: `ITreeTableModel`
      Adds a listener to the model, which will be informed when key or column values get changes.
      Specified by:
        `addTreeTableModelListener` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `l` - the listener to add
      See Also:
        `ITreeTableModel.removeTreeTableModelListener(ITreeTableModelListener)`

    - #### removeTreeTableModelListener

          public void removeTreeTableModelListener(ITreeTableModelListener l)

      Description copied from interface: `ITreeTableModel`
      Removes a listener from the model.
      Specified by:
        `removeTreeTableModelListener` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `l` - the listener to remove
      See Also:
        `ITreeTableModel.addTreeTableModelListener(ITreeTableModelListener)`

    - #### fireTreeNodeKeyChanged

          protected void fireTreeNodeKeyChanged(Object[] path,
                                                Object oldKey,
                                                Object newKey)

      Fires a `TreeTableModelEvent` when a node's key value was changed.
      Parameters:
        `path` - the path to the node that was changed
        `oldKey` - the old key value
        `newKey` - the new key value
      Since:
        1.0

    - #### fireTreeNodeValuesChanged

          protected void fireTreeNodeValuesChanged(Object[] path,
                                                   Object oldValue,
                                                   Object newValue,
                                                   int columnModelIndex)

      Fires a `TreeTableModelEvent` when a node's column value was changed.
      Parameters:
        `path` - the path to the node that was changed
        `oldValue` - the old column value
        `newValue` - the new column value
        `columnModelIndex` - the column's model index
      Since:
        1.0

    - #### sort

          public void sort()

      Sorts the entire tree based on the key column and in ascending order.
      Since:
        1.0
      See Also:
        `sort(ITreeTableNode)`, `sort(ITreeTableNode, int[])`, `sort(ITreeTableNode, int[], boolean[])`

    - #### sort

          public void sort(T node)

      Sorts the given node#s children based on the key column and in ascending order.
      Parameters:
        `node` - the parent of the nodes that will be sorted
      Since:
        1.0
      See Also:
        `sort()`, `sort(ITreeTableNode, int[])`, `sort(ITreeTableNode, int[], boolean[])`

    - #### sort

          public void sort(T node,
                           int[] modelIndices)

      Sorts the children of a node based on the given model indices and in ascending order.
      Parameters:
        `node` - the parent of the nodes that will be sorted
        `modelIndices` - the model indices on which to sort
      Since:
        1.0
      See Also:
        `sort()`, `sort(ITreeTableNode)`, `sort(ITreeTableNode, int[], boolean[])`

    - #### sort

          public void sort(T node,
                           int[] modelIndices,
                           boolean[] sortDirection)

      Description copied from interface: `ITreeTableModel`
      Invokes multi-column sorting on the tree table model. Each column can be sorted in ascending or descending order. The lengths of the two parameters arrays need to be equal.
      Specified by:
        `sort` in interface `ITreeTableModel<T extends ITreeTableNode>`
      Parameters:
        `node` - the node that is the target of the sort, the node's children will be sorted (if the node is the root then the entire table will be sorted)
        `modelIndices` - the model indices that are used to determine which column values to compare for sorting (use `KeyColumn.MODEL_INDEX` to specify a sort based on the key column
        `sortDirection` - if TRUE the sort direction will be ascending

    - #### setRoot

          @Deprecated
          public void setRoot(TreeNode node)

      Deprecated.
      Overrides:
        `setRoot` in class `DefaultTreeModel`

    - #### setRoot

          public void setRoot(T root)

      Overrides the parent method in order to implement type safety via the use of Generics.
      Parameters:
        `root` - the typed root object
      Since:
        1.0
      See Also:
        `getRoot()`

    - #### getRoot

          public T getRoot()

      Specified by:
        `getRoot` in interface `TreeModel`
      Overrides:
        `getRoot` in class `DefaultTreeModel`

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.