Debajit
Debajit

Reputation: 47101

JFace question: How do I select all items in a ListSelectionDialog?

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?

Upvotes: 4

Views: 1331

Answers (2)

ElOjcar
ElOjcar

Reputation: 301

You can subclass the ListSelectionDialog and add this method:

public void selectAll() {
    getViewer().setAllChecked(true);
}

Upvotes: 0

James Van Huis
James Van Huis

Reputation: 5561

List elementsToSelect = ...
dialog.setInitialElementSelections(elementsToSelect);

Upvotes: 7

Related Questions