KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > util > ChoicePropertyDescriptor


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.pde.internal.ui.util;
12
13 import org.eclipse.jface.viewers.CellEditor;
14 import org.eclipse.jface.viewers.ComboBoxCellEditor;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.ui.views.properties.PropertyDescriptor;
18
19 public class ChoicePropertyDescriptor extends PropertyDescriptor {
20
21     /**
22      * The list of possible values to display in the combo box
23      */

24     private String JavaDoc[] values;
25 /**
26  * Creates an property descriptor with the given id, display name, and list
27  * of value labels to display in the combo box cell editor.
28  *
29  * @param id the id of the property
30  * @param displayName the name to display for the property
31  * @param valuesArray the list of possible values to display in the combo box
32  */

33 public ChoicePropertyDescriptor(Object JavaDoc id, String JavaDoc displayName, String JavaDoc[] valuesArray) {
34     super(id, displayName);
35     values = valuesArray;
36 }
37 /**
38  * The <code>ComboBoxPropertyDescriptor</code> implementation of this
39  * <code>IPropertyDescriptor</code> method creates and returns a new
40  * <code>ComboBoxCellEditor</code>.
41  * <p>
42  * The editor is configured with the current validator if there is one.
43  * </p>
44  */

45 public CellEditor createPropertyEditor(Composite parent) {
46     CellEditor editor = new ComboBoxCellEditor(parent, values, SWT.READ_ONLY);
47     if (getValidator() != null)
48         editor.setValidator(getValidator());
49     return editor;
50 }
51 }
52
Popular Tags