Moving editor sources back into trunk
[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.apache.log4j.Logger;
14 import org.eclipse.jface.viewers.CellEditor;
15 import org.eclipse.jface.viewers.ComboBoxCellEditor;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.custom.CCombo;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
20
21 /**
22 * @author p.ciardelli
23 * @created 14.05.2009
24 * @version 1.0
25 */
26 public class EditorComboBoxPropertyDescriptor extends
27 ComboBoxPropertyDescriptor {
28 private static final Logger logger = Logger
29 .getLogger(EditorComboBoxPropertyDescriptor.class);
30 private String[] labels;
31
32 /**
33 * @param id
34 * @param displayName
35 * @param labelsArray
36 */
37 public EditorComboBoxPropertyDescriptor(Object id, String displayName,
38 String[] labelsArray) {
39 super(id, displayName, labelsArray);
40 this.labels = labelsArray;
41 }
42
43 public CellEditor createPropertyEditor(Composite parent) {
44 CellEditor editor = new ComboBoxCellEditor(parent, labels,
45 SWT.READ_ONLY);
46 if (getValidator() != null) {
47 editor.setValidator(getValidator());
48 }
49 ((CCombo) editor.getControl()).setVisibleItemCount(20);
50 return editor;
51 }
52 }