KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > dialogs > ElementListSelectionDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.dialogs;
12
13 import java.util.Arrays JavaDoc;
14
15 import org.eclipse.jface.viewers.ILabelProvider;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.swt.widgets.Shell;
19
20 /**
21  * A class to select elements out of a list of elements.
22  *
23  * @since 2.0
24  */

25 public class ElementListSelectionDialog extends
26         AbstractElementListSelectionDialog {
27
28     private Object JavaDoc[] fElements;
29
30     /**
31      * Creates a list selection dialog.
32      * @param parent the parent widget.
33      * @param renderer the label renderer.
34      */

35     public ElementListSelectionDialog(Shell parent, ILabelProvider renderer) {
36         super(parent, renderer);
37     }
38
39     /**
40      * Sets the elements of the list.
41      * @param elements the elements of the list.
42      */

43     public void setElements(Object JavaDoc[] elements) {
44         fElements = elements;
45     }
46
47     /*
48      * @see SelectionStatusDialog#computeResult()
49      */

50     protected void computeResult() {
51         setResult(Arrays.asList(getSelectedElements()));
52     }
53
54     /*
55      * @see Dialog#createDialogArea(Composite)
56      */

57     protected Control createDialogArea(Composite parent) {
58         Composite contents = (Composite) super.createDialogArea(parent);
59
60         createMessageArea(contents);
61         createFilterText(contents);
62         createFilteredList(contents);
63
64         setListElements(fElements);
65
66         setSelection(getInitialElementSelections().toArray());
67
68         return contents;
69     }
70 }
71
Popular Tags