207fd6f0cf8ba71c41e9fea59e920d1ee9ad7bc0
[phpeclipse.git] /
1 package net.sourceforge.phpdt.internal.ui.dialogs;
2
3 import java.util.Arrays;
4 import java.util.List;
5
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;
10
11 /**
12  * A class to select elements out of a list of elements.
13  */
14 public class ElementListSelectionDialog extends
15                 AbstractElementListSelectionDialog {
16
17         private Object[] fElements;
18
19         /**
20          * Creates a list selection dialog.
21          * 
22          * @param parent
23          *            the parent widget.
24          * @param renderer
25          *            the label renderer.
26          */
27         public ElementListSelectionDialog(Shell parent, ILabelProvider renderer) {
28                 super(parent, renderer);
29         }
30
31         /**
32          * Sets the elements of the list.
33          * 
34          * @param elements
35          *            the elements of the list.
36          */
37 //      public void setElements(Object[] elements) {
38 //              fElements = elements;
39 //      }
40
41         /*
42          * @see SelectionStatusDialog#computeResult()
43          */
44         protected void computeResult() {
45                 setResult(Arrays.asList(getSelectedElements()));
46         }
47
48         /*
49          * @see Dialog#createDialogArea(Composite)
50          */
51         protected Control createDialogArea(Composite parent) {
52                 Composite contents = (Composite) super.createDialogArea(parent);
53
54                 createMessageArea(contents);
55                 createFilterText(contents);
56                 createFilteredList(contents);
57
58                 setListElements(fElements);
59
60                 List initialSelections = getInitialElementSelections();
61                 if (initialSelections != null)
62                         setSelection(initialSelections.toArray());
63
64                 return contents;
65         }
66
67 }