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.GenEnum; 24 import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; 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.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 35 import org.eclipse.emf.edit.provider.ViewerNotification; 36 37 39 40 46 public class GenEnumItemProvider 47 extends GenDataTypeItemProvider 48 implements 49 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 50 { 51 57 public GenEnumItemProvider(AdapterFactory adapterFactory) 58 { 59 super(adapterFactory); 60 } 61 62 68 public List getPropertyDescriptors(Object object) 69 { 70 if (itemPropertyDescriptors == null) 71 { 72 super.getPropertyDescriptors(object); 73 74 addEcoreEnumPropertyDescriptor(object); 75 } 76 return itemPropertyDescriptors; 77 } 78 79 85 protected void addEcoreEnumPropertyDescriptor(Object object) 86 { 87 itemPropertyDescriptors.add 88 (createItemPropertyDescriptor 89 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 90 getResourceLocator(), 91 getString("_UI_GenEnum_ecoreEnum_feature"), 92 getString("_UI_GenEnum_ecoreEnum_description"), 93 GenModelPackage.eINSTANCE.getGenEnum_EcoreEnum(), 94 false, 95 null, 96 getString("_UI_EcorePropertyCategory"), 97 null)); 98 } 99 100 108 public Collection getChildrenFeatures(Object object) 109 { 110 if (childrenFeatures == null) 111 { 112 super.getChildrenFeatures(object); 113 childrenFeatures.add(GenModelPackage.eINSTANCE.getGenEnum_GenEnumLiterals()); 114 } 115 return childrenFeatures; 116 } 117 118 120 public Object getImage(Object object) 121 { 122 return new UnderlayedImage(getResourceLocator().getImage("full/obj16/EEnum")); 123 } 124 125 128 public String getText(Object object) 129 { 130 GenEnum genEnum = (GenEnum)object; 131 return genEnum.getEcoreEnum().getName(); 132 } 133 134 141 public void notifyChanged(Notification notification) 142 { 143 updateChildren(notification); 144 145 switch (notification.getFeatureID(GenEnum.class)) 146 { 147 case GenModelPackage.GEN_ENUM__ECORE_ENUM: 148 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 149 return; 150 case GenModelPackage.GEN_ENUM__GEN_ENUM_LITERALS: 151 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 152 return; 153 } 154 super.notifyChanged(notification); 155 } 156 157 163 public ResourceLocator getResourceLocator() 164 { 165 return GenModelEditPlugin.INSTANCE; 166 } 167 168 } 169 | Popular Tags |