KickJava   Java API By Example, From Geeks To Geeks.

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


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: GenPackageItemProvider.java,v 1.14 2005/06/08 06:17:51 nickb Exp $
16  */

17 package org.eclipse.emf.codegen.ecore.genmodel.provider;
18
19
20 import java.util.Collection 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.GenPackage;
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.EStructuralFeature;
29
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.codegen.ecore.genmodel.GenPackage} object.
43  * <!-- begin-user-doc -->
44  * <!-- end-user-doc -->
45  * @generated
46  */

47 public class GenPackageItemProvider
48   extends GenBaseItemProvider
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 GenPackageItemProvider(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       addPrefixPropertyDescriptor(object);
76       addBasePackagePropertyDescriptor(object);
77       addResourcePropertyDescriptor(object);
78       addDisposableProviderFactoryPropertyDescriptor(object);
79       addAdapterFactoryPropertyDescriptor(object);
80       addLoadInitializationPropertyDescriptor(object);
81       addInterfacePackageSuffixPropertyDescriptor(object);
82       addClassPackageSuffixPropertyDescriptor(object);
83       addUtilityPackageSuffixPropertyDescriptor(object);
84       addProviderPackageSuffixPropertyDescriptor(object);
85       addPresentationPackageSuffixPropertyDescriptor(object);
86       addTestsPackageSuffixPropertyDescriptor(object);
87       addGenerateExampleClassPropertyDescriptor(object);
88       addEcorePackagePropertyDescriptor(object);
89     }
90     return itemPropertyDescriptors;
91   }
92
93   /**
94    * This adds a property descriptor for the Prefix feature.
95    * <!-- begin-user-doc -->
96    * <!-- end-user-doc -->
97    * @generated
98    */

99   protected void addPrefixPropertyDescriptor(Object JavaDoc object)
100   {
101     itemPropertyDescriptors.add
102       (createItemPropertyDescriptor
103         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
104          getResourceLocator(),
105          getString("_UI_GenPackage_prefix_feature"),
106          getString("_UI_GenPackage_prefix_description"),
107          GenModelPackage.eINSTANCE.getGenPackage_Prefix(),
108          true,
109          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
110          getString("_UI_AllPropertyCategory"),
111          null));
112   }
113
114   /**
115    * This adds a property descriptor for the Base Package feature.
116    * <!-- begin-user-doc -->
117    * <!-- end-user-doc -->
118    * @generated
119    */

120   protected void addBasePackagePropertyDescriptor(Object JavaDoc object)
121   {
122     itemPropertyDescriptors.add
123       (createItemPropertyDescriptor
124         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
125          getResourceLocator(),
126          getString("_UI_GenPackage_basePackage_feature"),
127          getString("_UI_GenPackage_basePackage_description"),
128          GenModelPackage.eINSTANCE.getGenPackage_BasePackage(),
129          true,
130          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
131          getString("_UI_AllPropertyCategory"),
132          null));
133   }
134
135   /**
136    * This adds a property descriptor for the Resource feature.
137    * <!-- begin-user-doc -->
138    * <!-- end-user-doc -->
139    * @generated
140    */

141   protected void addResourcePropertyDescriptor(Object JavaDoc object)
142   {
143     itemPropertyDescriptors.add
144       (createItemPropertyDescriptor
145         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
146          getResourceLocator(),
147          getString("_UI_GenPackage_resource_feature"),
148          getString("_UI_GenPackage_resource_description"),
149          GenModelPackage.eINSTANCE.getGenPackage_Resource(),
150          true,
151          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
152          getString("_UI_ModelPropertyCategory"),
153          null));
154   }
155
156   /**
157    * This adds a property descriptor for the Disposable Provider Factory feature.
158    * <!-- begin-user-doc -->
159    * <!-- end-user-doc -->
160    * @generated
161    */

