KickJava   Java API By Example, From Geeks To Geeks.

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


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: EPackageItemProvider.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.List JavaDoc;
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.EPackage;
27 import org.eclipse.emf.ecore.EStructuralFeature;
28 import org.eclipse.emf.ecore.EcoreFactory;
29 import org.eclipse.emf.ecore.EcorePackage;
30 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
31 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
32 import org.eclipse.emf.edit.provider.IItemLabelProvider;
33 import org.eclipse.emf.edit.provider.IItemPropertySource;
34 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
35 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
36 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
37
38
39 import org.eclipse.emf.edit.provider.ViewerNotification;
40
41 /**
42  * This is the item provider adapter for a {@link org.eclipse.emf.ecore.EPackage} object.
43  * <!-- begin-user-doc -->
44  * <!-- end-user-doc -->
45  * @generated
46  */

47 public class EPackageItemProvider
48   extends ENamedElementItemProvider
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 EPackageItemProvider(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       addNsURIPropertyDescriptor(object);
76       addNsPrefixPropertyDescriptor(object);
77       addEFactoryInstancePropertyDescriptor(object);
78     }
79     return itemPropertyDescriptors;
80   }
81
82   /**
83    * This adds a property descriptor for the Ns URI feature.
84    * <!-- begin-user-doc -->
85    * <!-- end-user-doc -->
86    * @generated
87    */

88   protected void addNsURIPropertyDescriptor(Object JavaDoc object)
89   {
90     itemPropertyDescriptors.add
91       (createItemPropertyDescriptor
92         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
93          getResourceLocator(),
94          getString("_UI_EPackage_nsURI_feature"),
95          getString("_UI_PropertyDescriptor_description", "_UI_EPackage_nsURI_feature", "_UI_EPackage_type"),
96          EcorePackage.eINSTANCE.getEPackage_NsURI(),
97          true,
98          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
99          null,
100          null));
101   }
102
103   /**
104    * This adds a property descriptor for the Ns Prefix feature.
105    * <!-- begin-user-doc -->
106    * <!-- end-user-doc -->
107    * @generated
108    */

109   protected void addNsPrefixPropertyDescriptor(Object JavaDoc object)
110   {
111     itemPropertyDescriptors.add
112       (createItemPropertyDescriptor
113         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
114          getResourceLocator(),
115          getString("_UI_EPackage_nsPrefix_feature"),
116          getString("_UI_PropertyDescriptor_description", "_UI_EPackage_nsPrefix_feature", "_UI_EPackage_type"),
117          EcorePackage.eINSTANCE.getEPackage_NsPrefix(),
118          true,
119          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
120          null,
121          null));
122   }
123
124   /**
125    * This adds a property descriptor for the EFactory Instance feature.
126    * <!-- begin-user-doc -->
127    * <!-- end-user-doc -->
128    * @generated
129    */

130   protected void addEFactoryInstancePropertyDescriptor(Object JavaDoc object)
131   {
132     itemPropertyDescriptors.add
133       (createItemPropertyDescriptor
134         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
135          getResourceLocator(),
136          getString("_UI_EPackage_eFactoryInstance_feature"),
137          getString("_UI_PropertyDescriptor_description", "_UI_EPackage_eFactoryInstance_feature", "_UI_EPackage_type"),
138          EcorePackage.eINSTANCE.getEPackage_EFactoryInstance(),
139          true,
140          null,
141          null,
142          null));
143   }
144
145   /**
146    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
147    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
148    * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
149    * <!-- begin-user-doc -->
150    * <!-- end-user-doc -->
151    * @generated
152    */

153   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
154   {
155     if (childrenFeatures == null)
156     {
157       super.getChildrenFeatures(object);
158       childrenFeatures.add(EcorePackage.eINSTANCE.getEPackage_EClassifiers());
159       childrenFeatures.add(EcorePackage.eINSTANCE.getEPackage_ESubpackages());
160     }
161     return childrenFeatures;
162   }
163
164   /**
165    * <!-- begin-user-doc -->
166    * <!-- end-user-doc -->
167    * @generated
168    */

169   protected EStructuralFeature getChildFeature(Object JavaDoc object, Object JavaDoc child)
170   {
171     // Check the type of the specified child object and return the proper feature to use for
172
// adding (see {@link AddCommand}) it as a child.
173

174     return super.getChildFeature(object, child);
175   }
176
177   /**
178    * This returns EPackage.gif.
179    * <!-- begin-user-doc -->
180    * <!-- end-user-doc -->
181    * @generated
182    */

183   public Object JavaDoc getImage(Object JavaDoc object)
184   {
185     return getResourceLocator().getImage("full/obj16/EPackage");
186   }
187
188   /**
189    * This returns the label text for the adapted class.
190    * <!-- begin-user-doc -->
191    * <!-- end-user-doc -->
192    * @generated NOT
193    */

194   public String JavaDoc getText(Object JavaDoc object)
195   {
196     EPackage ePackage = (EPackage)object;
197     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
198     stringBuffer.append(ePackage.getName());
199     return stringBuffer.toString();
200   }
201
202   /**
203    * This handles model notifications by calling {@link #updateChildren} to update any cached
204    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
205    * <!-- begin-user-doc -->
206    * <!-- end-user-doc -->
207    * @generated
208    */

209   public void notifyChanged(Notification notification)
210   {
211     updateChildren(notification);
212
213     switch (notification.getFeatureID(EPackage.class))
214     {
215       case EcorePackage.EPACKAGE__NS_URI:
216       case EcorePackage.EPACKAGE__NS_PREFIX:
217       case EcorePackage.EPACKAGE__EFACTORY_INSTANCE:
218         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
219         return;
220       case EcorePackage.EPACKAGE__ECLASSIFIERS:
221       case EcorePackage.EPACKAGE__ESUBPACKAGES:
222         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
223         return;
224     }
225     super.notifyChanged(notification);
226   }
227
228   /**
229    * This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
230    * describing all of the children that can be created under this object.
231    * <!-- begin-user-doc -->
232    * <!-- end-user-doc -->
233    * @generated
234    */

235   protected void collectNewChildDescriptors(Collection JavaDoc newChildDescriptors, Object JavaDoc object)
236   {
237     super.collectNewChildDescriptors(newChildDescriptors, object);
238
239     newChildDescriptors.add
240       (createChildParameter
241         (EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
242          EcoreFactory.eINSTANCE.createEClass()));
243
244     newChildDescriptors.add
245       (createChildParameter
246         (EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
247          EcoreFactory.eINSTANCE.createEDataType()));
248
249     newChildDescriptors.add
250       (createChildParameter
251         (EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
252          EcoreFactory.eINSTANCE.createEEnum()));
253
254     newChildDescriptors.add
255       (createChildParameter
256         (EcorePackage.eINSTANCE.getEPackage_ESubpackages(),
257          EcoreFactory.eINSTANCE.createEPackage()));
258   }
259
260   /**
261    * Return the resource locator for this item provider's resources.
262    * <!-- begin-user-doc -->
263    * <!-- end-user-doc -->
264    * @generated
265    */

266   public ResourceLocator getResourceLocator()
267   {
268     return EcoreEditPlugin.INSTANCE;
269   }
270
271 }
272
Popular Tags