editor now updatable via updateSite
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / propertysheet / name / EditorComboBoxPropertyDescriptor.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.propertysheet.name;
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.custom.CCombo;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
19
20 /**
21 * @author p.ciardelli
22 * @created 14.05.2009
23 * @version 1.0
24 */
25 public class EditorComboBoxPropertyDescriptor extends
26 ComboBoxPropertyDescriptor {
27 private String[] labels;
28
29 /**
30 * @param id
31 * @param displayName
32 * @param labelsArray
33 */
34 public EditorComboBoxPropertyDescriptor(Object id, String displayName,
35 String[] labelsArray) {
36 super(id, displayName, labelsArray);
37 this.labels = labelsArray;
38 }
39
40 public CellEditor createPropertyEditor(Composite parent) {
41 CellEditor editor = new ComboBoxCellEditor(parent, labels,
42 SWT.READ_ONLY);
43 if (getValidator() != null) {
44 editor.setValidator(getValidator());
45 }
46 ((CCombo) editor.getControl()).setVisibleItemCount(20);
47 return editor;
48 }
49 }