By default, all the objects in the data source that do not have a
parent are treated as root nodes by the network component. However,
you can explicitly select the root nodes to be displayed through
the adapter that forms a bridge between the data source and the
network component. To retrieve the adapter, use the
getAdapter method. The adapter must be an
instance of a subclass of
IlpAbstractNodeAdapter.
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 network adapter
has two options: either the origins are represented as root nodes,
or they are hidden and their child objects are represented as root
nodes.
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 network.
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 network:
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 network
To show only a given
IlpObject as the root node of a network,
use the following code:
IlpNetwork network = ....;
IlpObject originObject = .....;
java.util.List originList = new ArrayList();
originList.add(originObject.getIdentifier());
network.getAdapter().setOrigins(originList, true);