KickJava   Java API By Example, From Geeks To Geeks.

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


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: EcoreItemProviderAdapterFactory.java,v 1.4 2005/06/08 06:15:46 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.provider;
18
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Collection JavaDoc;
22
23 import org.eclipse.emf.common.notify.Adapter;
24 import org.eclipse.emf.common.notify.Notification;
25 import org.eclipse.emf.common.notify.Notifier;
26 import org.eclipse.emf.ecore.util.EcoreAdapterFactory;
27 import org.eclipse.emf.edit.provider.ChangeNotifier;
28 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
29 import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
30 import org.eclipse.emf.edit.provider.IChangeNotifier;
31 import org.eclipse.emf.edit.provider.IDisposable;
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.INotifyChangedListener;
36 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
37 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
38 import org.eclipse.emf.edit.provider.ReflectiveItemProvider;
39
40
41 /**
42  * This is the factory that is used to provide the interfaces needed to support Viewers.
43  * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
44  * The adapters also support Eclipse property sheets.
45  * Note that most of the adapters are shared among multiple instances.
46  * <!-- begin-user-doc -->
47  * <!-- end-user-doc -->
48  * @generated
49  */

50 public class EcoreItemProviderAdapterFactory extends EcoreAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable
51 {
52   /**
53    * This keeps track of the root adapter factory that delegates to this adapter factory.
54    * <!-- begin-user-doc -->
55    * <!-- end-user-doc -->
56    * @generated
57    */

58   protected ComposedAdapterFactory parentAdapterFactory;
59
60   /**
61    * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
62    * <!-- begin-user-doc -->
63    * <!-- end-user-doc -->
64    * @generated
65    */

66   protected IChangeNotifier changeNotifier = new ChangeNotifier();
67
68   /**
69    * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
70    * <!-- begin-user-doc -->
71    * <!-- end-user-doc -->
72    * @generated
73    */

74   protected Collection JavaDoc supportedTypes = new ArrayList JavaDoc();
75
76   /**
77    * This constructs an instance.
78    * <!-- begin-user-doc -->
79    * <!-- end-user-doc -->
80    * @generated
81    */

82   public EcoreItemProviderAdapterFactory()
83   {
84     supportedTypes.add(IEditingDomainItemProvider.class);
85     supportedTypes.add(IStructuredItemContentProvider.class);
86     supportedTypes.add(ITreeItemContentProvider.class);
87     supportedTypes.add(IItemLabelProvider.class);
88     supportedTypes.add(IItemPropertySource.class);
89   }
90
91   /**
92    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EAttribute} instances.
93    * <!-- begin-user-doc -->
94    * <!-- end-user-doc -->
95    * @generated
96    */

97   protected EAttributeItemProvider eAttributeItemProvider;
98
99   /**
100    * This creates an adapter for a {@link org.eclipse.emf.ecore.EAttribute}.
101    * <!-- begin-user-doc -->
102    * <!-- end-user-doc -->
103    * @generated
104    */

105   public Adapter createEAttributeAdapter()
106   {
107     if (eAttributeItemProvider == null)
108     {
109       eAttributeItemProvider = new EAttributeItemProvider(this);
110     }
111
112     return eAttributeItemProvider;
113   }
114
115   /**
116    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EAnnotation} instances.
117    * <!-- begin-user-doc -->
118    * <!-- end-user-doc -->
119    * @generated
120    */

121   protected EAnnotationItemProvider eAnnotationItemProvider;
122
123   /**
124    * This creates an adapter for a {@link org.eclipse.emf.ecore.EAnnotation}.
125    * <!-- begin-user-doc -->
126    * <!-- end-user-doc -->
127    * @generated
128    */

129   public Adapter createEAnnotationAdapter()
130   {
131     if (eAnnotationItemProvider == null)
132     {
133       eAnnotationItemProvider = new EAnnotationItemProvider(this);
134     }
135
136     return eAnnotationItemProvider;
137   }
138
139   /**
140    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EClass} instances.
141    * <!-- begin-user-doc -->
142    * <!-- end-user-doc -->
143    * @generated
144    */

145   protected EClassItemProvider eClassItemProvider;
146
147   /**
148    * This creates an adapter for a {@link org.eclipse.emf.ecore.EClass}.
149    * <!-- begin-user-doc -->
150    * <!-- end-user-doc -->
151    * @generated
152    */

153   public Adapter createEClassAdapter()
154   {
155     if (eClassItemProvider == null)
156     {
157       eClassItemProvider = new EClassItemProvider(this);
158     }
159
160     return eClassItemProvider;
161   }
162
163   /**
164    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EDataType} instances.
165    * <!-- begin-user-doc -->
166    * <!-- end-user-doc -->
167    * @generated
168    */

169   protected EDataTypeItemProvider eDataTypeItemProvider;
170
171   /**
172    * This creates an adapter for a {@link org.eclipse.emf.ecore.EDataType}.
173    * <!-- begin-user-doc -->
174    * <!-- end-user-doc -->
175    * @generated
176    */

177   public Adapter createEDataTypeAdapter()
178   {
179     if (eDataTypeItemProvider == null)
180     {
181       eDataTypeItemProvider = new EDataTypeItemProvider(this);
182     }
183
184     return eDataTypeItemProvider;
185   }
186
187   /**
188    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EEnum} instances.
189    * <!-- begin-user-doc -->
190    * <!-- end-user-doc -->
191    * @generated
192    */

193   protected EEnumItemProvider eEnumItemProvider;
194
195   /**
196    * This creates an adapter for a {@link org.eclipse.emf.ecore.EEnum}.
197    * <!-- begin-user-doc -->
198    * <!-- end-user-doc -->
199    * @generated
200    */

201   public Adapter createEEnumAdapter()
202   {
203     if (eEnumItemProvider == null)
204     {
205       eEnumItemProvider = new EEnumItemProvider(this);
206     }
207
208     return eEnumItemProvider;
209   }
210
211   /**
212    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EEnumLiteral} instances.
213    * <!-- begin-user-doc -->
214    * <!-- end-user-doc -->
215    * @generated
216    */

217   protected EEnumLiteralItemProvider eEnumLiteralItemProvider;
218
219   /**
220    * This creates an adapter for a {@link org.eclipse.emf.ecore.EEnumLiteral}.
221    * <!-- begin-user-doc -->
222    * <!-- end-user-doc -->
223    * @generated
224    */

225   public Adapter createEEnumLiteralAdapter()
226   {
227     if (eEnumLiteralItemProvider == null)
228     {
229       eEnumLiteralItemProvider = new EEnumLiteralItemProvider(this);
230     }
231
232     return eEnumLiteralItemProvider;
233   }
234
235   /**
236    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EFactory} instances.
237    * <!-- begin-user-doc -->
238    * <!-- end-user-doc -->
239    * @generated
240    */

241   protected EFactoryItemProvider eFactoryItemProvider;
242
243   /**
244    * This creates an adapter for a {@link org.eclipse.emf.ecore.EFactory}.
245    * <!-- begin-user-doc -->
246    * <!-- end-user-doc -->
247    * @generated
248    */

249   public Adapter createEFactoryAdapter()
250   {
251     if (eFactoryItemProvider == null)
252     {
253       eFactoryItemProvider = new EFactoryItemProvider(this);
254     }
255
256     return eFactoryItemProvider;
257   }
258
259   /**
260    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EObject} instances.
261    * <!-- begin-user-doc -->
262    * <!-- end-user-doc -->
263    * @generated NOT
264    */

265   protected ReflectiveItemProvider eObjectItemProvider;
266
267   /**
268    * This creates an adapter for a {@link org.eclipse.emf.ecore.EObject}.
269    * <!-- begin-user-doc -->
270    * <!-- end-user-doc -->
271    * @generated NOT
272    */

273   public Adapter createEObjectAdapter()
274   {
275     if (eObjectItemProvider == null)
276     {
277       eObjectItemProvider = new ReflectiveItemProvider(this);
278     }
279
280     return eObjectItemProvider;
281   }
282
283   /**
284    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EOperation} instances.
285    * <!-- begin-user-doc -->
286    * <!-- end-user-doc -->
287    * @generated
288    */

289   protected EOperationItemProvider eOperationItemProvider;
290
291   /**
292    * This creates an adapter for a {@link org.eclipse.emf.ecore.EOperation}.
293    * <!-- begin-user-doc -->
294    * <!-- end-user-doc -->
295    * @generated
296    */

297   public Adapter createEOperationAdapter()
298   {
299     if (eOperationItemProvider == null)
300     {
301       eOperationItemProvider = new EOperationItemProvider(this);
302     }
303
304     return eOperationItemProvider;
305   }
306
307   /**
308    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EPackage} instances.
309    * <!-- begin-user-doc -->
310    * <!-- end-user-doc -->
311    * @generated
312    */

313   protected EPackageItemProvider ePackageItemProvider;
314
315   /**
316    * This creates an adapter for a {@link org.eclipse.emf.ecore.EPackage}.
317    * <!-- begin-user-doc -->
318    * <!-- end-user-doc -->
319    * @generated
320    */

321   public Adapter createEPackageAdapter()
322   {
323     if (ePackageItemProvider == null)
324     {
325       ePackageItemProvider = new EPackageItemProvider(this);
326     }
327
328     return ePackageItemProvider;
329   }
330
331   /**
332    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EParameter} instances.
333    * <!-- begin-user-doc -->
334    * <!-- end-user-doc -->
335    * @generated
336    */

337   protected EParameterItemProvider eParameterItemProvider;
338
339   /**
340    * This creates an adapter for a {@link org.eclipse.emf.ecore.EParameter}.
341    * <!-- begin-user-doc -->
342    * <!-- end-user-doc -->
343    * @generated
344    */

345   public Adapter createEParameterAdapter()
346   {
347     if (eParameterItemProvider == null)
348     {
349       eParameterItemProvider = new EParameterItemProvider(this);
350     }
351
352     return eParameterItemProvider;
353   }
354
355   /**
356    * This keeps track of the one adapter used for all {@link org.eclipse.emf.ecore.EReference} instances.
357    * <!-- begin-user-doc -->
358    * <!-- end-user-doc -->
359    * @generated
360    */

361   protected EReferenceItemProvider eReferenceItemProvider;
362
363   /**
364    * This creates an adapter for a {@link org.eclipse.emf.ecore.EReference}.
365    * <!-- begin-user-doc -->
366    * <!-- end-user-doc -->
367    * @generated
368    */

369   public Adapter createEReferenceAdapter()
370   {
371     if (eReferenceItemProvider == null)
372     {
373       eReferenceItemProvider = new EReferenceItemProvider(this);
374     }
375
376     return eReferenceItemProvider;
377   }
378
379   /**
380    * This keeps track of the one adapter used for all {@link java.util.Map.Entry} instances.
381    * <!-- begin-user-doc -->
382    * <!-- end-user-doc -->
383    * @generated
384    */

385   protected EStringToStringMapEntryItemProvider eStringToStringMapEntryItemProvider;
386
387   /**
388    * This creates an adapter for a {@link java.util.Map.Entry}.
389    * <!-- begin-user-doc -->
390    * <!-- end-user-doc -->
391    * @generated
392    */

393   public Adapter createEStringToStringMapEntryAdapter()
394   {
395     if (eStringToStringMapEntryItemProvider == null)
396     {
397       eStringToStringMapEntryItemProvider = new EStringToStringMapEntryItemProvider(this);
398     }
399
400     return eStringToStringMapEntryItemProvider;
401   }
402
403   /**
404    * This returns the root adapter factory that contains this factory.
405    * <!-- begin-user-doc -->
406    * <!-- end-user-doc -->
407    * @generated
408    */

409   public ComposeableAdapterFactory getRootAdapterFactory()
410   {
411     return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
412   }
413
414   /**
415    * This sets the composed adapter factory that contains this factory.
416    * <!-- begin-user-doc -->
417    * <!-- end-user-doc -->
418    * @generated
419    */

420   public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory)
421   {
422     this.parentAdapterFactory = parentAdapterFactory;
423   }
424
425   /**
426    * <!-- begin-user-doc -->
427    * <!-- end-user-doc -->
428    * @generated
429    */

