01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.dialogs;
11:
12: import java.util.Arrays;
13:
14: import org.eclipse.jface.viewers.ILabelProvider;
15: import org.eclipse.swt.widgets.Composite;
16: import org.eclipse.swt.widgets.Control;
17: import org.eclipse.swt.widgets.Shell;
18:
19: /**
20: * A class to select elements out of a list of elements.
21: *
22: * @since 2.0
23: */
24: public class ElementListSelectionDialog extends
25: AbstractElementListSelectionDialog {
26:
27: private Object[] fElements;
28:
29: /**
30: * Creates a list selection dialog.
31: * @param parent the parent widget.
32: * @param renderer the label renderer.
33: */
34: public ElementListSelectionDialog(Shell parent,
35: 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[] 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: }
|