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.EEnum; 27 import org.eclipse.emf.ecore.EcoreFactory; 28 import org.eclipse.emf.ecore.EcorePackage; 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 36 import org.eclipse.emf.edit.provider.ViewerNotification; 37 38 44 public class EEnumItemProvider 45 extends EDataTypeItemProvider 46 implements 47 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 48 { 49 55 public EEnumItemProvider(AdapterFactory adapterFactory) 56 { 57 super(adapterFactory); 58 } 59 60 66 public List getPropertyDescriptors(Object object) 67 { 68 if (itemPropertyDescriptors == null) 69 { 70 super.getPropertyDescriptors(object); 71 72 } 73 return itemPropertyDescriptors; 74 } 75 76 84 public Collection getChildrenFeatures(Object object) 85 { 86 if (childrenFeatures == null) 87 { 88 super.getChildrenFeatures(object); 89 childrenFeatures.add(EcorePackage.eINSTANCE.getEEnum_ELiterals()); 90 } 91 return childrenFeatures; 92 } 93 94 100 public Object getImage(Object object) 101 { 102 return getResourceLocator().getImage("full/obj16/EEnum"); 103 } 104 105 111 public String getText(Object object) 112 { 113 EEnum eEnum = (EEnum)object; 114 StringBuffer result = new StringBuffer (); 115 result.append(eEnum.getName()); 116 return result.toString(); 117 } 118 119 126 public void notifyChanged(Notification notification) 127 { 128 updateChildren(notification); 129 130 switch (notification.getFeatureID(EEnum.class)) 131 { 132 case EcorePackage.EENUM__ELITERALS: 133 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 134 return; 135 } 136 super.notifyChanged(notification); 137 } 138 139 146 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 147 { 148 super.collectNewChildDescriptors(newChildDescriptors, object); 149 150 newChildDescriptors.add 151 (createChildParameter 152 (EcorePackage.eINSTANCE.getEEnum_ELiterals(), 153 EcoreFactory.eINSTANCE.createEEnumLiteral())); 154 } 155 156 162 public ResourceLocator getResourceLocator() 163 { 164 return EcoreEditPlugin.INSTANCE; 165 } 166 167 } 168 | Popular Tags |