KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

47 public class GenModelItemProviderAdapterFactory extends GenModelAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable
48 {
49   /**
50    * This keeps track of the root adapter factory that delegates to this adapter factory.
51    * <!-- begin-user-doc -->
52    * <!-- end-user-doc -->
53    * @generated
54    */

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

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

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

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

94   protected GenModelItemProvider genModelItemProvider;
95
96   /**
97    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenModel}.
98    * <!-- begin-user-doc -->
99    * <!-- end-user-doc -->
100    * @generated
101    */

102   public Adapter createGenModelAdapter()
103   {
104     if (genModelItemProvider == null)
105     {
106       genModelItemProvider = new GenModelItemProvider(this);
107     }
108
109     return genModelItemProvider;
110   }
111
112   /**
113    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenPackage} instances.
114    * <!-- begin-user-doc -->
115    * <!-- end-user-doc -->
116    * @generated
117    */

118   protected GenPackageItemProvider genPackageItemProvider;
119
120   /**
121    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenPackage}.
122    * <!-- begin-user-doc -->
123    * <!-- end-user-doc -->
124    * @generated
125    */

126   public Adapter createGenPackageAdapter()
127   {
128     if (genPackageItemProvider == null)
129     {
130       genPackageItemProvider = new GenPackageItemProvider(this);
131     }
132
133     return genPackageItemProvider;
134   }
135
136   /**
137    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenClass} instances.
138    * <!-- begin-user-doc -->
139    * <!-- end-user-doc -->
140    * @generated
141    */

142   protected GenClassItemProvider genClassItemProvider;
143
144   /**
145    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenClass}.
146    * <!-- begin-user-doc -->
147    * <!-- end-user-doc -->
148    * @generated
149    */

150   public Adapter createGenClassAdapter()
151   {
152     if (genClassItemProvider == null)
153     {
154       genClassItemProvider = new GenClassItemProvider(this);
155     }
156
157     return genClassItemProvider;
158   }
159
160   /**
161    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenFeature} instances.
162    * <!-- begin-user-doc -->
163    * <!-- end-user-doc -->
164    * @generated
165    */

166   protected GenFeatureItemProvider genFeatureItemProvider;
167
168   /**
169    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenFeature}.
170    * <!-- begin-user-doc -->
171    * <!-- end-user-doc -->
172    * @generated
173    */

174   public Adapter createGenFeatureAdapter()
175   {
176     if (genFeatureItemProvider == null)
177     {
178       genFeatureItemProvider = new GenFeatureItemProvider(this);
179     }
180
181     return genFeatureItemProvider;
182   }
183
184   /**
185    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenEnum} instances.
186    * <!-- begin-user-doc -->
187    * <!-- end-user-doc -->
188    * @generated
189    */

190   protected GenEnumItemProvider genEnumItemProvider;
191
192   /**
193    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenEnum}.
194    * <!-- begin-user-doc -->
195    * <!-- end-user-doc -->
196    * @generated
197    */

198   public Adapter createGenEnumAdapter()
199   {
200     if (genEnumItemProvider == null)
201     {
202       genEnumItemProvider = new GenEnumItemProvider(this);
203     }
204
205     return genEnumItemProvider;
206   }
207
208   /**
209    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenEnumLiteral} instances.
210    * <!-- begin-user-doc -->
211    * <!-- end-user-doc -->
212    * @generated
213    */

214   protected GenEnumLiteralItemProvider genEnumLiteralItemProvider;
215
216   /**
217    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenEnumLiteral}.
218    * <!-- begin-user-doc -->
219    * <!-- end-user-doc -->
220    * @generated
221    */

222   public Adapter createGenEnumLiteralAdapter()
223   {
224     if (genEnumLiteralItemProvider == null)
225     {
226       genEnumLiteralItemProvider = new GenEnumLiteralItemProvider(this);
227     }
228
229     return genEnumLiteralItemProvider;
230   }
231
232   /**
233    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenDataType} instances.
234    * <!-- begin-user-doc -->
235    * <!-- end-user-doc -->
236    * @generated
237    */

238   protected GenDataTypeItemProvider genDataTypeItemProvider;
239
240   /**
241    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenDataType}.
242    * <!-- begin-user-doc -->
243    * <!-- end-user-doc -->
244    * @generated
245    */

246   public Adapter createGenDataTypeAdapter()
247   {
248     if (genDataTypeItemProvider == null)
249     {
250       genDataTypeItemProvider = new GenDataTypeItemProvider(this);
251     }
252
253     return genDataTypeItemProvider;
254   }
255
256   /**
257    * This keeps track of the one adapter used for all {@link org.eclipse.emf.codegen.ecore.genmodel.GenOperation} instances.
258    * <!-- begin-user-doc -->
259    * <!-- end-user-doc -->
260    * @generated
261    */

262   protected GenOperationItemProvider genOperationItemProvider;
263
264   /**
265    * This creates an adapter for a {@link org.eclipse.emf.codegen.ecore.genmodel.GenOperation}.
266    * <!-- begin-user-doc -->
267    * <!-- end-user-doc -->
268    * @generated
269    */

270   public Adapter createGenOperationAdapter()
271   {
272     if (genOperationItemProvider == null)
273     {
274       genOperationItemProvider = new GenOperationItemProvider(this);
275     }
276
277     return genOperationItemProvider;
278   }
279
280   /**
281    * This returns the root adapter factory that contains this factory.
282    * <!-- begin-user-doc -->
283    * <!-- end-user-doc -->
284    * @generated
285    */

286   public ComposeableAdapterFactory getRootAdapterFactory()
287   {
288     return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
289   }
290
291   /**
292    * This sets the composed adapter factory that contains this factory.
293    * <!-- begin-user-doc -->
294    * <!-- end-user-doc -->
295    * @generated
296    */

297   public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory)
298   {
299     this.parentAdapterFactory = parentAdapterFactory;
300   }
301
302   /**
303    * <!-- begin-user-doc -->
304    * <!-- end-user-doc -->
305    * @generated
306    */

