KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > change > provider > ChangeItemProviderAdapterFactory


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

17 package org.eclipse.emf.ecore.change.provider;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Collection JavaDoc;
21
22 import org.eclipse.emf.common.notify.Adapter;
23 import org.eclipse.emf.common.notify.Notification;
24 import org.eclipse.emf.common.notify.Notifier;
25 import org.eclipse.emf.ecore.change.util.ChangeAdapterFactory;
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 ChangeItemProviderAdapterFactory extends ChangeAdapterFactory 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 ChangeItemProviderAdapterFactory()
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.ecore.change.ChangeDescription} instances.
90    * <!-- begin-user-doc -->
91    * <!-- end-user-doc -->
92    * @generated
93    */

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

102   public Adapter createChangeDescriptionAdapter()
103   {
104     if (changeDescriptionItemProvider == null)
105     {
106       changeDescriptionItemProvider = new ChangeDescriptionItemProvider(this);
107     }
108
109     return changeDescriptionItemProvider;
110   }
111
112   /**
113    * This keeps track of the one adapter used for all {@link java.util.Map.Entry} instances.
114    * <!-- begin-user-doc -->
115    * <!-- end-user-doc -->
116    * @generated
117    */

118   protected EObjectToChangesMapEntryItemProvider eObjectToChangesMapEntryItemProvider;
119
120   /**
121    * This creates an adapter for a {@link java.util.Map.Entry}.
122    * <!-- begin-user-doc -->
123    * <!-- end-user-doc -->
124    * @generated
125    */

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

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

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

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

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

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

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

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

222   public Adapter createFeatureMapEntryAdapter()
223   {
224     if (featureMapEntryItemProvider == null)
225     {
226       featureMapEntryItemProvider = new FeatureMapEntryItemProvider(this);
227     }
228
229     return featureMapEntryItemProvider;
230   }
231
232   /**
233    * This returns the root adapter factory that contains this factory.
234    * <!-- begin-user-doc -->
235    * <!-- end-user-doc -->
236    * @generated
237    */

238   public ComposeableAdapterFactory getRootAdapterFactory()
239   {
240     return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
241   }
242
243   /**
244    * This sets the composed adapter factory that contains this factory.
245    * <!-- begin-user-doc -->
246    * <!-- end-user-doc -->
247    * @generated
248    */

249   public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory)
250   {
251     this.parentAdapterFactory = parentAdapterFactory;
252   }
253
254   /**
255    * <!-- begin-user-doc -->
256    * <!-- end-user-doc -->
257    * @generated
258    */

259   public boolean isFactoryForType(Object JavaDoc type)
260   {
261     return supportedTypes.contains(type) || super.isFactoryForType(type);
262   }
263
264   /**
265    * This implementation substitutes the factory itself as the key for the adapter.
266    * <!-- begin-user-doc -->
267    * <!-- end-user-doc -->
268    * @generated
269    */

270   public Adapter adapt(Notifier notifier, Object JavaDoc type)
271   {
272     return super.adapt(notifier, this);
273   }
274
275   /**
276    * <!-- begin-user-doc -->
277    * <!-- end-user-doc -->
278    * @generated
279    */

280   public Object JavaDoc adapt(Object JavaDoc object, Object JavaDoc type)
281   {
282     if (isFactoryForType(type))
283     {
284       Object JavaDoc adapter = super.adapt(object, type);
285       if (!(type instanceof Class JavaDoc) || (((Class JavaDoc)type).isInstance(adapter)))
286       {
287         return adapter;
288       }
289     }
290
291     return null;
292   }
293
294   /**
295    * This adds a listener.
296    * <!-- begin-user-doc -->
297    * <!-- end-user-doc -->
298    * @generated
299    */

300   public void addListener(INotifyChangedListener notifyChangedListener)
301   {
302     changeNotifier.addListener(notifyChangedListener);
303   }
304
305   /**
306    * This removes a listener.
307    * <!-- begin-user-doc -->
308    * <!-- end-user-doc -->
309    * @generated
310    */

311   public void removeListener(INotifyChangedListener notifyChangedListener)
312   {
313     changeNotifier.removeListener(notifyChangedListener);
314   }
315
316   /**
317    * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
318    * <!-- begin-user-doc -->
319    * <!-- end-user-doc -->
320    * @generated
321    */

322   public void fireNotifyChanged(Notification notification)
323   {
324     changeNotifier.fireNotifyChanged(notification);
325
326     if (parentAdapterFactory != null)
327     {
328       parentAdapterFactory.fireNotifyChanged(notification);
329     }
330   }
331
332   /**
333    * This disposes all of the item providers created by this factory.
334    * <!-- begin-user-doc -->
335    * <!-- end-user-doc -->
336    * @generated
337    */

338   public void dispose()
339   {
340     if (changeDescriptionItemProvider != null) changeDescriptionItemProvider.dispose();
341     if (eObjectToChangesMapEntryItemProvider != null) eObjectToChangesMapEntryItemProvider.dispose();
342     if (featureChangeItemProvider != null) featureChangeItemProvider.dispose();
343     if (listChangeItemProvider != null) listChangeItemProvider.dispose();
344     if (resourceChangeItemProvider != null) resourceChangeItemProvider.dispose();
345     if (featureMapEntryItemProvider != null) featureMapEntryItemProvider.dispose();
346   }
347
348 }
349
Popular Tags