162   protected void addDisposableProviderFactoryPropertyDescriptor(Object JavaDoc object)
163   {
164     itemPropertyDescriptors.add
165       (createItemPropertyDescriptor
166         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
167          getResourceLocator(),
168          getString("_UI_GenPackage_disposableProviderFactory_feature"),
169          getString("_UI_GenPackage_disposableProviderFactory_description"),
170          GenModelPackage.eINSTANCE.getGenPackage_DisposableProviderFactory(),
171          true,
172          ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
173          getString("_UI_EditPropertyCategory"),
174          null));
175   }
176
177   /**
178    * This adds a property descriptor for the Adapter Factory feature.
179    * <!-- begin-user-doc -->
180    * <!-- end-user-doc -->
181    * @generated
182    */

183   protected void addAdapterFactoryPropertyDescriptor(Object JavaDoc object)
184   {
185     itemPropertyDescriptors.add
186       (createItemPropertyDescriptor
187         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
188          getResourceLocator(),
189          getString("_UI_GenPackage_adapterFactory_feature"),
190          getString("_UI_GenPackage_adapterFactory_description"),
191          GenModelPackage.eINSTANCE.getGenPackage_AdapterFactory(),
192          true,
193          ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
194          getString("_UI_ModelPropertyCategory"),
195          null));
196   }
197
198   /**
199    * This adds a property descriptor for the Load Initialization feature.
200    * <!-- begin-user-doc -->
201    * <!-- end-user-doc -->
202    * @generated
203    */

204   protected void addLoadInitializationPropertyDescriptor(Object JavaDoc object)
205   {
206     itemPropertyDescriptors.add
207       (createItemPropertyDescriptor
208         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
209          getResourceLocator(),
210          getString("_UI_GenPackage_loadInitialization_feature"),
211          getString("_UI_GenPackage_loadInitialization_description"),
212          GenModelPackage.eINSTANCE.getGenPackage_LoadInitialization(),
213          true,
214          ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
215          getString("_UI_ModelPropertyCategory"),
216          null));
217   }
218
219   /**
220    * This adds a property descriptor for the Interface Package Suffix feature.
221    * <!-- begin-user-doc -->
222    * <!-- end-user-doc -->
223    * @generated
224    */

225   protected void addInterfacePackageSuffixPropertyDescriptor(Object JavaDoc object)
226   {
227     itemPropertyDescriptors.add
228       (createItemPropertyDescriptor
229         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
230          getResourceLocator(),
231          getString("_UI_GenPackage_interfacePackageSuffix_feature"),
232          getString("_UI_GenPackage_interfacePackageSuffix_description"),
233          GenModelPackage.eINSTANCE.getGenPackage_InterfacePackageSuffix(),
234          true,
235          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
236          getString("_UI_PackageSuffixesPropertyCategory"),
237          null));
238   }
239
240   /**
241    * This adds a property descriptor for the Class Package Suffix feature.
242    * <!-- begin-user-doc -->
243    * <!-- end-user-doc -->
244    * @generated
245    */

246   protected void addClassPackageSuffixPropertyDescriptor(Object JavaDoc object)
247   {
248     itemPropertyDescriptors.add
249       (createItemPropertyDescriptor
250         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
251          getResourceLocator(),
252          getString("_UI_GenPackage_classPackageSuffix_feature"),
253          getString("_UI_GenPackage_classPackageSuffix_description"),
254          GenModelPackage.eINSTANCE.getGenPackage_ClassPackageSuffix(),
255          true,
256          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
257          getString("_UI_PackageSuffixesPropertyCategory"),
258          null));
259   }
260
261   /**
262    * This adds a property descriptor for the Utility Package Suffix feature.
263    * <!-- begin-user-doc -->
264    * <!-- end-user-doc -->
265    * @generated
266    */

267   protected void addUtilityPackageSuffixPropertyDescriptor(Object JavaDoc object)
268   {
269     itemPropertyDescriptors.add
270       (createItemPropertyDescriptor
271         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
272          getResourceLocator(),
273          getString("_UI_GenPackage_utilityPackageSuffix_feature"),
274          getString("_UI_GenPackage_utilityPackageSuffix_description"),
275          GenModelPackage.eINSTANCE.getGenPackage_UtilityPackageSuffix(),
276          true,
277          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
278          getString("_UI_PackageSuffixesPropertyCategory"),
279          null));
280   }
281
282   /**
283    * This adds a property descriptor for the Provider Package Suffix feature.
284    * <!-- begin-user-doc -->
285    * <!-- end-user-doc -->
286    * @generated
287    */

