JFace Question: How to 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 dialogue is displayed well.

However, I would like all the checkboxes to be selected. How to do it?

+4
source share
2 answers
 List elementsToSelect = ... dialog.setInitialElementSelections(elementsToSelect); 
+7
source

You can subclass ListSelectionDialog and add this method:

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

Source: https://habr.com/ru/post/1286768/


All Articles