| The Essential JViews Framework > Managers > Selection in a Manager > Listener for the Selections in a Manager |
Listener for the Selections in a Manager |
INDEX
PREVIOUS
NEXT
|
A class must implement the ManagerSelectionListener interface to be notified that selections in a manager have been modified. This interface contains only the selectionChanged method, which is called each time an object is selected or deselected.
void selectionChanged(ManagerSelectionChangedEvent event)
To be notified of selections and deselections, a class must register itself using the following method of the class IlvManager:
void addManagerSelectionListener(ManagerSelectionListener l)
Note that the selectionChanged method is called just after the object is selected or deselected, so you can easily determine whether it is a selection or a deselection. You do this the following way:
When numerous objects are being selected, for example, as a result of the call to the selectAll method of the manager, many selection events will be sent to the selection listeners. This can be inefficient for some listeners that need to perform an action when the selection is stable. For example, a property inspector showing the properties of selected objects does not need to be updated for each individual selection when a number of objects are selected at the same time. To solve this kind of problem, the ManagerSelectionChangedEvent class has the:
isAdjusting method that tells you if the event is part of a series of selection events.
isAdjustmentEnd method which indicates that the event is the last one of a series.
In the case of our "property inspector," the listener would be as follows:
You may want to use the same "adjustment" notification when selecting numerous objects in a manager. The IlvManager class allows you to do this using the setSelectionAdjusting method:
boolean isAdjusting = manager.isSelectionAdjusting(); manager.setSelectionAdjusting(true); try { // select or deselect a lot of objects. } finally { manager.setSelectionAdjusting(isAdjusting); } |
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |