1 17 package org.eclipse.emf.codegen.ecore.genmodel.provider; 18 19 20 import java.util.Collection ; 21 import java.util.List ; 22 23 import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; 24 import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; 25 import org.eclipse.emf.common.notify.AdapterFactory; 26 import org.eclipse.emf.common.notify.Notification; 27 import org.eclipse.emf.common.util.ResourceLocator; 28 import org.eclipse.emf.ecore.EStructuralFeature; 29 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 GenPackageItemProvider 48 extends GenBaseItemProvider 49 implements 50 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 51 { 52 58 public GenPackageItemProvider(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 addPrefixPropertyDescriptor(object); 76 addBasePackagePropertyDescriptor(object); 77 addResourcePropertyDescriptor(object); 78 addDisposableProviderFactoryPropertyDescriptor(object); 79 addAdapterFactoryPropertyDescriptor(object); 80 addLoadInitializationPropertyDescriptor(object); 81 addInterfacePackageSuffixPropertyDescriptor(object); 82 addClassPackageSuffixPropertyDescriptor(object); 83 addUtilityPackageSuffixPropertyDescriptor(object); 84 addProviderPackageSuffixPropertyDescriptor(object); 85 addPresentationPackageSuffixPropertyDescriptor(object); 86 addTestsPackageSuffixPropertyDescriptor(object); 87 addGenerateExampleClassPropertyDescriptor(object); 88 addEcorePackagePropertyDescriptor(object); 89 } 90 return itemPropertyDescriptors; 91 } 92 93 99 protected void addPrefixPropertyDescriptor(Object object) 100 { 101 itemPropertyDescriptors.add 102 (createItemPropertyDescriptor 103 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 104 getResourceLocator(), 105 getString("_UI_GenPackage_prefix_feature"), 106 getString("_UI_GenPackage_prefix_description"), 107 GenModelPackage.eINSTANCE.getGenPackage_Prefix(), 108 true, 109 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 110 getString("_UI_AllPropertyCategory"), 111 null)); 112 } 113 114 120 protected void addBasePackagePropertyDescriptor(Object object) 121 { 122 itemPropertyDescriptors.add 123 (createItemPropertyDescriptor 124 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 125 getResourceLocator(), 126 getString("_UI_GenPackage_basePackage_feature"), 127 getString("_UI_GenPackage_basePackage_description"), 128 GenModelPackage.eINSTANCE.getGenPackage_BasePackage(), 129 true, 130 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 131 getString("_UI_AllPropertyCategory"), 132 null)); 133 } 134 135 141 protected void addResourcePropertyDescriptor(Object object) 142 { 143 itemPropertyDescriptors.add 144 (createItemPropertyDescriptor 145 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 146 getResourceLocator(), 147 getString("_UI_GenPackage_resource_feature"), 148 getString("_UI_GenPackage_resource_description"), 149 GenModelPackage.eINSTANCE.getGenPackage_Resource(), 150 true, 151 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 152 getString("_UI_ModelPropertyCategory"), 153 null)); 154 } 155 156 162 protected void addDisposableProviderFactoryPropertyDescriptor(Object object) 163 { 164 itemPropertyDescriptors.add 165 (createItemPropertyDescriptor 166 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 167 getResourceLocator(), 168 getString("_UI_GenPackage_disposableProviderFactory_feature"), 169 getString("_UI_GenPackage_disposableProviderFactory_description"), 170 GenModelPackage.eINSTANCE.getGenPackage_DisposableProviderFactory(), 171 true, 172 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 173 getString("_UI_EditPropertyCategory"), 174 null)); 175 } 176 177 183 protected void addAdapterFactoryPropertyDescriptor(Object object) 184 { 185 itemPropertyDescriptors.add 186 (createItemPropertyDescriptor 187 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 188 getResourceLocator(), 189 getString("_UI_GenPackage_adapterFactory_feature"), 190 getString("_UI_GenPackage_adapterFactory_description"), 191 GenModelPackage.eINSTANCE.getGenPackage_AdapterFactory(), 192 true, 193 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 194 getString("_UI_ModelPropertyCategory"), 195 null)); 196 } 197 198 204 protected void addLoadInitializationPropertyDescriptor(Object object) 205 { 206 itemPropertyDescriptors.add 207 (createItemPropertyDescriptor 208 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 209 getResourceLocator(), 210 getString("_UI_GenPackage_loadInitialization_feature"), 211 getString("_UI_GenPackage_loadInitialization_description"), 212 GenModelPackage.eINSTANCE.getGenPackage_LoadInitialization(), 213 true, 214 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 215 getString("_UI_ModelPropertyCategory"), 216 null)); 217 } 218 219 225 protected void addInterfacePackageSuffixPropertyDescriptor(Object object) 226 { 227 itemPropertyDescriptors.add 228 (createItemPropertyDescriptor 229 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 230 getResourceLocator(), 231 getString("_UI_GenPackage_interfacePackageSuffix_feature"), 232 getString("_UI_GenPackage_interfacePackageSuffix_description"), 233 GenModelPackage.eINSTANCE.getGenPackage_InterfacePackageSuffix(), 234 true, 235 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 236 getString("_UI_PackageSuffixesPropertyCategory"), 237 null)); 238 } 239 240 246 protected void addClassPackageSuffixPropertyDescriptor(Object object) 247 { 248 itemPropertyDescriptors.add 249 (createItemPropertyDescriptor 250 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 251 getResourceLocator(), 252 getString("_UI_GenPackage_classPackageSuffix_feature"), 253 getString("_UI_GenPackage_classPackageSuffix_description"), 254 GenModelPackage.eINSTANCE.getGenPackage_ClassPackageSuffix(), 255 true, 256 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 257 getString("_UI_PackageSuffixesPropertyCategory"), 258 null)); 259 } 260 261 267 protected void addUtilityPackageSuffixPropertyDescriptor(Object object) 268 { 269 itemPropertyDescriptors.add 270 (createItemPropertyDescriptor 271 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 272 getResourceLocator(), 273 getString("_UI_GenPackage_utilityPackageSuffix_feature"), 274 getString("_UI_GenPackage_utilityPackageSuffix_description"), 275 GenModelPackage.eINSTANCE.getGenPackage_UtilityPackageSuffix(), 276 true, 277 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 278 getString("_UI_PackageSuffixesPropertyCategory"), 279 null)); 280 } 281 282 288 protected void addProviderPackageSuffixPropertyDescriptor(Object object) 289 { 290 itemPropertyDescriptors.add 291 (createItemPropertyDescriptor 292 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 293 getResourceLocator(), 294 getString("_UI_GenPackage_providerPackageSuffix_feature"), 295 getString("_UI_GenPackage_providerPackageSuffix_description"), 296 GenModelPackage.eINSTANCE.getGenPackage_ProviderPackageSuffix(), 297 true, 298 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 299 getString("_UI_PackageSuffixesPropertyCategory"), 300 null)); 301 } 302 303 309 protected void addPresentationPackageSuffixPropertyDescriptor(Object object) 310 { 311 itemPropertyDescriptors.add 312 (createItemPropertyDescriptor 313 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 314 getResourceLocator(), 315 getString("_UI_GenPackage_presentationPackageSuffix_feature"), 316 getString("_UI_GenPackage_presentationPackageSuffix_description"), 317 GenModelPackage.eINSTANCE.getGenPackage_PresentationPackageSuffix(), 318 true, 319 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 320 getString("_UI_PackageSuffixesPropertyCategory"), 321 null)); 322 } 323 324 330 protected void addTestsPackageSuffixPropertyDescriptor(Object object) 331 { 332 itemPropertyDescriptors.add 333 (createItemPropertyDescriptor 334 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 335 getResourceLocator(), 336 getString("_UI_GenPackage_testsPackageSuffix_feature"), 337 getString("_UI_GenPackage_testsPackageSuffix_description"), 338 GenModelPackage.eINSTANCE.getGenPackage_TestsPackageSuffix(), 339 true, 340 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 341 getString("_UI_PackageSuffixesPropertyCategory"), 342 null)); 343 } 344 345 351 protected void addGenerateExampleClassPropertyDescriptor(Object object) 352 { 353 itemPropertyDescriptors.add 354 (createItemPropertyDescriptor 355 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 356 getResourceLocator(), 357 getString("_UI_GenPackage_generateExampleClass_feature"), 358 getString("_UI_GenPackage_generateExampleClass_description"), 359 GenModelPackage.eINSTANCE.getGenPackage_GenerateExampleClass(), 360 true, 361 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, 362 getString("_UI_TestsPropertyCategory"), 363 null)); 364 } 365 366 372 protected void addEcorePackagePropertyDescriptor(Object object) 373 { 374 itemPropertyDescriptors.add 375 (createItemPropertyDescriptor 376 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 377 getResourceLocator(), 378 getString("_UI_GenPackage_ecorePackage_feature"), 379 getString("_UI_GenPackage_ecorePackage_description"), 380 GenModelPackage.eINSTANCE.getGenPackage_EcorePackage(), 381 false, 382 null, 383 getString("_UI_EcorePropertyCategory"), 384 null)); 385 } 386 387 392 protected EStructuralFeature getChildFeature(Object object, Object child) 393 { 394 397 return super.getChildFeature(object, child); 398 } 399 400 405 public Collection getChildrenFeatures(Object object) 406 { 407 if (childrenFeatures == null) 408 { 409 super.getChildrenFeatures(object); 410 childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_NestedGenPackages()); 411 childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenClasses()); 412 childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenEnums()); 413 childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenDataTypes()); 414 } 415 return childrenFeatures; 416 } 417 418 420 public Object getImage(Object object) 421 { 422 GenPackage genPackage = (GenPackage)object; 423 String imageName = genPackage.eContainer() instanceof GenPackage || genPackage.canGenerate() ? 424 "full/obj16/EPackage" : "full/obj16/UsedGenPackage"; 425 return new UnderlayedImage(getResourceLocator().getImage(imageName)); 426 } 427 428 431 public String getText(Object object) 432 { 433 GenPackage genPackage = (GenPackage)object; 434 String text = genPackage.getPrefix(); 435 if (text == null || text.length() == 0) 436 { 437 text = "[" + genPackage.getEcorePackage().getName() + "]"; 438 } 439 return text; 440 } 441 442 449 public void notifyChanged(Notification notification) 450 { 451 updateChildren(notification); 452 453 switch (notification.getFeatureID(GenPackage.class)) 454 { 455 case GenModelPackage.GEN_PACKAGE__PREFIX: 456 case GenModelPackage.GEN_PACKAGE__BASE_PACKAGE: 457 case GenModelPackage.GEN_PACKAGE__RESOURCE: 458 case GenModelPackage.GEN_PACKAGE__DISPOSABLE_PROVIDER_FACTORY: 459 case GenModelPackage.GEN_PACKAGE__ADAPTER_FACTORY: 460 case GenModelPackage.GEN_PACKAGE__LOAD_INITIALIZATION: 461 case GenModelPackage.GEN_PACKAGE__INTERFACE_PACKAGE_SUFFIX: 462 case GenModelPackage.GEN_PACKAGE__CLASS_PACKAGE_SUFFIX: 463 case GenModelPackage.GEN_PACKAGE__UTILITY_PACKAGE_SUFFIX: 464 case GenModelPackage.GEN_PACKAGE__PROVIDER_PACKAGE_SUFFIX: 465 case GenModelPackage.GEN_PACKAGE__PRESENTATION_PACKAGE_SUFFIX: 466 case GenModelPackage.GEN_PACKAGE__TESTS_PACKAGE_SUFFIX: 467 case GenModelPackage.GEN_PACKAGE__GENERATE_EXAMPLE_CLASS: 468 case GenModelPackage.GEN_PACKAGE__ECORE_PACKAGE: 469 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 470 return; 471 case GenModelPackage.GEN_PACKAGE__GEN_ENUMS: 472 case GenModelPackage.GEN_PACKAGE__GEN_DATA_TYPES: 473 case GenModelPackage.GEN_PACKAGE__GEN_CLASSES: 474 case GenModelPackage.GEN_PACKAGE__NESTED_GEN_PACKAGES: 475 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 476 return; 477 } 478 super.notifyChanged(notification); 479 } 480 481 487 public ResourceLocator getResourceLocator() 488 { 489 return GenModelEditPlugin.INSTANCE; 490 } 491 492 } 493 | Popular Tags |