KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > editor > Doml > provider > DomlItemProviderAdapterFactory


1 /**
2  * <copyright>
3  * </copyright>
4  *
5  * $Id$
6  */

7 package org.enhydra.dods.editor.Doml.provider;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Collection JavaDoc;
11
12 import org.eclipse.emf.common.notify.Adapter;
13 import org.eclipse.emf.common.notify.Notification;
14 import org.eclipse.emf.common.notify.Notifier;
15
16 import org.eclipse.emf.edit.provider.ChangeNotifier;
17 import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
18 import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
19 import org.eclipse.emf.edit.provider.IChangeNotifier;
20 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
21 import org.eclipse.emf.edit.provider.IItemLabelProvider;
22 import org.eclipse.emf.edit.provider.IItemPropertySource;
23 import org.eclipse.emf.edit.provider.INotifyChangedListener;
24 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
25 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
26
27 import org.enhydra.dods.editor.Doml.util.DomlAdapterFactory;
28
29 /**
30  * This is the factory that is used to provide the interfaces needed to support Viewers.
31  * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
32  * The adapters also support Eclipse property sheets.
33  * Note that most of the adapters are shared among multiple instances.
34  * <!-- begin-user-doc -->
35  * <!-- end-user-doc -->
36  * @generated
37  */

38 public class DomlItemProviderAdapterFactory extends DomlAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier {
39     /**
40      * This keeps track of the root adapter factory that delegates to this adapter factory.
41      * <!-- begin-user-doc -->
42      * <!-- end-user-doc -->
43      * @generated
44      */

45     protected ComposedAdapterFactory parentAdapterFactory;
46
47     /**
48      * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
49      * <!-- begin-user-doc -->
50      * <!-- end-user-doc -->
51      * @generated
52      */

53     protected IChangeNotifier changeNotifier = new ChangeNotifier();
54
55     /**
56      * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
57      * <!-- begin-user-doc -->
58      * <!-- end-user-doc -->
59      * @generated
60      */

61     protected Collection JavaDoc supportedTypes = new ArrayList JavaDoc();
62
63     /**
64      * This constructs an instance.
65      * <!-- begin-user-doc -->
66      * <!-- end-user-doc -->
67      * @generated
68      */

69     public DomlItemProviderAdapterFactory() {
70         supportedTypes.add(IStructuredItemContentProvider.class);
71         supportedTypes.add(ITreeItemContentProvider.class);
72         supportedTypes.add(IItemPropertySource.class);
73         supportedTypes.add(IEditingDomainItemProvider.class);
74         supportedTypes.add(IItemLabelProvider.class);
75     }
76
77     /**
78      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.ColumnType} instances.
79      * <!-- begin-user-doc -->
80      * <!-- end-user-doc -->
81      * @generated
82      */

83     protected ColumnTypeItemProvider columnTypeItemProvider;
84
85     /**
86      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.ColumnType}.
87      * <!-- begin-user-doc -->
88      * <!-- end-user-doc -->
89      * @generated
90      */

91     public Adapter createColumnTypeAdapter() {
92         if (columnTypeItemProvider == null) {
93             columnTypeItemProvider = new ColumnTypeItemProvider(this);
94         }
95
96         return columnTypeItemProvider;
97     }
98
99     /**
100      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.DatabaseType} instances.
101      * <!-- begin-user-doc -->
102      * <!-- end-user-doc -->
103      * @generated
104      */

105     protected DatabaseTypeItemProvider databaseTypeItemProvider;
106
107     /**
108      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.DatabaseType}.
109      * <!-- begin-user-doc -->
110      * <!-- end-user-doc -->
111      * @generated
112      */

113     public Adapter createDatabaseTypeAdapter() {
114         if (databaseTypeItemProvider == null) {
115             databaseTypeItemProvider = new DatabaseTypeItemProvider(this);
116         }
117
118         return databaseTypeItemProvider;
119     }
120
121     /**
122      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.DocumentRoot} instances.
123      * <!-- begin-user-doc -->
124      * <!-- end-user-doc -->
125      * @generated
126      */

127     protected DocumentRootItemProvider documentRootItemProvider;
128
129     /**
130      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.DocumentRoot}.
131      * <!-- begin-user-doc -->
132      * <!-- end-user-doc -->
133      * @generated
134      */

135     public Adapter createDocumentRootAdapter() {
136         if (documentRootItemProvider == null) {
137             documentRootItemProvider = new DocumentRootItemProvider(this);
138         }
139
140         return documentRootItemProvider;
141     }
142
143     /**
144      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.DomlType} instances.
145      * <!-- begin-user-doc -->
146      * <!-- end-user-doc -->
147      * @generated
148      */

149     protected DomlTypeItemProvider domlTypeItemProvider;
150
151     /**
152      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.DomlType}.
153      * <!-- begin-user-doc -->
154      * <!-- end-user-doc -->
155      * @generated
156      */

157     public Adapter createDomlTypeAdapter() {
158         if (domlTypeItemProvider == null) {
159             domlTypeItemProvider = new DomlTypeItemProvider(this);
160         }
161
162         return domlTypeItemProvider;
163     }
164
165     /**
166      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.IndexColumnType} instances.
167      * <!-- begin-user-doc -->
168      * <!-- end-user-doc -->
169      * @generated
170      */

171     protected IndexColumnTypeItemProvider indexColumnTypeItemProvider;
172
173     /**
174      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.IndexColumnType}.
175      * <!-- begin-user-doc -->
176      * <!-- end-user-doc -->
177      * @generated
178      */

179     public Adapter createIndexColumnTypeAdapter() {
180         if (indexColumnTypeItemProvider == null) {
181             indexColumnTypeItemProvider = new IndexColumnTypeItemProvider(this);
182         }
183
184         return indexColumnTypeItemProvider;
185     }
186
187     /**
188      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.IndexType} instances.
189      * <!-- begin-user-doc -->
190      * <!-- end-user-doc -->
191      * @generated
192      */

193     protected IndexTypeItemProvider indexTypeItemProvider;
194
195     /**
196      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.IndexType}.
197      * <!-- begin-user-doc -->
198      * <!-- end-user-doc -->
199      * @generated
200      */

201     public Adapter createIndexTypeAdapter() {
202         if (indexTypeItemProvider == null) {
203             indexTypeItemProvider = new IndexTypeItemProvider(this);
204         }
205
206         return indexTypeItemProvider;
207     }
208
209     /**
210      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.PackageType} instances.
211      * <!-- begin-user-doc -->
212      * <!-- end-user-doc -->
213      * @generated
214      */

215     protected PackageTypeItemProvider packageTypeItemProvider;
216
217     /**
218      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.PackageType}.
219      * <!-- begin-user-doc -->
220      * <!-- end-user-doc -->
221      * @generated
222      */

223     public Adapter createPackageTypeAdapter() {
224         if (packageTypeItemProvider == null) {
225             packageTypeItemProvider = new PackageTypeItemProvider(this);
226         }
227
228         return packageTypeItemProvider;
229     }
230
231     /**
232      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.ReferenceObjectType} instances.
233      * <!-- begin-user-doc -->
234      * <!-- end-user-doc -->
235      * @generated
236      */

237     protected ReferenceObjectTypeItemProvider referenceObjectTypeItemProvider;
238
239     /**
240      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.ReferenceObjectType}.
241      * <!-- begin-user-doc -->
242      * <!-- end-user-doc -->
243      * @generated
244      */

245     public Adapter createReferenceObjectTypeAdapter() {
246         if (referenceObjectTypeItemProvider == null) {
247             referenceObjectTypeItemProvider = new ReferenceObjectTypeItemProvider(this);
248         }
249
250         return referenceObjectTypeItemProvider;
251     }
252
253     /**
254      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.TableType} instances.
255      * <!-- begin-user-doc -->
256      * <!-- end-user-doc -->
257      * @generated
258      */

259     protected TableTypeItemProvider tableTypeItemProvider;
260
261     /**
262      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.TableType}.
263      * <!-- begin-user-doc -->
264      * <!-- end-user-doc -->
265      * @generated
266      */

267     public Adapter createTableTypeAdapter() {
268         if (tableTypeItemProvider == null) {
269             tableTypeItemProvider = new TableTypeItemProvider(this);
270         }
271
272         return tableTypeItemProvider;
273     }
274
275     /**
276      * This keeps track of the one adapter used for all {@link org.enhydra.dods.editor.Doml.TypeType} instances.
277      * <!-- begin-user-doc -->
278      * <!-- end-user-doc -->
279      * @generated
280      */

281     protected TypeTypeItemProvider typeTypeItemProvider;
282
283     /**
284      * This creates an adapter for a {@link org.enhydra.dods.editor.Doml.TypeType}.
285      * <!-- begin-user-doc -->
286      * <!-- end-user-doc -->
287      * @generated
288      */

289     public Adapter createTypeTypeAdapter() {
290         if (typeTypeItemProvider == null) {
291             typeTypeItemProvider = new TypeTypeItemProvider(this);
292         }
293
294         return typeTypeItemProvider;
295     }
296
297     /**
298      * This returns the root adapter factory that contains this factory.
299      * <!-- begin-user-doc -->
300      * <!-- end-user-doc -->
301      * @generated
302      */

303     public ComposeableAdapterFactory getRootAdapterFactory() {
304         return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
305     }
306
307     /**
308      * This sets the composed adapter factory that contains this factory.
309      * <!-- begin-user-doc -->
310      * <!-- end-user-doc -->
311      * @generated
312      */

313     public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
314         this.parentAdapterFactory = parentAdapterFactory;
315     }
316
317     /**
318      * <!-- begin-user-doc -->
319      * <!-- end-user-doc -->
320      * @generated
321      */

