* Sets the currently selected {@link IProject}s.
*
* @param projects
*/
public void setSelectedProjects(List<IProject> projects) {
CheckboxTableViewer checkboxTableViewer = (CheckboxTableViewer) this.viewer;
IStructuredContentProvider structuredContentProvider = (IStructuredContentProvider) checkboxTableViewer
.getContentProvider();
Object[] allElements = structuredContentProvider
.getElements(checkboxTableViewer.getInput());
Object[] checkedElements = checkboxTableViewer.getCheckedElements();
List<IProject> allProjects = ArrayUtils.getAdaptableObjects(
allElements, IProject.class);
List<IProject> checkedProjects = ArrayUtils.getAdaptableObjects(
checkedElements, IProject.class);
Map<IProject, Boolean> checkStatesChanges = calculateCheckStateDiff(
allProjects, checkedProjects, projects);
/*
* Does not fire events...
*/
checkboxTableViewer.setCheckedElements(projects.toArray());
/*
* ... therefore we have to fire them.
*/
for (Map.Entry<IProject, Boolean> entry : checkStatesChanges.entrySet())