307   public boolean isFactoryForType(Object JavaDoc type)
308   {
309     return supportedTypes.contains(type) || super.isFactoryForType(type);
310   }
311
312   /**
313    * This implementation substitutes the factory itself as the key for the adapter.
314    * <!-- begin-user-doc -->
315    * <!-- end-user-doc -->
316    * @generated
317    */

318   public Adapter adapt(Notifier notifier, Object JavaDoc type)
319   {
320     return super.adapt(notifier, this);
321   }
322
323   /**
324    * <!-- begin-user-doc -->
325    * <!-- end-user-doc -->
326    * @generated
327    */

328   public Object JavaDoc adapt(Object JavaDoc object, Object JavaDoc type)
329   {
330     if (isFactoryForType(type))
331     {
332       Object JavaDoc adapter = super.adapt(object, type);
333       if (!(type instanceof Class JavaDoc) || (((Class JavaDoc)type).isInstance(adapter)))
334       {
335         return adapter;
336       }
337     }
338
339     return null;
340   }
341
342   /**
343    * This adds a listener.
344    * <!-- begin-user-doc -->
345    * <!-- end-user-doc -->
346    * @generated
347    */

348   public void addListener(INotifyChangedListener notifyChangedListener)
349   {
350     changeNotifier.addListener(notifyChangedListener);
351   }
352
353   /**
354    * This removes a listener.
355    * <!-- begin-user-doc -->
356    * <!-- end-user-doc -->
357    * @generated
358    */

359   public void removeListener(INotifyChangedListener notifyChangedListener)
360   {
361     changeNotifier.removeListener(notifyChangedListener);
362   }
363
364   /**
365    * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
366    * <!-- begin-user-doc -->
367    * <!-- end-user-doc -->
368    * @generated
369    */

370   public void fireNotifyChanged(Notification notification)
371   {
372     changeNotifier.fireNotifyChanged(notification);
373
374     if (parentAdapterFactory != null)
375     {
376       parentAdapterFactory.fireNotifyChanged(notification);
377     }
378   }
379
380   /**
381    * This disposes all of the item providers created by this factory.
382    * <!-- begin-user-doc -->
383    * <!-- end-user-doc -->
384    * @generated
385    */

386   public void dispose()
387   {
388     if (genModelItemProvider != null) genModelItemProvider.dispose();
389     if (genPackageItemProvider != null) genPackageItemProvider.dispose();
390     if (genClassItemProvider != null) genClassItemProvider.dispose();
391     if (genFeatureItemProvider != null) genFeatureItemProvider.dispose();
392     if (genEnumItemProvider != null) genEnumItemProvider.dispose();
393     if (genEnumLiteralItemProvider != null) genEnumLiteralItemProvider.dispose();
394     if (genDataTypeItemProvider != null) genDataTypeItemProvider.dispose();
395     if (genOperationItemProvider != null) genOperationItemProvider.dispose();
396   }
397
398 }
399
Popular Tags