1 17 package org.eclipse.emf.ecore.provider; 18 19 20 import java.util.Collection ; 21 import java.util.List ; 22 23 import org.eclipse.emf.common.notify.AdapterFactory; 24 import org.eclipse.emf.common.notify.Notification; 25 import org.eclipse.emf.common.util.ResourceLocator; 26 import org.eclipse.emf.ecore.EAttribute; 27 import org.eclipse.emf.ecore.EcorePackage; 28 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 29 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 30 import org.eclipse.emf.edit.provider.IItemLabelProvider; 31 import org.eclipse.emf.edit.provider.IItemPropertySource; 32 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 33 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 34 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 35 36 37 import org.eclipse.emf.edit.provider.ViewerNotification; 38 39 45 public class EAttributeItemProvider 46 extends EStructuralFeatureItemProvider 47 implements 48 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 49 { 50 56 public EAttributeItemProvider(AdapterFactory adapterFactory) 57 { 58 super(adapterFactory); 59 } 60 61 67 public List getPropertyDescriptors(Object object) 68 { 69 if (itemPropertyDescriptors == null) 70 { 71 super.getPropertyDescriptors(object); 72 73 addIDPropertyDescriptor(object); 74 addEAttributeTypePropertyDescriptor(object); 75 } 76 return itemPropertyDescriptors; 77 } 78 79 85 protected void addIDPropertyDescriptor(Object object) 86 { 87 itemPropertyDescriptors.add 88 (createItemPropertyDescriptor 89 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 90 getResourceLocator(), 91 getString("_UI_EAttribute_iD_feature"), 92 getString("_UI_PropertyDescriptor_description", "_UI_EAttribute_iD_feature", "_UI_EAttribute_type"), 93 EcorePackage.eINSTANCE.getEAttribute_ID(), 94 true, 95 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 96 null, 97 null)); 98 } 99 100 106 protected void addEAttributeTypePropertyDescriptor(Object object) 107 { 108 itemPropertyDescriptors.add 109 (createItemPropertyDescriptor 110 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 111 getResourceLocator(), 112 getString("_UI_EAttribute_eAttributeType_feature"), 113 getString("_UI_PropertyDescriptor_description", "_UI_EAttribute_eAttributeType_feature", "_UI_EAttribute_type"), 114 EcorePackage.eINSTANCE.getEAttribute_EAttributeType(), 115 false, 116 null, 117 null, 118 null)); 119 } 120 121 127 public Object getImage(Object object) 128 { 129 return getComposedImage(object, getResourceLocator().getImage("full/obj16/EAttribute")); 130 } 131 132 138 public String getText(Object object) 139 { 140 EAttribute eAttribute = (EAttribute)object; 141 StringBuffer result = new StringBuffer (); 142 result.append(eAttribute.getName()); 143 if (eAttribute.getEType() != null) 144 { 145 result.append(" : "); 146 result.append(eAttribute.getEType().getName()); 147 } 148 return result.toString(); 149 } 150 151 158 public void notifyChanged(Notification notification) 159 { 160 updateChildren(notification); 161 162 switch (notification.getFeatureID(EAttribute.class)) 163 { 164 case EcorePackage.EATTRIBUTE__ID: 165 case EcorePackage.EATTRIBUTE__EATTRIBUTE_TYPE: 166 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 167 return; 168 } 169 super.notifyChanged(notification); 170 } 171 172 179 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 180 { 181 super.collectNewChildDescriptors(newChildDescriptors, object); 182 } 183 184 190 public ResourceLocator getResourceLocator() 191 { 192 return EcoreEditPlugin.INSTANCE; 193 } 194 195 } 196 | Popular Tags |