KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > genmodel > provider > GenOperationItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: GenOperationItemProvider.java,v 1.8 2005/06/08 06:17:51 nickb Exp $
16  */

17 package org.eclipse.emf.codegen.ecore.genmodel.provider;
18
19
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
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 // import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
41

42
43 /**
44  * This is the item provider adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenOperation} object.
45  * <!-- begin-user-doc -->
46  * <!-- end-user-doc -->
47  * @generated
48  */

49 public class GenOperationItemProvider
50   extends GenBaseItemProvider
51   implements
52     IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource
53 {
54   /**
55    * This constructs an instance from a factory and a notifier.
56    * <!-- begin-user-doc -->
57    * <!-- end-user-doc -->
58    * @generated
59    */

60   public GenOperationItemProvider(AdapterFactory adapterFactory)
61   {
62     super(adapterFactory);
63   }
64
65   /**
66    * This returns the property descriptors for the adapted class.
67    * <!-- begin-user-doc -->
68    * <!-- end-user-doc -->
69    * @generated
70    */

71   public List JavaDoc getPropertyDescriptors(Object JavaDoc object)
72   {
73     if (itemPropertyDescriptors == null)
74     {
75       super.getPropertyDescriptors(object);
76
77       addEcoreOperationPropertyDescriptor(object);
78     }
79     return itemPropertyDescriptors;
80   }
81
82   /**
83    * This adds a property descriptor for the Ecore Operation feature.
84    * <!-- begin-user-doc -->
85    * <!-- end-user-doc -->
86    * @generated
87    */

88   protected void addEcoreOperationPropertyDescriptor(Object JavaDoc 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   /**
104    */

105   public Object JavaDoc getImage(Object JavaDoc object)
106   {
107     return new UnderlayedImage(getResourceLocator().getImage("full/obj16/EOperation"));
108   }
109
110   /**
111    * This returns the label text for the adapted class.
112    */

113   public String JavaDoc getText(Object JavaDoc object)
114   {
115     GenOperation genOperation = (GenOperation)object;
116     EOperation eOperation = genOperation.getEcoreOperation();
117     StringBuffer JavaDoc result = new StringBuffer JavaDoc();
118     result.append(eOperation.getName());
119     result.append("("); //)
120
for (Iterator JavaDoc 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     // (
133
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 JavaDoc 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   /**
158    * This handles model notifications by calling {@link #updateChildren} to update any cached
159    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
160    * <!-- begin-user-doc -->
161    * <!-- end-user-doc -->
162    * @generated
163    */

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   /**
179    * Return the resource locator for this item provider's resources.
180    * <!-- begin-user-doc -->
181    * <!-- end-user-doc -->
182    * @generated
183    */

184   public ResourceLocator getResourceLocator()
185   {
186     return GenModelEditPlugin.INSTANCE;
187   }
188
189 }
190
Popular Tags