group.setText(name);
return group;
}
private ContainerCheckedTreeViewer createTree(Composite parent, int style) {
final ContainerCheckedTreeViewer viewer = new ContainerCheckedTreeViewer(parent, style | SWT.SINGLE | SWT.BORDER
| SWT.V_SCROLL | SWT.H_SCROLL | SWT.RESIZE) {
/**
* Overriden to re-set checked state of elements after filter change
*/
@Override
public void refresh(boolean updateLabels) {
super.refresh(updateLabels);
setCheckedElements(checkedElements);
}
};
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(labelProvider);
viewer.setInput(allowedTypes);
Object[] preselected = getPreselected();
viewer.setCheckedElements(preselected);
viewer.addPostSelectionChangedListener(new TreeSelectionChangedListener());
viewer.getTree().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
updateDescription((IStructuredSelection) viewer.getSelection());
}
});
viewer.addCheckStateListener(new TreeCheckStateListener());
return viewer;
}