| Graphic Components > Tree Component > Tree Component Services > Handling the Selection |
Handling the Selection |
INDEX
PREVIOUS
NEXT
|
The selection model requirements for an IlpTree are defined by the interface IlpTreeSelectionModel. This model extends the Swing TreeSelectionModel to provide convenience operations when working with business objects (IlpObject).
The selection model is responsible for setting, modifying, and retrieving the objects selected in the IlpTree.
The IlpTreeSelectionModel interface provides the following basic methods:
IlpObject instances,
This interface also has a number of advanced features described in Architecture of the Tree Component of this section.
IlpDefaultTreeSelectionModel is the default implementation of IlpTreeSelectionModel.
The following code shows you how to access the IlpTreeSelectionModel of an IlpTree.
IlpTree tree = ... //... // Retrieve the selection model IlpTreeSelectionModel selectionModel = tree.getSelectionModel();
The following code shows you how to retrieve the selected IlpObject instances from the selection model.
Collection selection = selectionModel.getSelectedObjects();
Iterator it = selection.iterator();
while (it.hasNext()) {
IlpObject node = (IlpObject)it.next();
// Do what you want with the selected node
// ...
}
The sample <installdir>/samples/tree/basic demonstrates the use of the selection model.
The IlpTree allows you to choose between the look-and-feel for the selection:
HIGHLIGHT_SELECTION_LOOK_AND_FEEL: the standard mode, where a selected cell appears highlighted.
CHECKBOX_SELECTION_LOOK_AND_FEEL: in this mode, a check box is displayed next to each tree node. A check mark indicates that the corresponding node is selected. Clicking a check box or a cell switches the selection state of the corresponding node. In this mode, the highlighting only indicates which cell has the focus.| Note |
| In this mode, collapsing a node does not deselect its descendants. |
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |