org.netbeans.spi.viewmodel/2 1.32.1

org.netbeans.spi.viewmodel
Interface TreeModel

All Superinterfaces:
Model
All Known Subinterfaces:
ReorderableTreeModel
All Known Implementing Classes:
Models.CompoundModel

public interface TreeModel
extends Model

Defines data model for tree.


Field Summary
static String ROOT
          Constant for root node.
 
Method Summary
 void addModelListener(ModelListener l)
          Registers given listener.
 Object[] getChildren(Object parent, int from, int to)
          Returns children for given parent on given indexes.
 int getChildrenCount(Object node)
          Returns the number of children for given node.
 Object getRoot()
          Returns the root node of the tree or null, if the tree is empty.
 boolean isLeaf(Object node)
          Returns true if node is leaf.
 void removeModelListener(ModelListener l)
          Unregisters given listener.
 

Field Detail

ROOT

static final String ROOT
Constant for root node. This root node should be used if root node does not represent any valuable information and should not be visible in tree.

See Also:
Constant Field Values
Method Detail

getRoot

Object getRoot()
Returns the root node of the tree or null, if the tree is empty.

Returns:
the root node of the tree or null

getChildren

Object[] getChildren(Object parent,
                     int from,
                     int to)
                     throws UnknownTypeException
Returns children for given parent on given indexes.

This method works in pair with getChildrenCount(java.lang.Object), the to parameter is up to the value that is returned from getChildrenCount(java.lang.Object). If the list of children varies over time, the implementation code needs to pay attention to bounds and check the from and to parameters, especially if getChildrenCount(java.lang.Object) returns Integer.MAX_VALUE. Caching of the children between getChildrenCount(java.lang.Object) and getChildren(java.lang.Object, int, int) can be used as well, if necessary.

Parameters:
parent - a parent of returned nodes
from - a start index
to - a end index
Returns:
children for given parent on given indexes
Throws:
UnknownTypeException - if this TreeModel implementation is not able to resolve children for given node type
See Also:
getChildrenCount(java.lang.Object)

isLeaf

boolean isLeaf(Object node)
               throws UnknownTypeException
Returns true if node is leaf.

Returns:
true if node is leaf
Throws:
UnknownTypeException - if this TreeModel implementation is not able to resolve dchildren for given node type

getChildrenCount

int getChildrenCount(Object node)
                     throws UnknownTypeException
Returns the number of children for given node.

This method works in pair with getChildren(java.lang.Object, int, int), which gets this returned value (or less) as the to parameter. This method is always called before a call to getChildren(java.lang.Object, int, int). This method can return e.g. Integer.MAX_VALUE when all children should be loaded.

Parameters:
node - the parent node
Returns:
the children count
Throws:
UnknownTypeException - if this TreeModel implementation is not able to resolve children for given node type
Since:
1.1
See Also:
getChildren(java.lang.Object, int, int)

addModelListener

void addModelListener(ModelListener l)
Registers given listener.

Parameters:
l - the listener to add

removeModelListener

void removeModelListener(ModelListener l)
Unregisters given listener.

Parameters:
l - the listener to remove

org.netbeans.spi.viewmodel/2 1.32.1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.