List<RosterEntryElement> checkedElements = ArrayUtils
.getAdaptableObjects(treeViewer.getCheckedElements(),
RosterEntryElement.class);
List<RosterEntryElement> elementsToCheck = new ArrayList<RosterEntryElement>();
for (JID buddy : buddies) {
elementsToCheck.add(new RosterEntryElement(saros.getSarosNet()
.getRoster(), buddy));
}
Map<RosterEntryElement, Boolean> checkStatesChanges = calculateCheckStateDiff(
allElements, checkedElements, elementsToCheck);
/*
* Update the check state in the RosterCheckStateProvider
*/
for (Entry<RosterEntryElement, Boolean> entryElement : checkStatesChanges
.entrySet()) {
RosterEntryElement rosterEntryElement = entryElement.getKey();
boolean checked = checkStatesChanges.get(rosterEntryElement);
this.checkStateProvider.setChecked(rosterEntryElement, checked);
}
/*
* Refresh the viewer in order to reflect the new check states.
*/
treeViewer.refresh();
/*
* Fire events
*/
for (Entry<RosterEntryElement, Boolean> entryElement : checkStatesChanges
.entrySet()) {
RosterEntryElement rosterEntryElement = entryElement.getKey();
boolean checked = checkStatesChanges.get(rosterEntryElement);
this.notifyBuddySelectionChanged(
(JID) rosterEntryElement.getAdapter(JID.class), checked);
}
}