4

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?

Debajit
  • 46,327
  • 33
  • 91
  • 100

2 Answers2

7
List elementsToSelect = ...
dialog.setInitialElementSelections(elementsToSelect);
James Van Huis
  • 5,481
  • 1
  • 26
  • 25
0

You can subclass the ListSelectionDialog and add this method:

public void selectAll() {
    getViewer().setAllChecked(true);
}
ElOjcar
  • 301
  • 2
  • 4
  • 12