1 11 package org.eclipse.ui.views.properties; 12 13 import org.eclipse.jface.viewers.CellEditor; 14 import org.eclipse.jface.viewers.ComboBoxCellEditor; 15 import org.eclipse.jface.viewers.ILabelProvider; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.widgets.Composite; 18 19 40 public class ComboBoxPropertyDescriptor extends PropertyDescriptor { 41 42 45 private String [] labels; 46 47 55 public ComboBoxPropertyDescriptor(Object id, String displayName, 56 String [] labelsArray) { 57 super(id, displayName); 58 labels = labelsArray; 59 } 60 61 69 public CellEditor createPropertyEditor(Composite parent) { 70 CellEditor editor = new ComboBoxCellEditor(parent, labels, 71 SWT.READ_ONLY); 72 if (getValidator() != null) { 73 editor.setValidator(getValidator()); 74 } 75 return editor; 76 } 77 78 87 public ILabelProvider getLabelProvider() { 88 if (isLabelProviderSet()) { 89 return super.getLabelProvider(); 90 } else { 91 return new ComboBoxLabelProvider(labels); 92 } 93 } 94 } 95 | Popular Tags |