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.EPackage; 27 import org.eclipse.emf.ecore.EStructuralFeature; 28 import org.eclipse.emf.ecore.EcoreFactory; 29 import org.eclipse.emf.ecore.EcorePackage; 30 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 31 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 32 import org.eclipse.emf.edit.provider.IItemLabelProvider; 33 import org.eclipse.emf.edit.provider.IItemPropertySource; 34 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 35 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 36 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 37 38 39 import org.eclipse.emf.edit.provider.ViewerNotification; 40 41 47 public class EPackageItemProvider 48 extends ENamedElementItemProvider 49 implements 50 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 51 { 52 58 public EPackageItemProvider(AdapterFactory adapterFactory) 59 { 60 super(adapterFactory); 61 } 62 63 69 public List getPropertyDescriptors(Object object) 70 { 71 if (itemPropertyDescriptors == null) 72 { 73 super.getPropertyDescriptors(object); 74 75 addNsURIPropertyDescriptor(object); 76 addNsPrefixPropertyDescriptor(object); 77 addEFactoryInstancePropertyDescriptor(object); 78 } 79 return itemPropertyDescriptors; 80 } 81 82 88 protected void addNsURIPropertyDescriptor(Object object) 89 { 90 itemPropertyDescriptors.add 91 (createItemPropertyDescriptor 92 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 93 getResourceLocator(), 94 getString("_UI_EPackage_nsURI_feature"), 95 getString("_UI_PropertyDescriptor_description", "_UI_EPackage_nsURI_feature", "_UI_EPackage_type"), 96 EcorePackage.eINSTANCE.getEPackage_NsURI(), 97 true, 98 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 99 null, 100 null)); 101 } 102 103 109 protected void addNsPrefixPropertyDescriptor(Object object) 110 { 111 itemPropertyDescriptors.add 112 (createItemPropertyDescriptor 113 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 114 getResourceLocator(), 115 getString("_UI_EPackage_nsPrefix_feature"), 116 getString("_UI_PropertyDescriptor_description", "_UI_EPackage_nsPrefix_feature", "_UI_EPackage_type"), 117 EcorePackage.eINSTANCE.getEPackage_NsPrefix(), 118 true, 119 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 120 null, 121 null)); 122 } 123 124 130 protected void addEFactoryInstancePropertyDescriptor(Object object) 131 { 132 itemPropertyDescriptors.add 133 (createItemPropertyDescriptor 134 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 135 getResourceLocator(), 136 getString("_UI_EPackage_eFactoryInstance_feature"), 137 getString("_UI_PropertyDescriptor_description", "_UI_EPackage_eFactoryInstance_feature", "_UI_EPackage_type"), 138 EcorePackage.eINSTANCE.getEPackage_EFactoryInstance(), 139 true, 140 null, 141 null, 142 null)); 143 } 144 145 153 public Collection getChildrenFeatures(Object object) 154 { 155 if (childrenFeatures == null) 156 { 157 super.getChildrenFeatures(object); 158 childrenFeatures.add(EcorePackage.eINSTANCE.getEPackage_EClassifiers()); 159 childrenFeatures.add(EcorePackage.eINSTANCE.getEPackage_ESubpackages()); 160 } 161 return childrenFeatures; 162 } 163 164 169 protected EStructuralFeature getChildFeature(Object object, Object child) 170 { 171 174 return super.getChildFeature(object, child); 175 } 176 177 183 public Object getImage(Object object) 184 { 185 return getResourceLocator().getImage("full/obj16/EPackage"); 186 } 187 188 194 public String getText(Object object) 195 { 196 EPackage ePackage = (EPackage)object; 197 StringBuffer stringBuffer = new StringBuffer (); 198 stringBuffer.append(ePackage.getName()); 199 return stringBuffer.toString(); 200 } 201 202 209 public void notifyChanged(Notification notification) 210 { 211 updateChildren(notification); 212 213 switch (notification.getFeatureID(EPackage.class)) 214 { 215 case EcorePackage.EPACKAGE__NS_URI: 216 case EcorePackage.EPACKAGE__NS_PREFIX: 217 case EcorePackage.EPACKAGE__EFACTORY_INSTANCE: 218 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 219 return; 220 case EcorePackage.EPACKAGE__ECLASSIFIERS: 221 case EcorePackage.EPACKAGE__ESUBPACKAGES: 222 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 223 return; 224 } 225 super.notifyChanged(notification); 226 } 227 228 235 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 236 { 237 super.collectNewChildDescriptors(newChildDescriptors, object); 238 239 newChildDescriptors.add 240 (createChildParameter 241 (EcorePackage.eINSTANCE.getEPackage_EClassifiers(), 242 EcoreFactory.eINSTANCE.createEClass())); 243 244 newChildDescriptors.add 245 (createChildParameter 246 (EcorePackage.eINSTANCE.getEPackage_EClassifiers(), 247 EcoreFactory.eINSTANCE.createEDataType())); 248 249 newChildDescriptors.add 250 (createChildParameter 251 (EcorePackage.eINSTANCE.getEPackage_EClassifiers(), 252 EcoreFactory.eINSTANCE.createEEnum())); 253 254 newChildDescriptors.add 255 (createChildParameter 256 (EcorePackage.eINSTANCE.getEPackage_ESubpackages(), 257 EcoreFactory.eINSTANCE.createEPackage())); 258 } 259 260 266 public ResourceLocator getResourceLocator() 267 { 268 return EcoreEditPlugin.INSTANCE; 269 } 270 271 } 272 | Popular Tags |