288   protected void addProviderPackageSuffixPropertyDescriptor(Object JavaDoc object)
289   {
290     itemPropertyDescriptors.add
291       (createItemPropertyDescriptor
292         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
293          getResourceLocator(),
294          getString("_UI_GenPackage_providerPackageSuffix_feature"),
295          getString("_UI_GenPackage_providerPackageSuffix_description"),
296          GenModelPackage.eINSTANCE.getGenPackage_ProviderPackageSuffix(),
297          true,
298          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
299          getString("_UI_PackageSuffixesPropertyCategory"),
300          null));
301   }
302
303   /**
304    * This adds a property descriptor for the Presentation Package Suffix feature.
305    * <!-- begin-user-doc -->
306    * <!-- end-user-doc -->
307    * @generated
308    */

309   protected void addPresentationPackageSuffixPropertyDescriptor(Object JavaDoc object)
310   {
311     itemPropertyDescriptors.add
312       (createItemPropertyDescriptor
313         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
314          getResourceLocator(),
315          getString("_UI_GenPackage_presentationPackageSuffix_feature"),
316          getString("_UI_GenPackage_presentationPackageSuffix_description"),
317          GenModelPackage.eINSTANCE.getGenPackage_PresentationPackageSuffix(),
318          true,
319          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
320          getString("_UI_PackageSuffixesPropertyCategory"),
321          null));
322   }
323
324   /**
325    * This adds a property descriptor for the Tests Package Suffix feature.
326    * <!-- begin-user-doc -->
327    * <!-- end-user-doc -->
328    * @generated
329    */

330   protected void addTestsPackageSuffixPropertyDescriptor(Object JavaDoc object)
331   {
332     itemPropertyDescriptors.add
333       (createItemPropertyDescriptor
334         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
335          getResourceLocator(),
336          getString("_UI_GenPackage_testsPackageSuffix_feature"),
337          getString("_UI_GenPackage_testsPackageSuffix_description"),
338          GenModelPackage.eINSTANCE.getGenPackage_TestsPackageSuffix(),
339          true,
340          ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
341          getString("_UI_PackageSuffixesPropertyCategory"),
342          null));
343   }
344
345   /**
346    * This adds a property descriptor for the Generate Example Class feature.
347    * <!-- begin-user-doc -->
348    * <!-- end-user-doc -->
349    * @generated
350    */

351   protected void addGenerateExampleClassPropertyDescriptor(Object JavaDoc object)
352   {
353     itemPropertyDescriptors.add
354       (createItemPropertyDescriptor
355         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
356          getResourceLocator(),
357          getString("_UI_GenPackage_generateExampleClass_feature"),
358          getString("_UI_GenPackage_generateExampleClass_description"),
359          GenModelPackage.eINSTANCE.getGenPackage_GenerateExampleClass(),
360          true,
361          ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE,
362          getString("_UI_TestsPropertyCategory"),
363          null));
364   }
365
366   /**
367    * This adds a property descriptor for the Ecore Package feature.
368    * <!-- begin-user-doc -->
369    * <!-- end-user-doc -->
370    * @generated
371    */

372   protected void addEcorePackagePropertyDescriptor(Object JavaDoc object)
373   {
374     itemPropertyDescriptors.add
375       (createItemPropertyDescriptor
376         (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
377          getResourceLocator(),
378          getString("_UI_GenPackage_ecorePackage_feature"),
379          getString("_UI_GenPackage_ecorePackage_description"),
380          GenModelPackage.eINSTANCE.getGenPackage_EcorePackage(),
381          false,
382          null,
383          getString("_UI_EcorePropertyCategory"),
384          null));
385   }
386
387   /**
388    * <!-- begin-user-doc -->
389    * <!-- end-user-doc -->
390    * @generated
391    */

