I create a JFace ListSelectionDialog as follows.
我创建了一个JFace ListSelectionDialog,如下所示。
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?
但是,我想要选中所有复选框。我怎么做?
2 个解决方案
#1
List elementsToSelect = ...
dialog.setInitialElementSelections(elementsToSelect);
#2
You can subclass the ListSelectionDialog and add this method:
您可以继承ListSelectionDialog并添加此方法:
public void selectAll() {
getViewer().setAllChecked(true);
}
#1
List elementsToSelect = ...
dialog.setInitialElementSelections(elementsToSelect);
#2
You can subclass the ListSelectionDialog and add this method:
您可以继承ListSelectionDialog并添加此方法:
public void selectAll() {
getViewer().setAllChecked(true);
}