322     public boolean isFactoryForType(Object JavaDoc type) {
323         return supportedTypes.contains(type) || super.isFactoryForType(type);
324     }
325
326     /**
327      * This implementation substitutes the factory itself as the key for the adapter.
328      * <!-- begin-user-doc -->
329      * <!-- end-user-doc -->
330      * @generated
331      */

332     public Adapter adapt(Notifier notifier, Object JavaDoc type) {
333         return super.adapt(notifier, this);
334     }
335
336     /**
337      * <!-- begin-user-doc -->
338      * <!-- end-user-doc -->
339      * @generated
340      */

341     public Object JavaDoc adapt(Object JavaDoc object, Object JavaDoc type) {
342         if (isFactoryForType(type)) {
343             Object JavaDoc adapter = super.adapt(object, type);
344             if (!(type instanceof Class JavaDoc) || (((Class JavaDoc)type).isInstance(adapter))) {
345                 return adapter;
346             }
347         }
348
349         return null;
350     }
351
352     /**
353      * This adds a listener.
354      * <!-- begin-user-doc -->
355      * <!-- end-user-doc -->
356      * @generated
357      */

358     public void addListener(INotifyChangedListener notifyChangedListener) {
359         changeNotifier.addListener(notifyChangedListener);
360     }
361
362     /**
363      * This removes a listener.
364      * <!-- begin-user-doc -->
365      * <!-- end-user-doc -->
366      * @generated
367      */

368     public void removeListener(INotifyChangedListener notifyChangedListener) {
369         changeNotifier.removeListener(notifyChangedListener);
370     }
371
372     /**
373      * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
374      * <!-- begin-user-doc -->
375      * <!-- end-user-doc -->
376      * @generated
377      */

378     public void fireNotifyChanged(Notification notification) {
379         changeNotifier.fireNotifyChanged(notification);
380
381         if (parentAdapterFactory != null) {
382             parentAdapterFactory.fireNotifyChanged(notification);
383         }
384     }
385
386 }
387
Popular Tags