1 11 package org.eclipse.pde.internal.ui.editor.schema; 12 13 import java.util.*; 14 import org.eclipse.pde.internal.ui.editor.*; 15 import org.eclipse.pde.internal.core.ischema.*; 16 import org.eclipse.ui.views.properties.*; 17 import org.eclipse.jface.viewers.*; 18 19 public abstract class SchemaObjectPropertySource implements IPropertySource { 20 private Object sourceObject; 21 protected boolean isSchemaObject = false; 22 class ComboProvider extends LabelProvider { 23 private String property; 24 private String [] table; 25 26 public ComboProvider(String property, String [] table) { 27 this.property = property; 28 this.table = table; 29 } 30 31 public String getText(Object obj) { 32 isSchemaObject = true; 33 Integer index = (Integer ) getPropertyValue(property); 34 return table[index.intValue()]; 35 } 36 } 37 38 public SchemaObjectPropertySource(Object object) { 39 this.sourceObject = object; 40 } 41 42 protected PropertyDescriptor createComboBoxPropertyDescriptor(String id, String name, 43 String [] choices) { 44 if (isEditable()) 45 return new ComboBoxPropertyDescriptor(id, name, choices); 46 return new PropertyDescriptor(id, name); 47 } 48 49 protected PropertyDescriptor createTextPropertyDescriptor(String id, String name) { 50 if (isEditable()) 51 return new ModifiedTextPropertyDescriptor(id, name); 52 return new PropertyDescriptor(id, name); 53 } 54 55 protected Object getNonzeroValue(Object value) { 56 if (value != null) 57 return value; 58 return ""; } 60 61 public java.lang.Object getSourceObject() { 62 return sourceObject; 63 } 64 65 public boolean isEditable() { 66 ISchemaObject schemaObject = (ISchemaObject) getSourceObject(); 67 ISchema schema = schemaObject.getSchema(); 68 return schema != null ? schema.isEditable() : false; 69 } 70 71 public void setSourceObject(java.lang.Object newSourceObject) { 72 sourceObject = newSourceObject; 73 } 74 75 protected IPropertyDescriptor[] toDescriptorArray(Vector result) { 76 IPropertyDescriptor[] array = new IPropertyDescriptor[result.size()]; 77 result.copyInto(array); 78 return array; 79 } 80 } 81 | Popular Tags |