1 17 package org.eclipse.emf.codegen.ecore.genmodel.provider; 18 19 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; 24 import org.eclipse.emf.codegen.ecore.genmodel.GenOperation; 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.EClassifier; 29 import org.eclipse.emf.ecore.EOperation; 30 import org.eclipse.emf.ecore.EParameter; 31 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; 32 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 33 import org.eclipse.emf.edit.provider.IItemLabelProvider; 34 import org.eclipse.emf.edit.provider.IItemPropertySource; 35 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 36 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 37 38 import org.eclipse.emf.edit.provider.ViewerNotification; 39 40 42 43 49 public class GenOperationItemProvider 50 extends GenBaseItemProvider 51 implements 52 IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource 53 { 54 60 public GenOperationItemProvider(AdapterFactory adapterFactory) 61 { 62 super(adapterFactory); 63 } 64 65 71 public List getPropertyDescriptors(Object object) 72 { 73 if (itemPropertyDescriptors == null) 74 { 75 super.getPropertyDescriptors(object); 76 77 addEcoreOperationPropertyDescriptor(object); 78 } 79 return itemPropertyDescriptors; 80 } 81 82 88 protected void addEcoreOperationPropertyDescriptor(Object object) 89 { 90 itemPropertyDescriptors.add 91 (createItemPropertyDescriptor 92 (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), 93 getResourceLocator(), 94 getString("_UI_GenOperation_ecoreOperation_feature"), 95 getString("_UI_GenOperation_ecoreOperation_description"), 96 GenModelPackage.eINSTANCE.getGenOperation_EcoreOperation(), 97 false, 98 null, 99 getString("_UI_EcorePropertyCategory"), 100 null)); 101 } 102 103 105 public Object getImage(Object object) 106 { 107 return new UnderlayedImage(getResourceLocator().getImage("full/obj16/EOperation")); 108 } 109 110 113 public String getText(Object object) 114 { 115 GenOperation genOperation = (GenOperation)object; 116 EOperation eOperation = genOperation.getEcoreOperation(); 117 StringBuffer result = new StringBuffer (); 118 result.append(eOperation.getName()); 119 result.append("("); for (Iterator i = eOperation.getEParameters().iterator(); i.hasNext(); ) 121 { 122 EParameter eParameter = (EParameter)i.next(); 123 if (eParameter.getEType() != null) 124 { 125 result.append(eParameter.getEType().getName()); 126 if (i.hasNext()) 127 { 128 result.append(", "); 129 } 130 } 131 } 132 result.append(")"); 134 if (eOperation.getEType() != null) 135 { 136 result.append(" : "); 137 result.append(eOperation.getEType().getName()); 138 } 139 140 if (!eOperation.getEExceptions().isEmpty()) 141 { 142 result.append(" throws "); 143 for (Iterator i = eOperation.getEExceptions().iterator(); i.hasNext(); ) 144 { 145 EClassifier eClassifier = (EClassifier)i.next(); 146 result.append(eClassifier.getName()); 147 if (i.hasNext()) 148 { 149 result.append(", "); 150 } 151 } 152 } 153 154 return result.toString(); 155 } 156 157 164 public void notifyChanged(Notification notification) 165 { 166 updateChildren(notification); 167 168 switch (notification.getFeatureID(GenOperation.class)) 169 { 170 case GenModelPackage.GEN_OPERATION__ECORE_OPERATION: 171 case GenModelPackage.GEN_OPERATION__GEN_PARAMETERS: 172 fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 173 return; 174 } 175 super.notifyChanged(notification); 176 } 177 178 184 public ResourceLocator getResourceLocator() 185 { 186 return GenModelEditPlugin.INSTANCE; 187 } 188 189 } 190 | Popular Tags |