430   public boolean isFactoryForType(Object JavaDoc type)
431   {
432     return supportedTypes.contains(type) || super.isFactoryForType(type);
433   }
434
435   /**
436    * This implementation substitutes the factory itself as the key for the adapter.
437    * <!-- begin-user-doc -->
438    * <!-- end-user-doc -->
439    * @generated
440    */

441   public Adapter adapt(Notifier notifier, Object JavaDoc type)
442   {
443     return super.adapt(notifier, this);
444   }
445
446   /**
447    * <!-- begin-user-doc -->
448    * <!-- end-user-doc -->
449    * @generated
450    */

451   public Object JavaDoc adapt(Object JavaDoc object, Object JavaDoc type)
452   {
453     if (isFactoryForType(type))
454     {
455       Object JavaDoc adapter = super.adapt(object, type);
456       if (!(type instanceof Class JavaDoc) || (((Class JavaDoc)type).isInstance(adapter)))
457       {
458         return adapter;
459       }
460     }
461
462     return null;
463   }
464
465   /**
466    * This adds a listener.
467    * <!-- begin-user-doc -->
468    * <!-- end-user-doc -->
469    * @generated
470    */

471   public void addListener(INotifyChangedListener notifyChangedListener)
472   {
473     changeNotifier.addListener(notifyChangedListener);
474   }
475
476   /**
477    * This removes a listener.
478    * <!-- begin-user-doc -->
479    * <!-- end-user-doc -->
480    * @generated
481    */