392   protected EStructuralFeature getChildFeature(Object JavaDoc object, Object JavaDoc child)
393   {
394     // Check the type of the specified child object and return the proper feature to use for
395
// adding (see {@link AddCommand}) it as a child.
396

397     return super.getChildFeature(object, child);
398   }
399
400   /**
401    * This specifies how to implement {@link #getChildren}
402    * and {@link org.eclipse.emf.edit.command.AddCommand} and {@link org.eclipse.emf.edit.command.RemoveCommand}
403    * support in {@link #createCommand}.
404    */

405   public Collection JavaDoc getChildrenFeatures(Object JavaDoc object)
406   {
407     if (childrenFeatures == null)
408     {
409       super.getChildrenFeatures(object);
410       childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_NestedGenPackages());
411       childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenClasses());
412       childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenEnums());
413       childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenDataTypes());
414     }
415     return childrenFeatures;
416   }
417
418   /**
419    */

420   public Object JavaDoc getImage(Object JavaDoc object)
421   {
422     GenPackage genPackage = (GenPackage)object;
423     String JavaDoc imageName = genPackage.eContainer() instanceof GenPackage || genPackage.canGenerate() ?
424       "full/obj16/EPackage" : "full/obj16/UsedGenPackage";
425     return new UnderlayedImage(getResourceLocator().getImage(imageName));
426   }
427
428   /**
429    * This returns the label text for the adapted class.
430    */

431   public String JavaDoc getText(Object JavaDoc object)
432   {
433     GenPackage genPackage = (GenPackage)object;
434     String JavaDoc text = genPackage.getPrefix();
435     if (text == null || text.length() == 0)
436     {
437       text = "[" + genPackage.getEcorePackage().getName() + "]";
438     }
439     return text;
440   }
441
442   /**
443    * This handles model notifications by calling {@link #updateChildren} to update any cached
444    * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
445    * <!-- begin-user-doc -->
446    * <!-- end-user-doc -->
447    * @generated
448    */

449   public void notifyChanged(Notification notification)
450   {
451     updateChildren(notification);
452
453     switch (notification.getFeatureID(GenPackage.class))
454     {
455       case GenModelPackage.GEN_PACKAGE__PREFIX:
456       case GenModelPackage.GEN_PACKAGE__BASE_PACKAGE:
457       case GenModelPackage.GEN_PACKAGE__RESOURCE:
458       case GenModelPackage.GEN_PACKAGE__DISPOSABLE_PROVIDER_FACTORY:
459       case GenModelPackage.GEN_PACKAGE__ADAPTER_FACTORY:
460       case GenModelPackage.GEN_PACKAGE__LOAD_INITIALIZATION:
461       case GenModelPackage.GEN_PACKAGE__INTERFACE_PACKAGE_SUFFIX:
462       case GenModelPackage.GEN_PACKAGE__CLASS_PACKAGE_SUFFIX:
463       case GenModelPackage.GEN_PACKAGE__UTILITY_PACKAGE_SUFFIX:
464       case GenModelPackage.GEN_PACKAGE__PROVIDER_PACKAGE_SUFFIX:
465       case GenModelPackage.GEN_PACKAGE__PRESENTATION_PACKAGE_SUFFIX:
466       case GenModelPackage.GEN_PACKAGE__TESTS_PACKAGE_SUFFIX:
467       case GenModelPackage.GEN_PACKAGE__GENERATE_EXAMPLE_CLASS:
468       case GenModelPackage.GEN_PACKAGE__ECORE_PACKAGE:
469         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
470         return;
471       case GenModelPackage.GEN_PACKAGE__GEN_ENUMS:
472       case GenModelPackage.GEN_PACKAGE__GEN_DATA_TYPES:
473       case GenModelPackage.GEN_PACKAGE__GEN_CLASSES:
474       case GenModelPackage.GEN_PACKAGE__NESTED_GEN_PACKAGES:
475         fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
476         return;
477     }
478     super.notifyChanged(notification);
479   }
480
481   /**
482    * Return the resource locator for this item provider's resources.
483    * <!-- begin-user-doc -->
484    * <!-- end-user-doc -->
485    * @generated
486    */

487   public ResourceLocator getResourceLocator()
488   {
489     return GenModelEditPlugin.INSTANCE;
490   }
491
492 }
493
Popular Tags