When creating a JFace TreeViewer
, one can use the SWT constants to set single or multiple selections allowed for the user to the tree items (SWT.SINGLE
or SWT.MULTI
).
Can anyone help me please as I want a tree that its items can not be selected at all? I want it as for preview purpose and user should not be able to select an item there.
Many thanks in advance,
I don't really understand why do you want to suppress the selection, but this is how it may work:
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
v.setSelection(StructuredSelection.EMPTY);
}
}
});
In addition to this I would make sure that the viewer: