Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tonbeller.wcf.tree
Class MutableTreeModelDecorator

    java.lang.Object
      com.tonbeller.wcf.tree.MutableTreeModelDecorator

All Implemented Interfaces:
  ChangeOrderModel, DecoratedTreeModel, MutableTreeModel, TreeModel

public class MutableTreeModelDecorator
extends java.lang.Object
implements DecoratedTreeModel, MutableTreeModel, ChangeOrderModel

a caching TreeModel that allows to change the parent/child relationship.

Author:
  av

Field Summary

Fields inherited from interface com.tonbeller.wcf.tree.TreeModel
`EMPTY_MODEL`

Constructor Summary
`MutableTreeModelDecorator(TreeModel decoree)`
`MutableTreeModelDecorator(TreeModel decoree, java.util.Comparator comp)`

Method Summary
`void` | `addTreeModelChangeListener(TreeModelChangeListener l)`
`void` | `change(java.lang.Object parent, java.lang.Object[] children)` changes the parent / child relationship so that future calls to getChildren(parent) will return children
`void` | `fireModelChanged(boolean identityChanged)` fires a TreeModelChangeEvent.
`java.lang.Object[]` | `getChildren(java.lang.Object node)`
`TreeModel` | `getDecoree()`
`java.lang.Object` | `getParent(java.lang.Object node)`
`java.lang.Object[]` | `getRoots()` returns the root members of the tree.
`boolean` | `hasChildren(java.lang.Object node)`
`boolean` | `isEnableChangeOrder()` if enabled, changeOrder will be allowed
`boolean` | `mayMove(java.lang.Object scope, java.lang.Object node)` returns true, if node may be moved
`void` | `move(java.lang.Object scope, java.lang.Object node, int oldIndex, int newIndex)` called after the user has clicked on an item to move it.
`void` | `removeTreeModelChangeListener(TreeModelChangeListener l)`
`void` | `setDecoree(TreeModel newDecoree)` registers a changeListener with the newDecoree
`void` | `setEnableChangeOrder(boolean enableChangeOrder)` if enabled, changeOrder will be allowed

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MutableTreeModelDecorator

    public MutableTreeModelDecorator(TreeModel decoree)

### MutableTreeModelDecorator

    public MutableTreeModelDecorator(TreeModel decoree,
                                     java.util.Comparator comp)

Method Detail

### setDecoree

    public void setDecoree(TreeModel newDecoree)

  registers a changeListener with the newDecoree

### getDecoree

    public TreeModel getDecoree()

  Specified by:
    `getDecoree` in interface `DecoratedTreeModel`

### change

    public void change(java.lang.Object parent,
                       java.lang.Object[] children)

  Description copied from interface: `MutableTreeModel`
  changes the parent / child relationship so that future calls to getChildren(parent) will return children

  Specified by:
    `change` in interface `MutableTreeModel`
  Parameters:
    `parent` - the parent node or null to change the root node(s)
    `children` - the new children of parent. If children is an empty array, future calls to hasChildren(parent) will return true, and getChildren(parent) will return the empty array. If children is null, future calls to hasChildren(parent) will return false.

### getRoots

    public java.lang.Object[] getRoots()

  Description copied from interface: `TreeModel`
  returns the root members of the tree.

  Specified by:
    `getRoots` in interface `TreeModel`

### hasChildren

    public boolean hasChildren(java.lang.Object node)

  Specified by:
    `hasChildren` in interface `TreeModel`
  Returns:
    true if the member can be expanded

### getChildren

    public java.lang.Object[] getChildren(java.lang.Object node)

  Specified by:
    `getChildren` in interface `TreeModel`
  Returns:
    the children of the member

### getParent

    public java.lang.Object getParent(java.lang.Object node)

  Specified by:
    `getParent` in interface `TreeModel`
  Returns:
    the parent of member or null, if this is a root member

### mayMove

    public boolean mayMove(java.lang.Object scope,
                           java.lang.Object node)

  Description copied from interface: `ChangeOrderModel`
  returns true, if node may be moved

  Specified by:
    `mayMove` in interface `ChangeOrderModel`

### move

    public void move(java.lang.Object scope,
                     java.lang.Object node,
                     int oldIndex,
                     int newIndex)

  Description copied from interface: `ChangeOrderModel`
  called after the user has clicked on an item to move it. The element at `oldIndex` is removed from the array, so the size of the array is reduced by one. After that, the element is inserted at the index `newIndex`. A valid implementation would be:

         ArrayList al = ...
         Object o = al.remove(oldIndex);
         al.add(newIndex, o);

  Specified by:
    `move` in interface `ChangeOrderModel`
  Parameters:
    `scope` - the scope for the node to move (for convenience).
    `node` - the node to move (for convenience), which lives at position oldIndex
    `oldIndex` - the index of `item` before it was moved
    `newIndex` - the index of `item` after it has been moved
  See Also:
    `ChangeOrderUtils`

### isEnableChangeOrder

    public boolean isEnableChangeOrder()

  if enabled, changeOrder will be allowed

  Returns:
    boolean

### setEnableChangeOrder

    public void setEnableChangeOrder(boolean enableChangeOrder)

  if enabled, changeOrder will be allowed

  Parameters:
    `enableChangeOrder` - The enableChangeOrder to set

### fireModelChanged

    public void fireModelChanged(boolean identityChanged)

  Description copied from interface: `TreeModel`
  fires a TreeModelChangeEvent.

  Specified by:
    `fireModelChanged` in interface `TreeModel`
  Parameters:
    `identityChanged` - if true, the identities of the tree nodes have changed and, for example, the selection will be cleared.

### addTreeModelChangeListener

    public void addTreeModelChangeListener(TreeModelChangeListener l)

  Specified by:
    `addTreeModelChangeListener` in interface `TreeModel`

### removeTreeModelChangeListener

    public void removeTreeModelChangeListener(TreeModelChangeListener l)

  Specified by:
    `removeTreeModelChangeListener` in interface `TreeModel`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD