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