482   public void removeListener(INotifyChangedListener notifyChangedListener)
483   {
484     changeNotifier.removeListener(notifyChangedListener);
485   }
486
487   /**
488    * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
489    * <!-- begin-user-doc -->
490    * <!-- end-user-doc -->
491    * @generated
492    */

493   public void fireNotifyChanged(Notification notification)
494   {
495     changeNotifier.fireNotifyChanged(notification);
496
497     if (parentAdapterFactory != null)
498     {
499       parentAdapterFactory.fireNotifyChanged(notification);
500     }
501   }
502
503   /**
504    * This disposes all of the item providers created by this factory.
505    * <!-- begin-user-doc -->
506    * <!-- end-user-doc -->
507    * @generated
508    */

509   public void dispose()
510   {
511     if (eAttributeItemProvider != null) eAttributeItemProvider.dispose();
512     if (eAnnotationItemProvider != null) eAnnotationItemProvider.dispose();
513     if (eClassItemProvider != null) eClassItemProvider.dispose();
514     if (eDataTypeItemProvider != null) eDataTypeItemProvider.dispose();
515     if (eEnumItemProvider != null) eEnumItemProvider.dispose();
516     if (eEnumLiteralItemProvider != null) eEnumLiteralItemProvider.dispose();
517     if (eFactoryItemProvider != null) eFactoryItemProvider.dispose();
518     if (eObjectItemProvider != null) eObjectItemProvider.dispose();
519     if (eOperationItemProvider != null) eOperationItemProvider.dispose();
520     if (ePackageItemProvider != null) ePackageItemProvider.dispose();
521     if (eParameterItemProvider != null) eParameterItemProvider.dispose();
522     if (eReferenceItemProvider != null) eReferenceItemProvider.dispose();
523     if (eStringToStringMapEntryItemProvider != null) eStringToStringMapEntryItemProvider.dispose();
524   }
525
526 }
527
Popular Tags