The model

The tree model provides the representation objects to be displayed in the tree component. It can be connected to a back-end application by means of an adapter.
The representation model of the JViews TGO tree component includes the following classes:
  • IlpTreeModel is a container of the tree representation objects that implements the characteristics specific to the JViews TGO tree model.
  • IlpTreeNode defines the requirements associated with a node in an   IlpTreeModel. IlpDefaultTreeNode is the default implementation of IlpTreeNode .
    Note
    IlpTreeModel has a predefined root node that you should not remove. The IlpTreeView automatically hides this node. Consequently, you cannot use the setRoot() method of IlpTreeModel to modify the model. A convenient clear() method removes all the nodes in a single operation, except the root node.

Integration with the back-end

If the tree is to be connected to a back-end application, a data source and an adapter must be instantiated. The adapter translates insertions, removals, and updates of IlpObject instances in the data source into insertions, removals, and updates of IlpTreeNode instances in the tree model.The adapter must be connected both to the data source and to the tree model.
The tree automatically creates an appropriate adapter (of class IlpContainmentTreeAdapter). If you want to use a different adapter, you will need to create one and connect it to both the data source and the tree component. The adapter must be an instance of a subclass of IlpAbstractTreeAdapter.
The following code connects an IltDefaultDataSource to an IlpTree by means of a custom adapter.

How to connect a data source to a tree Component with a custom adapter

IlpTree ilpTree = new IlpTree();
IltDefaultDataSource dataSource = new IltDefaultDataSource();
// Create an instance of a custom adapter
MyAdapter adapter = new MyAdapter(tree.getContext());
// Connect the adapter to the data source
adapter.setDataSource(dataSource);
// Connect the adapter to the tree component
ilpTree.setAdapter(adapter);
For more information about data sources, refer to Introducing business objects and data sources. For more information about adapters, refer to Architecture of graphic components.