KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > provider > EOperationItemProvider


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 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: EOperationItemProvider.java,v 1.7 2005/06/08 06:15:46 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.provider;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23
24 import org.eclipse.emf.common.notify.AdapterFactory;
25 import org.eclipse.emf.common.notify.Notification;
26 import org.eclipse.emf.common.util.ResourceLocator;
27 import org.eclipse.emf.ecore.EClassifier;
28 import org.eclipse.emf.ecore.EOperation;
29 import org.eclipse.emf.ecore.EParameter;
30 import org.eclipse.emf.ecore.EcoreFactory;
31 import org.eclipse.emf.ecore.EcorePackage;
32 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
33 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
34 import org.eclipse.emf.edit.provider.IItemLabelProvider;
35 import org.eclipse.emf.edit.provider.IItemPropertySource;
36 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
37 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
38 import org.eclipse.emf.edit.provider.ViewerNotification;
39
40
41 /**
42  * This is the item provider adapter for a {@link org.eclipse.emf.ecore.EOperation} object.
43  * <!-- begin-user-doc -->
44  * <!-- end-user-doc -->
45  * @generated
46  */

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

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

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

86   protected void addEExceptionsPropertyDescriptor(Object JavaDoc object)
87   {
88     itemPropertyDescriptors.add
89       (createItemPropertyDescriptor
90         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
91          getResourceLocator(),
92          getString("_UI_EOperation_eExceptions_feature"),
93          getString("_UI_PropertyDescriptor_description", "_UI_EOperation_eExceptions_feature", "_UI_EOperation_type"),
94          EcorePackage.eINSTANCE.getEOperation_EExceptions(),
95          true,
96          null,
97          null,
98          null));
99   }
100
101   /**
102    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
103    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
104    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
105    * <!-- begin-user-doc -->
106    * <!-- end-user-doc -->
107    * @generated
108    */

109   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
110   {
111     if (childrenFeatures == null)
112     {
113       super.getChildrenFeatures(object);
114       childrenFeatures.add(EcorePackage.eINSTANCE.getEOperation_EParameters());
115     }
116     return childrenFeatures;
117   }
118
119   /**
120    * This returns EOperation.gif.
121    * <!-- begin-user-doc -->
122    * <!-- end-user-doc -->
123    * @generated
124    */

125   public Object JavaDoc getImage(Object JavaDoc object)
126   {
127     return getResourceLocator().getImage("full/obj16/EOperation");
128   }
129
130   /**
131    * This returns the label text for the adapted class.
132    * <!-- begin-user-doc -->
133    * <!-- end-user-doc -->
134    * @generated NOT
135    */

136   public String JavaDoc getText(Object JavaDoc object)
137   {
138     EOperation eOperation = (EOperation)object;
139     StringBuffer JavaDoc result = new StringBuffer JavaDoc();
140     result.append(eOperation.getName());
141     result.append("("); //)
142
for (Iterator JavaDoc i = eOperation.getEParameters().iterator(); i.hasNext(); )
143     {
144       EParameter eParameter = (EParameter)i.next();
145       if (eParameter.getEType() != null)
146       {
147         result.append(eParameter.getEType().getName());
148         if (i.hasNext())
149         {
150           result.append(", ");
151         }
152       }
153     }
154     // (
155
result.append(")");
156     if (eOperation.getEType() != null)
157     {
158       result.append(" : ");
159       result.append(eOperation.getEType().getName());
160     }
161
162     if (!eOperation.getEExceptions().isEmpty())
163     {
164       result.append(" throws ");
165       for (Iterator JavaDoc i = eOperation.getEExceptions().iterator(); i.hasNext(); )
166       {
167         EClassifier eClassifier = (EClassifier)i.next();
168         result.append(eClassifier.getName());
169         if (i.hasNext())
170         {
171           result.append(", ");
172         }
173       }
174     }
175     return result.toString();
176   }
177
178   /**
179    * This handles model notifications by calling {@link #updateChildren} to update any cached
180    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
181    * <!-- begin-user-doc -->
182    * <!-- end-user-doc -->
183    * @generated
184    */

185   public void notifyChanged(Notification notification)
186   {
187     updateChildren(notification);
188
189     switch (notification.getFeatureID(EOperation.class))
190     {
191       case EcorePackage.EOPERATION__EPARAMETERS:
192         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
193         return;
194     }
195     super.notifyChanged(notification);
196   }
197
198   /**
199    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
200    * describing all of the children that can be created under this object.
201    * <!-- begin-user-doc -->
202    * <!-- end-user-doc -->
203    * @generated
204    */

205   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
206   {
207     super.collectNewChildDescriptors(newChildDescriptors, object);
208
209     newChildDescriptors.add
210       (createChildParameter
211         (EcorePackage.eINSTANCE.getEOperation_EParameters(),
212          EcoreFactory.eINSTANCE.createEParameter()));
213   }
214
215   /**
216    * Return the resource locator for this item provider's resources.
217    * <!-- begin-user-doc -->
218    * <!-- end-user-doc -->
219    * @generated
220    */

221   public ResourceLocator getResourceLocator()
222   {
223     return EcoreEditPlugin.INSTANCE;
224   }
225
226 }
227
Popular Tags