The tree component takes by default as root nodes all the objects
in the data source that do not have a parent. However, you can
explicitly select the root nodes to be displayed through the
adapter that forms a bridge between the data source and the tree
component. To retrieve the adapter, use the
getAdapter method. The adapter for the tree
component must be an instance of a subclass of
IlpAbstractTreeAdapter.
The root nodes can be changed by modifying the list of
origins for the adapter. These origins are
set and retrieved as
IlpObject identifiers.
The method
getOrigins
allows you to get the list of current origins. The method
isShowingOrigin
indicates whether the origins themselves or their child objects are
represented as root nodes. By default, the list of origins is empty
and the origins are not shown, which means that all objects without
a parent are shown as root nodes. Thus, the entire contents of the
data source are displayed in the tree.
Note
The origins are specified using identifiers, not the
IlpObject
instances. You can retrieve the identifier of an
IlpObject with the
getIdentifier method of the object.
To change the list of origins, use the
setOrigins
method. This method takes a list of business object identifiers as
its first parameter. Its second parameter is a Boolean flag that
indicates whether or not the origins themselves should be shown as
root nodes.
Calling this method with an empty list and the second parameter set
to
true
empties the tree:
setOrigins(Collections.EMPTY_LIST, true);
Calling the method with an empty list and the second parameter set
to
false
restores the default; that is, all the objects in the data source
are shown:
setOrigins(Collections.EMPTY_LIST, false);
How to show an object as the root node of
a tree
To show only a given
IlpObject as the root node of a tree, use
the following code:
IlpTree tree = ....;
IlpObject originObject = .....;
java.util.List originList = new ArrayList();
originList.add(originObject.getIdentifier());
tree.getAdapter().setOrigins(originList, true);