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.EEnumLiteral; 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 EEnumLiteralItemProvider 46 extends ENamedElementItemProvider 47 implements 48 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 49 { 50 56 public EEnumLiteralItemProvider(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 addValuePropertyDescriptor(object); 74 addInstancePropertyDescriptor(object); 75 } 76 return itemPropertyDescriptors; 77 } 78 79 85 protected void addValuePropertyDescriptor(Object object) 86 { 87 itemPropertyDescriptors.add 88 (createItemPropertyDescriptor 89 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 90 getResourceLocator(), 91 getString("_UI_EEnumLiteral_value_feature"), 92 getString("_UI_PropertyDescriptor_description", "_UI_EEnumLiteral_value_feature", "_UI_EEnumLiteral_type"), 93 EcorePackage.eINSTANCE.getEEnumLiteral_Value(), 94 true, 95 ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, 96 null, 97 null)); 98 } 99 100 106 protected void addInstancePropertyDescriptor(Object object) 107 { 108 itemPropertyDescriptors.add 109 (createItemPropertyDescriptor 110 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 111 getResourceLocator(), 112 getString("_UI_EEnumLiteral_instance_feature"), 113 getString("_UI_PropertyDescriptor_description", "_UI_EEnumLiteral_instance_feature", "_UI_EEnumLiteral_type"), 114 EcorePackage.eINSTANCE.getEEnumLiteral_Instance(), 115 true, 116 ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, 117 null, 118 null)); 119 } 120 121 127 public Object getImage(Object object) 128 { 129 return getResourceLocator().getImage("full/obj16/EEnumLiteral"); 130 } 131 132 138 public String getText(Object object) 139 { 140 EEnumLiteral eEnumLiteral = (EEnumLiteral)object; 141 StringBuffer result = new StringBuffer (); 142 result.append(eEnumLiteral.getName()); 143 result.append(" = "); 144 result.append(eEnumLiteral.getValue()); 145 return result.toString(); 146 } 147 148 155 public void notifyChanged(Notification notification) 156 { 157 updateChildren(notification); 158 159 switch (notification.getFeatureID(EEnumLiteral.class)) 160 { 161 case EcorePackage.EENUM_LITERAL__VALUE: 162 case EcorePackage.EENUM_LITERAL__INSTANCE: 163 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 164 return; 165 } 166 super.notifyChanged(notification); 167 } 168 169 176 protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) 177 { 178 super.collectNewChildDescriptors(newChildDescriptors, object); 179 } 180 181 187 public ResourceLocator getResourceLocator() 188 { 189 return EcoreEditPlugin.INSTANCE; 190 } 191 192 } 193 | Popular Tags |