Having read this link, I want to create a dialog where I can select multiple items which to be in the form of check boxes.
ElementListSelectionDialog
doesn't show any elements in the dialog.
final ElementListSelectionDialog dialog = new ElementListSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), new LabelProvider());
dialog.setElements(new String[] { "1", "2", "3" });
dialog.setTitle("Numbers");
dialog.setMultipleSelection(true);
dialog.setInitialSelections(new String[] { "1", "2", "3" });
dialog.open();
Using the code above, I get the items in the dialog sometimes, but there are two problems:
If you know a better way of doing this, please let me know. I really appreciate any help :)
ElementListSelectionDialog
does not support check box selection.
You may be able to use org.eclipse.ui.dialogs.ListSelectionDialog
:
String [] elements = ...
ListSelectionDialog dialog =
new ListSelectionDialog(shell, elements, ArrayContentProvider.getInstance(),
new LabelProvider(), "selection message");
dialog.setTitle("dialog title");
dialog.setInitialSelections(new Object []{....selections});
dialog.open();
Object [] result = dialog.getResult();
or you can always write your own dialog using CheckboxTableViewer
.