JFace question: How do I select all items in a ListSelectionDialog?
-
20-08-2019 - |
Question
I create a JFace ListSelectionDialog as follows.
final ListSelectionDialog dialog = new ListSelectionDialog(
PlatformUI.getWorkbench().getDisplay().getActiveShell(),
List<SomeClass>,
new ArrayContentProvider(),
new LabelProvider(),
""); //$NON-NLS-1$
dialog.setTitle("Dialog Title"); //$NON-NLS-1$
dialog.setMessage("SomeMessage"); //$NON-NLS-1$
dialog.open();
and the dialog shows up fine.
However, I'd like all the checkboxes to be selected. How do I do that?
Solution
List elementsToSelect = ...
dialog.setInitialElementSelections(elementsToSelect);
OTHER TIPS
You can subclass the ListSelectionDialog and add this method:
public void selectAll() {
getViewer().setAllChecked(true);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow