KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > sdo > provider > SDOItemProviderAdapterFactory


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-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: SDOItemProviderAdapterFactory.java,v 1.5 2005/06/08 06:17:15 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.sdo.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.sdo.util.SDOAdapterFactory;
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
39
40 /**
41  * This is the factory that is used to provide the interfaces needed to support Viewers.
42  * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
43  * The adapters also support Eclipse property sheets.
44  * Note that most of the adapters are shared among multiple instances.
45  * <!-- begin-user-doc -->
46  * <!-- end-user-doc -->
47  * @generated
48  */

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

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

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

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

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

96   protected EChangeSummaryItemProvider eChangeSummaryItemProvider;
97
98   /**
99    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EChangeSummary}.
100    * <!-- begin-user-doc -->
101    * <!-- end-user-doc -->
102    * @generated
103    */

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

120   protected EChangeSummarySettingItemProvider eChangeSummarySettingItemProvider;
121
122   /**
123    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EChangeSummarySetting}.
124    * <!-- begin-user-doc -->
125    * <!-- end-user-doc -->
126    * @generated
127    */

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

144   protected EDataGraphItemProvider eDataGraphItemProvider;
145
146   /**
147    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EDataGraph}.
148    * <!-- begin-user-doc -->
149    * <!-- end-user-doc -->
150    * @generated
151    */

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

168   protected EDataObjectItemProvider eDataObjectItemProvider;
169
170   /**
171    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EDataObject}.
172    * <!-- begin-user-doc -->
173    * <!-- end-user-doc -->
174    * @generated
175    */

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

192   protected EPropertyItemProvider ePropertyItemProvider;
193
194   /**
195    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EProperty}.
196    * <!-- begin-user-doc -->
197    * <!-- end-user-doc -->
198    * @generated
199    */

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

216   protected ETypeItemProvider eTypeItemProvider;
217
218   /**
219    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EType}.
220    * <!-- begin-user-doc -->
221    * <!-- end-user-doc -->
222    * @generated
223    */

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

240   protected EDataObjectAnyTypeItemProvider eDataObjectAnyTypeItemProvider;
241
242   /**
243    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EDataObjectAnyType}.
244    * <!-- begin-user-doc -->
245    * <!-- end-user-doc -->
246    * @generated
247    */

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

264   protected EDataObjectSimpleAnyTypeItemProvider eDataObjectSimpleAnyTypeItemProvider;
265
266   /**
267    * This creates an adapter for a {@link org.eclipse.emf.ecore.sdo.EDataObjectSimpleAnyType}.
268    * <!-- begin-user-doc -->
269    * <!-- end-user-doc -->
270    * @generated
271    */

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

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

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

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

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

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

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

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

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

388   public void dispose()
389   {
390     if (eChangeSummaryItemProvider != null) eChangeSummaryItemProvider.dispose();
391     if (eChangeSummarySettingItemProvider != null) eChangeSummarySettingItemProvider.dispose();
392     if (eDataGraphItemProvider != null) eDataGraphItemProvider.dispose();
393     if (eDataObjectItemProvider != null) eDataObjectItemProvider.dispose();
394     if (ePropertyItemProvider != null) ePropertyItemProvider.dispose();
395     if (eTypeItemProvider != null) eTypeItemProvider.dispose();
396     if (eDataObjectAnyTypeItemProvider != null) eDataObjectAnyTypeItemProvider.dispose();
397     if (eDataObjectSimpleAnyTypeItemProvider != null) eDataObjectSimpleAnyTypeItemProvider.dispose();
398   }
399
400 }
401
Popular Tags