1 package net.sourceforge.phpdt.internal.ui.dialogs;
3 import java.util.Arrays;
6 import org.eclipse.jface.viewers.ILabelProvider;
7 import org.eclipse.swt.widgets.Composite;
8 import org.eclipse.swt.widgets.Control;
9 import org.eclipse.swt.widgets.Shell;
12 * A class to select elements out of a list of elements.
14 public class ElementListSelectionDialog extends AbstractElementListSelectionDialog {
16 private Object[] fElements;
19 * Creates a list selection dialog.
20 * @param parent the parent widget.
21 * @param renderer the label renderer.
23 public ElementListSelectionDialog(Shell parent, ILabelProvider renderer) {
24 super(parent, renderer);
28 * Sets the elements of the list.
29 * @param elements the elements of the list.
31 public void setElements(Object[] elements) {
36 * @see SelectionStatusDialog#computeResult()
38 protected void computeResult() {
39 setResult(Arrays.asList(getSelectedElements()));
43 * @see Dialog#createDialogArea(Composite)
45 protected Control createDialogArea(Composite parent) {
46 Composite contents= (Composite) super.createDialogArea(parent);
48 createMessageArea(contents);
49 createFilterText(contents);
50 createFilteredList(contents);
52 setListElements(fElements);
54 List initialSelections= getInitialSelections();
55 if (initialSelections != null)
56 setSelection(initialSelections.toArray());