KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2xml > provider > Ecore2XMLItemProviderAdapterFactory


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2005 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: Ecore2XMLItemProviderAdapterFactory.java,v 1.2 2005/06/21 16:16:58 khussey Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2xml.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
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 import org.eclipse.emf.mapping.ecore2xml.util.Ecore2XMLAdapterFactory;
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 Ecore2XMLItemProviderAdapterFactory extends Ecore2XMLAdapterFactory 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 Ecore2XMLItemProviderAdapterFactory()
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.mapping.ecore2xml.XMLInfo} instances.
92    * <!-- begin-user-doc -->
93    * <!-- end-user-doc -->
94    * @generated
95    */

96   protected XMLInfoItemProvider xmlInfoItemProvider;
97
98   /**
99    * This creates an adapter for a {@link org.eclipse.emf.mapping.ecore2xml.XMLInfo}.
100    * <!-- begin-user-doc -->
101    * <!-- end-user-doc -->
102    * @generated
103    */

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

120   protected XMLMapItemProvider xmlMapItemProvider;
121
122   /**
123    * This creates an adapter for a {@link org.eclipse.emf.mapping.ecore2xml.XMLMap}.
124    * <!-- begin-user-doc -->
125    * <!-- end-user-doc -->
126    * @generated
127    */

128   public Adapter createXMLMapAdapter()
129   {
130     if (xmlMapItemProvider == null)
131     {
132       xmlMapItemProvider = new XMLMapItemProvider(this);
133     }
134
135     return xmlMapItemProvider;
136   }
137
138   /**
139    * This keeps track of the one adapter used for all {@link java.util.Map.Entry} instances.
140    * <!-- begin-user-doc -->
141    * <!-- end-user-doc -->
142    * @generated
143    */

144   protected ENamedElementToXMLInfoMapEntryItemProvider eNamedElementToXMLInfoMapEntryItemProvider;
145
146   /**
147    * This creates an adapter for a {@link java.util.Map.Entry}.
148    * <!-- begin-user-doc -->
149    * <!-- end-user-doc -->
150    * @generated
151    */

152   public Adapter createENamedElementToXMLInfoMapEntryAdapter()
153   {
154     if (eNamedElementToXMLInfoMapEntryItemProvider == null)
155     {
156       eNamedElementToXMLInfoMapEntryItemProvider = new ENamedElementToXMLInfoMapEntryItemProvider(this);
157     }
158
159     return eNamedElementToXMLInfoMapEntryItemProvider;
160   }
161
162   /**
163    * This returns the root adapter factory that contains this factory.
164    * <!-- begin-user-doc -->
165    * <!-- end-user-doc -->
166    * @generated
167    */

168   public ComposeableAdapterFactory getRootAdapterFactory()
169   {
170     return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
171   }
172
173   /**
174    * This sets the composed adapter factory that contains this factory.
175    * <!-- begin-user-doc -->
176    * <!-- end-user-doc -->
177    * @generated
178    */

179   public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory)
180   {
181     this.parentAdapterFactory = parentAdapterFactory;
182   }
183
184   /**
185    * <!-- begin-user-doc -->
186    * <!-- end-user-doc -->
187    * @generated
188    */

189   public boolean isFactoryForType(Object JavaDoc type)
190   {
191     return supportedTypes.contains(type) || super.isFactoryForType(type);
192   }
193
194   /**
195    * This implementation substitutes the factory itself as the key for the adapter.
196    * <!-- begin-user-doc -->
197    * <!-- end-user-doc -->
198    * @generated
199    */

200   public Adapter adapt(Notifier notifier, Object JavaDoc type)
201   {
202     return super.adapt(notifier, this);
203   }
204
205   /**
206    * <!-- begin-user-doc -->
207    * <!-- end-user-doc -->
208    * @generated
209    */

210   public Object JavaDoc adapt(Object JavaDoc object, Object JavaDoc type)
211   {
212     if (isFactoryForType(type))
213     {
214       Object JavaDoc adapter = super.adapt(object, type);
215       if (!(type instanceof Class JavaDoc) || (((Class JavaDoc)type).isInstance(adapter)))
216       {
217         return adapter;
218       }
219     }
220
221     return null;
222   }
223
224   /**
225    * This adds a listener.
226    * <!-- begin-user-doc -->
227    * <!-- end-user-doc -->
228    * @generated
229    */

230   public void addListener(INotifyChangedListener notifyChangedListener)
231   {
232     changeNotifier.addListener(notifyChangedListener);
233   }
234
235   /**
236    * This removes a listener.
237    * <!-- begin-user-doc -->
238    * <!-- end-user-doc -->
239    * @generated
240    */

241   public void removeListener(INotifyChangedListener notifyChangedListener)
242   {
243     changeNotifier.removeListener(notifyChangedListener);
244   }
245
246   /**
247    * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
248    * <!-- begin-user-doc -->
249    * <!-- end-user-doc -->
250    * @generated
251    */

252   public void fireNotifyChanged(Notification notification)
253   {
254     changeNotifier.fireNotifyChanged(notification);
255
256     if (parentAdapterFactory != null)
257     {
258       parentAdapterFactory.fireNotifyChanged(notification);
259     }
260   }
261
262   /**
263    * This disposes all of the item providers created by this factory.
264    * <!-- begin-user-doc -->
265    * <!-- end-user-doc -->
266    * @generated
267    */

268   public void dispose()
269   {
270     if (xmlInfoItemProvider != null) xmlInfoItemProvider.dispose();
271     if (xmlMapItemProvider != null) xmlMapItemProvider.dispose();
272     if (eNamedElementToXMLInfoMapEntryItemProvider != null) eNamedElementToXMLInfoMapEntryItemProvider.dispose();
273   }
274
275 }
276
Popular Tags