Configuring the tree component through the API

For details of the classes involved in the architecture of the tree component, see Architecture of the tree component.
For details about programming the individual services of a tree component, see Tree component services .

How to configure the tree view with the API

The following code sample shows how to configure the tree view ( IlpTreeView) through the API.
IlpTreeView view = tree.getView();

// Setting the selection mode
view.setSelectionLookAndFeel(IlpTreeView.HIGHLIGHT_SELECTION_LOOK_AND_FEEL);

// Setting the tree cell renderer
view.setCellRenderer(new MyTreeCellRenderer());

// Setting the background color
view.setBackground(Color.white);

How to configure the tree view interactor with the API

The following code sample shows how to configure the tree view interactor through the API. For details of this interactor, see Interacting with the tree view.
IlpTree tree = // ...
// Retrieve the view interactor
IlpViewInteractor viewInteractor = tree.getViewInteractor();
// Create an action
Action myAction = new MyAction();
// Clicking the 3rd mouse button will trigger myAction
viewInteractor.setGestureAction(IlpGesture.BUTTON3_CLICKED,myAction);

How to configure the tree adapter with the API

The following code sample shows how to configure the tree adapter ( IlpAbstractTreeAdapter) through the API.
IlpAbstractTreeAdapter adapter = tree.getAdapter();

// Setting the filter
IlpFilter myFilter = new MyFilter();
// (it is the same as tree.setFilter(myFilter)
adapter.setFilter(myFilter);

// Origin
List myOrigins = new ArrayList();
myOrigins.add(objectID_1);
myOrigins.add(objectID_2);
.
.
.
myOrigins.add(objectID_n);
// in this case we want to display the
// origins
boolean showOrigin = true;
adapter.setOrigins(myOrigins, showOrigin);

// Expansion Strategy Factory
// Usually the expansion strategy factory relies
// on the adapter to access the data source and to
// load/release objects
IlpExpansionStrategyFactory myExpFactory = new
   MyExpansionStrategyFactory(adapter);
adapter.setExpansionStrategyFactory(myExpFactory);

// Tree Node Factory
IlpTreeNodeFactory myNodeFactory = new MyTreeNodeFactory();
adapter.setNodeFactory(myNodeFactory);
// Setting the object attribute value changed event filter IlpFilter
myEventFilter = new MyEventFilter();
adapter.setObjectAttributeChangedFilter(myEventFilter);