1 17 package org.eclipse.emf.edit.ui.provider; 18 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import org.eclipse.ui.views.properties.IPropertyDescriptor; 26 import org.eclipse.ui.views.properties.IPropertySource; 27 28 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; 29 import org.eclipse.emf.edit.provider.IItemPropertySource; 30 31 32 36 public class PropertySource implements IPropertySource 37 { 38 41 protected Object object; 42 43 46 protected IItemPropertySource itemPropertySource; 47 48 51 public PropertySource(Object object, IItemPropertySource itemPropertySource) 52 { 53 this.object = object; 54 this.itemPropertySource = itemPropertySource; 55 } 56 57 60 public Object getEditableValue() 61 { 62 return itemPropertySource.getEditableValue(object); 63 } 64 65 68 public IPropertyDescriptor [] getPropertyDescriptors() 69 { 70 Collection result = new ArrayList (); 71 List itemPropertyDescriptors = itemPropertySource.getPropertyDescriptors(object); 72 if (itemPropertyDescriptors != null) 73 { 74 for (Iterator i = itemPropertyDescriptors.iterator(); i.hasNext(); ) 75 { 76 IItemPropertyDescriptor itemPropertyDescriptor = (IItemPropertyDescriptor)i.next(); 77 result.add(createPropertyDescriptor(itemPropertyDescriptor)); 78 } 79 } 80 81 return (IPropertyDescriptor [])result.toArray(new IPropertyDescriptor [result.size()]); 82 } 83 84 protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) 85 { 86 return new PropertyDescriptor(object, itemPropertyDescriptor); 87 } 88 89 92 public Object getPropertyValue(Object propertyId) 93 { 94 return itemPropertySource.getPropertyDescriptor(object, propertyId).getPropertyValue(object); 95 } 96 97 100 public boolean isPropertySet(Object propertyId) 101 { 102 return itemPropertySource.getPropertyDescriptor(object, propertyId).isPropertySet(object); 103 } 104 105 108 public void resetPropertyValue(Object propertyId) 109 { 110 itemPropertySource.getPropertyDescriptor(object, propertyId).resetPropertyValue(object); 111 } 112 113 116 public void setPropertyValue(Object propertyId, Object value) 117 { 118 itemPropertySource.getPropertyDescriptor(object, propertyId).setPropertyValue(object, value); 119 } 120 } 121 | Popular Tags |