1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTBase.provider; |
8 | |
9 | import QVTBase.util.QVTBaseAdapterFactory; |
10 | |
11 | import java.util.ArrayList; |
12 | import java.util.Collection; |
13 | |
14 | import org.eclipse.emf.common.notify.Adapter; |
15 | import org.eclipse.emf.common.notify.Notification; |
16 | import org.eclipse.emf.common.notify.Notifier; |
17 | |
18 | import org.eclipse.emf.edit.provider.ChangeNotifier; |
19 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
20 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
21 | import org.eclipse.emf.edit.provider.IChangeNotifier; |
22 | import org.eclipse.emf.edit.provider.IDisposable; |
23 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
24 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
25 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
26 | import org.eclipse.emf.edit.provider.INotifyChangedListener; |
27 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
28 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
29 | |
30 | /** |
31 | * This is the factory that is used to provide the interfaces needed to support Viewers. |
32 | * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. |
33 | * The adapters also support Eclipse property sheets. |
34 | * Note that most of the adapters are shared among multiple instances. |
35 | * <!-- begin-user-doc --> |
36 | * <!-- end-user-doc --> |
37 | * @generated |
38 | */ |
39 | public class QVTBaseItemProviderAdapterFactory extends QVTBaseAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { |
40 | /** |
41 | * This keeps track of the root adapter factory that delegates to this adapter factory. |
42 | * <!-- begin-user-doc --> |
43 | * <!-- end-user-doc --> |
44 | * @generated |
45 | */ |
46 | protected ComposedAdapterFactory parentAdapterFactory; |
47 | |
48 | /** |
49 | * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @generated |
53 | */ |
54 | protected IChangeNotifier changeNotifier = new ChangeNotifier(); |
55 | |
56 | /** |
57 | * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @generated |
61 | */ |
62 | protected Collection<Object> supportedTypes = new ArrayList<Object>(); |
63 | |
64 | /** |
65 | * This constructs an instance. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @generated |
69 | */ |
70 | public QVTBaseItemProviderAdapterFactory() { |
71 | supportedTypes.add(IEditingDomainItemProvider.class); |
72 | supportedTypes.add(IStructuredItemContentProvider.class); |
73 | supportedTypes.add(ITreeItemContentProvider.class); |
74 | supportedTypes.add(IItemLabelProvider.class); |
75 | supportedTypes.add(IItemPropertySource.class); |
76 | } |
77 | |
78 | /** |
79 | * This keeps track of the one adapter used for all {@link QVTBase.Function} instances. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected FunctionItemProvider functionItemProvider; |
85 | |
86 | /** |
87 | * This creates an adapter for a {@link QVTBase.Function}. |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @generated |
91 | */ |
92 | @Override |
93 | public Adapter createFunctionAdapter() { |
94 | if (functionItemProvider == null) { |
95 | functionItemProvider = new FunctionItemProvider(this); |
96 | } |
97 | |
98 | return functionItemProvider; |
99 | } |
100 | |
101 | /** |
102 | * This keeps track of the one adapter used for all {@link QVTBase.FunctionParameter} instances. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | protected FunctionParameterItemProvider functionParameterItemProvider; |
108 | |
109 | /** |
110 | * This creates an adapter for a {@link QVTBase.FunctionParameter}. |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | @Override |
116 | public Adapter createFunctionParameterAdapter() { |
117 | if (functionParameterItemProvider == null) { |
118 | functionParameterItemProvider = new FunctionParameterItemProvider(this); |
119 | } |
120 | |
121 | return functionParameterItemProvider; |
122 | } |
123 | |
124 | /** |
125 | * This keeps track of the one adapter used for all {@link QVTBase.Pattern} instances. |
126 | * <!-- begin-user-doc --> |
127 | * <!-- end-user-doc --> |
128 | * @generated |
129 | */ |
130 | protected PatternItemProvider patternItemProvider; |
131 | |
132 | /** |
133 | * This creates an adapter for a {@link QVTBase.Pattern}. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Adapter createPatternAdapter() { |
140 | if (patternItemProvider == null) { |
141 | patternItemProvider = new PatternItemProvider(this); |
142 | } |
143 | |
144 | return patternItemProvider; |
145 | } |
146 | |
147 | /** |
148 | * This keeps track of the one adapter used for all {@link QVTBase.Predicate} instances. |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | protected PredicateItemProvider predicateItemProvider; |
154 | |
155 | /** |
156 | * This creates an adapter for a {@link QVTBase.Predicate}. |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | @Override |
162 | public Adapter createPredicateAdapter() { |
163 | if (predicateItemProvider == null) { |
164 | predicateItemProvider = new PredicateItemProvider(this); |
165 | } |
166 | |
167 | return predicateItemProvider; |
168 | } |
169 | |
170 | /** |
171 | * This keeps track of the one adapter used for all {@link QVTBase.Transformation} instances. |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | protected TransformationItemProvider transformationItemProvider; |
177 | |
178 | /** |
179 | * This creates an adapter for a {@link QVTBase.Transformation}. |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | @Override |
185 | public Adapter createTransformationAdapter() { |
186 | if (transformationItemProvider == null) { |
187 | transformationItemProvider = new TransformationItemProvider(this); |
188 | } |
189 | |
190 | return transformationItemProvider; |
191 | } |
192 | |
193 | /** |
194 | * This keeps track of the one adapter used for all {@link QVTBase.TypedModel} instances. |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | protected TypedModelItemProvider typedModelItemProvider; |
200 | |
201 | /** |
202 | * This creates an adapter for a {@link QVTBase.TypedModel}. |
203 | * <!-- begin-user-doc --> |
204 | * <!-- end-user-doc --> |
205 | * @generated |
206 | */ |
207 | @Override |
208 | public Adapter createTypedModelAdapter() { |
209 | if (typedModelItemProvider == null) { |
210 | typedModelItemProvider = new TypedModelItemProvider(this); |
211 | } |
212 | |
213 | return typedModelItemProvider; |
214 | } |
215 | |
216 | /** |
217 | * This returns the root adapter factory that contains this factory. |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | public ComposeableAdapterFactory getRootAdapterFactory() { |
223 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
224 | } |
225 | |
226 | /** |
227 | * This sets the composed adapter factory that contains this factory. |
228 | * <!-- begin-user-doc --> |
229 | * <!-- end-user-doc --> |
230 | * @generated |
231 | */ |
232 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
233 | this.parentAdapterFactory = parentAdapterFactory; |
234 | } |
235 | |
236 | /** |
237 | * <!-- begin-user-doc --> |
238 | * <!-- end-user-doc --> |
239 | * @generated |
240 | */ |
241 | @Override |
242 | public boolean isFactoryForType(Object type) { |
243 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
244 | } |
245 | |
246 | /** |
247 | * This implementation substitutes the factory itself as the key for the adapter. |
248 | * <!-- begin-user-doc --> |
249 | * <!-- end-user-doc --> |
250 | * @generated |
251 | */ |
252 | @Override |
253 | public Adapter adapt(Notifier notifier, Object type) { |
254 | return super.adapt(notifier, this); |
255 | } |
256 | |
257 | /** |
258 | * <!-- begin-user-doc --> |
259 | * <!-- end-user-doc --> |
260 | * @generated |
261 | */ |
262 | @Override |
263 | public Object adapt(Object object, Object type) { |
264 | if (isFactoryForType(type)) { |
265 | Object adapter = super.adapt(object, type); |
266 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
267 | return adapter; |
268 | } |
269 | } |
270 | |
271 | return null; |
272 | } |
273 | |
274 | /** |
275 | * This adds a listener. |
276 | * <!-- begin-user-doc --> |
277 | * <!-- end-user-doc --> |
278 | * @generated |
279 | */ |
280 | public void addListener(INotifyChangedListener notifyChangedListener) { |
281 | changeNotifier.addListener(notifyChangedListener); |
282 | } |
283 | |
284 | /** |
285 | * This removes a listener. |
286 | * <!-- begin-user-doc --> |
287 | * <!-- end-user-doc --> |
288 | * @generated |
289 | */ |
290 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
291 | changeNotifier.removeListener(notifyChangedListener); |
292 | } |
293 | |
294 | /** |
295 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
296 | * <!-- begin-user-doc --> |
297 | * <!-- end-user-doc --> |
298 | * @generated |
299 | */ |
300 | public void fireNotifyChanged(Notification notification) { |
301 | changeNotifier.fireNotifyChanged(notification); |
302 | |
303 | if (parentAdapterFactory != null) { |
304 | parentAdapterFactory.fireNotifyChanged(notification); |
305 | } |
306 | } |
307 | |
308 | /** |
309 | * This disposes all of the item providers created by this factory. |
310 | * <!-- begin-user-doc --> |
311 | * <!-- end-user-doc --> |
312 | * @generated |
313 | */ |
314 | public void dispose() { |
315 | if (functionItemProvider != null) functionItemProvider.dispose(); |
316 | if (functionParameterItemProvider != null) functionParameterItemProvider.dispose(); |
317 | if (patternItemProvider != null) patternItemProvider.dispose(); |
318 | if (predicateItemProvider != null) predicateItemProvider.dispose(); |
319 | if (transformationItemProvider != null) transformationItemProvider.dispose(); |
320 | if (typedModelItemProvider != null) typedModelItemProvider.dispose(); |
321 | } |
322 | |
323 | } |