1 11 package org.eclipse.pde.internal.ui.editor.feature; 12 13 import java.util.*; 14 15 import org.eclipse.jface.viewers.*; 16 import org.eclipse.pde.internal.core.ifeature.*; 17 import org.eclipse.pde.internal.ui.editor.*; 18 import org.eclipse.ui.views.properties.*; 19 20 public abstract class FeaturePropertySource implements IPropertySource { 21 protected IFeatureObject object; 22 23 public FeaturePropertySource(IFeatureObject object) { 24 this.object = object; 25 } 26 protected PropertyDescriptor createTextPropertyDescriptor( 27 String name, 28 String displayName) { 29 if (isEditable()) 30 return new ModifiedTextPropertyDescriptor(name, displayName); 31 else 32 return new PropertyDescriptor(name, displayName); 33 } 34 35 protected PropertyDescriptor createChoicePropertyDescriptor( 36 String name, 37 String displayName, 38 final String [] choices) { 39 if (isEditable()) { 40 PropertyDescriptor desc = new ComboBoxPropertyDescriptor(name, displayName, choices); 41 desc.setLabelProvider(new LabelProvider() { 42 public String getText(Object obj) { 43 Integer index = (Integer )obj; 44 return choices[index.intValue()]; 45 } 46 }); 47 return desc; 48 } else 49 return new PropertyDescriptor(name, displayName); 50 } 51 public Object getEditableValue() { 52 return null; 53 } 54 public boolean isEditable() { 55 return object.getModel().isEditable(); 56 } 57 public boolean isPropertySet(Object property) { 58 return false; 59 } 60 public void resetPropertyValue(Object property) { 61 } 62 protected IPropertyDescriptor[] toDescriptorArray(Vector result) { 63 IPropertyDescriptor[] array = new IPropertyDescriptor[result.size()]; 64 result.copyInto(array); 65 return array; 66 } 67 } 68 | Popular Tags |