1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EMOF.provider; |
8 | |
9 | import EMOF.util.EMOFAdapterFactory; |
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 EMOFItemProviderAdapterFactory extends EMOFAdapterFactory 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 EMOFItemProviderAdapterFactory() { |
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 EMOF.Class} instances. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected ClassItemProvider classItemProvider; |
85 | |
86 | /** |
87 | * This creates an adapter for a {@link EMOF.Class}. |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @generated |
91 | */ |
92 | @Override |
93 | public Adapter createClassAdapter() { |
94 | if (classItemProvider == null) { |
95 | classItemProvider = new ClassItemProvider(this); |
96 | } |
97 | |
98 | return classItemProvider; |
99 | } |
100 | |
101 | /** |
102 | * This keeps track of the one adapter used for all {@link EMOF.Comment} instances. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | protected CommentItemProvider commentItemProvider; |
108 | |
109 | /** |
110 | * This creates an adapter for a {@link EMOF.Comment}. |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | @Override |
116 | public Adapter createCommentAdapter() { |
117 | if (commentItemProvider == null) { |
118 | commentItemProvider = new CommentItemProvider(this); |
119 | } |
120 | |
121 | return commentItemProvider; |
122 | } |
123 | |
124 | /** |
125 | * This keeps track of the one adapter used for all {@link EMOF.DataType} instances. |
126 | * <!-- begin-user-doc --> |
127 | * <!-- end-user-doc --> |
128 | * @generated |
129 | */ |
130 | protected DataTypeItemProvider dataTypeItemProvider; |
131 | |
132 | /** |
133 | * This creates an adapter for a {@link EMOF.DataType}. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Adapter createDataTypeAdapter() { |
140 | if (dataTypeItemProvider == null) { |
141 | dataTypeItemProvider = new DataTypeItemProvider(this); |
142 | } |
143 | |
144 | return dataTypeItemProvider; |
145 | } |
146 | |
147 | /** |
148 | * This keeps track of the one adapter used for all {@link EMOF.Enumeration} instances. |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | protected EnumerationItemProvider enumerationItemProvider; |
154 | |
155 | /** |
156 | * This creates an adapter for a {@link EMOF.Enumeration}. |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | @Override |
162 | public Adapter createEnumerationAdapter() { |
163 | if (enumerationItemProvider == null) { |
164 | enumerationItemProvider = new EnumerationItemProvider(this); |
165 | } |
166 | |
167 | return enumerationItemProvider; |
168 | } |
169 | |
170 | /** |
171 | * This keeps track of the one adapter used for all {@link EMOF.EnumerationLiteral} instances. |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | protected EnumerationLiteralItemProvider enumerationLiteralItemProvider; |
177 | |
178 | /** |
179 | * This creates an adapter for a {@link EMOF.EnumerationLiteral}. |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | @Override |
185 | public Adapter createEnumerationLiteralAdapter() { |
186 | if (enumerationLiteralItemProvider == null) { |
187 | enumerationLiteralItemProvider = new EnumerationLiteralItemProvider(this); |
188 | } |
189 | |
190 | return enumerationLiteralItemProvider; |
191 | } |
192 | |
193 | /** |
194 | * This keeps track of the one adapter used for all {@link EMOF.Extent} instances. |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | protected ExtentItemProvider extentItemProvider; |
200 | |
201 | /** |
202 | * This creates an adapter for a {@link EMOF.Extent}. |
203 | * <!-- begin-user-doc --> |
204 | * <!-- end-user-doc --> |
205 | * @generated |
206 | */ |
207 | @Override |
208 | public Adapter createExtentAdapter() { |
209 | if (extentItemProvider == null) { |
210 | extentItemProvider = new ExtentItemProvider(this); |
211 | } |
212 | |
213 | return extentItemProvider; |
214 | } |
215 | |
216 | /** |
217 | * This keeps track of the one adapter used for all {@link EMOF.Factory} instances. |
218 | * <!-- begin-user-doc --> |
219 | * <!-- end-user-doc --> |
220 | * @generated |
221 | */ |
222 | protected FactoryItemProvider factoryItemProvider; |
223 | |
224 | /** |
225 | * This creates an adapter for a {@link EMOF.Factory}. |
226 | * <!-- begin-user-doc --> |
227 | * <!-- end-user-doc --> |
228 | * @generated |
229 | */ |
230 | @Override |
231 | public Adapter createFactoryAdapter() { |
232 | if (factoryItemProvider == null) { |
233 | factoryItemProvider = new FactoryItemProvider(this); |
234 | } |
235 | |
236 | return factoryItemProvider; |
237 | } |
238 | |
239 | /** |
240 | * This keeps track of the one adapter used for all {@link EMOF.Object} instances. |
241 | * <!-- begin-user-doc --> |
242 | * <!-- end-user-doc --> |
243 | * @generated |
244 | */ |
245 | protected ObjectItemProvider objectItemProvider; |
246 | |
247 | /** |
248 | * This creates an adapter for a {@link EMOF.Object}. |
249 | * <!-- begin-user-doc --> |
250 | * <!-- end-user-doc --> |
251 | * @generated |
252 | */ |
253 | @Override |
254 | public Adapter createObjectAdapter() { |
255 | if (objectItemProvider == null) { |
256 | objectItemProvider = new ObjectItemProvider(this); |
257 | } |
258 | |
259 | return objectItemProvider; |
260 | } |
261 | |
262 | /** |
263 | * This keeps track of the one adapter used for all {@link EMOF.Operation} instances. |
264 | * <!-- begin-user-doc --> |
265 | * <!-- end-user-doc --> |
266 | * @generated |
267 | */ |
268 | protected OperationItemProvider operationItemProvider; |
269 | |
270 | /** |
271 | * This creates an adapter for a {@link EMOF.Operation}. |
272 | * <!-- begin-user-doc --> |
273 | * <!-- end-user-doc --> |
274 | * @generated |
275 | */ |
276 | @Override |
277 | public Adapter createOperationAdapter() { |
278 | if (operationItemProvider == null) { |
279 | operationItemProvider = new OperationItemProvider(this); |
280 | } |
281 | |
282 | return operationItemProvider; |
283 | } |
284 | |
285 | /** |
286 | * This keeps track of the one adapter used for all {@link EMOF.Package} instances. |
287 | * <!-- begin-user-doc --> |
288 | * <!-- end-user-doc --> |
289 | * @generated |
290 | */ |
291 | protected PackageItemProvider packageItemProvider; |
292 | |
293 | /** |
294 | * This creates an adapter for a {@link EMOF.Package}. |
295 | * <!-- begin-user-doc --> |
296 | * <!-- end-user-doc --> |
297 | * @generated |
298 | */ |
299 | @Override |
300 | public Adapter createPackageAdapter() { |
301 | if (packageItemProvider == null) { |
302 | packageItemProvider = new PackageItemProvider(this); |
303 | } |
304 | |
305 | return packageItemProvider; |
306 | } |
307 | |
308 | /** |
309 | * This keeps track of the one adapter used for all {@link EMOF.Parameter} instances. |
310 | * <!-- begin-user-doc --> |
311 | * <!-- end-user-doc --> |
312 | * @generated |
313 | */ |
314 | protected ParameterItemProvider parameterItemProvider; |
315 | |
316 | /** |
317 | * This creates an adapter for a {@link EMOF.Parameter}. |
318 | * <!-- begin-user-doc --> |
319 | * <!-- end-user-doc --> |
320 | * @generated |
321 | */ |
322 | @Override |
323 | public Adapter createParameterAdapter() { |
324 | if (parameterItemProvider == null) { |
325 | parameterItemProvider = new ParameterItemProvider(this); |
326 | } |
327 | |
328 | return parameterItemProvider; |
329 | } |
330 | |
331 | /** |
332 | * This keeps track of the one adapter used for all {@link EMOF.PrimitiveType} instances. |
333 | * <!-- begin-user-doc --> |
334 | * <!-- end-user-doc --> |
335 | * @generated |
336 | */ |
337 | protected PrimitiveTypeItemProvider primitiveTypeItemProvider; |
338 | |
339 | /** |
340 | * This creates an adapter for a {@link EMOF.PrimitiveType}. |
341 | * <!-- begin-user-doc --> |
342 | * <!-- end-user-doc --> |
343 | * @generated |
344 | */ |
345 | @Override |
346 | public Adapter createPrimitiveTypeAdapter() { |
347 | if (primitiveTypeItemProvider == null) { |
348 | primitiveTypeItemProvider = new PrimitiveTypeItemProvider(this); |
349 | } |
350 | |
351 | return primitiveTypeItemProvider; |
352 | } |
353 | |
354 | /** |
355 | * This keeps track of the one adapter used for all {@link EMOF.Property} instances. |
356 | * <!-- begin-user-doc --> |
357 | * <!-- end-user-doc --> |
358 | * @generated |
359 | */ |
360 | protected PropertyItemProvider propertyItemProvider; |
361 | |
362 | /** |
363 | * This creates an adapter for a {@link EMOF.Property}. |
364 | * <!-- begin-user-doc --> |
365 | * <!-- end-user-doc --> |
366 | * @generated |
367 | */ |
368 | @Override |
369 | public Adapter createPropertyAdapter() { |
370 | if (propertyItemProvider == null) { |
371 | propertyItemProvider = new PropertyItemProvider(this); |
372 | } |
373 | |
374 | return propertyItemProvider; |
375 | } |
376 | |
377 | /** |
378 | * This keeps track of the one adapter used for all {@link EMOF.ReflectiveCollection} instances. |
379 | * <!-- begin-user-doc --> |
380 | * <!-- end-user-doc --> |
381 | * @generated |
382 | */ |
383 | protected ReflectiveCollectionItemProvider reflectiveCollectionItemProvider; |
384 | |
385 | /** |
386 | * This creates an adapter for a {@link EMOF.ReflectiveCollection}. |
387 | * <!-- begin-user-doc --> |
388 | * <!-- end-user-doc --> |
389 | * @generated |
390 | */ |
391 | @Override |
392 | public Adapter createReflectiveCollectionAdapter() { |
393 | if (reflectiveCollectionItemProvider == null) { |
394 | reflectiveCollectionItemProvider = new ReflectiveCollectionItemProvider(this); |
395 | } |
396 | |
397 | return reflectiveCollectionItemProvider; |
398 | } |
399 | |
400 | /** |
401 | * This keeps track of the one adapter used for all {@link EMOF.ReflectiveSequence} instances. |
402 | * <!-- begin-user-doc --> |
403 | * <!-- end-user-doc --> |
404 | * @generated |
405 | */ |
406 | protected ReflectiveSequenceItemProvider reflectiveSequenceItemProvider; |
407 | |
408 | /** |
409 | * This creates an adapter for a {@link EMOF.ReflectiveSequence}. |
410 | * <!-- begin-user-doc --> |
411 | * <!-- end-user-doc --> |
412 | * @generated |
413 | */ |
414 | @Override |
415 | public Adapter createReflectiveSequenceAdapter() { |
416 | if (reflectiveSequenceItemProvider == null) { |
417 | reflectiveSequenceItemProvider = new ReflectiveSequenceItemProvider(this); |
418 | } |
419 | |
420 | return reflectiveSequenceItemProvider; |
421 | } |
422 | |
423 | /** |
424 | * This keeps track of the one adapter used for all {@link EMOF.Tag} instances. |
425 | * <!-- begin-user-doc --> |
426 | * <!-- end-user-doc --> |
427 | * @generated |
428 | */ |
429 | protected TagItemProvider tagItemProvider; |
430 | |
431 | /** |
432 | * This creates an adapter for a {@link EMOF.Tag}. |
433 | * <!-- begin-user-doc --> |
434 | * <!-- end-user-doc --> |
435 | * @generated |
436 | */ |
437 | @Override |
438 | public Adapter createTagAdapter() { |
439 | if (tagItemProvider == null) { |
440 | tagItemProvider = new TagItemProvider(this); |
441 | } |
442 | |
443 | return tagItemProvider; |
444 | } |
445 | |
446 | /** |
447 | * This keeps track of the one adapter used for all {@link EMOF.URIExtent} instances. |
448 | * <!-- begin-user-doc --> |
449 | * <!-- end-user-doc --> |
450 | * @generated |
451 | */ |
452 | protected URIExtentItemProvider uriExtentItemProvider; |
453 | |
454 | /** |
455 | * This creates an adapter for a {@link EMOF.URIExtent}. |
456 | * <!-- begin-user-doc --> |
457 | * <!-- end-user-doc --> |
458 | * @generated |
459 | */ |
460 | @Override |
461 | public Adapter createURIExtentAdapter() { |
462 | if (uriExtentItemProvider == null) { |
463 | uriExtentItemProvider = new URIExtentItemProvider(this); |
464 | } |
465 | |
466 | return uriExtentItemProvider; |
467 | } |
468 | |
469 | /** |
470 | * This returns the root adapter factory that contains this factory. |
471 | * <!-- begin-user-doc --> |
472 | * <!-- end-user-doc --> |
473 | * @generated |
474 | */ |
475 | public ComposeableAdapterFactory getRootAdapterFactory() { |
476 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
477 | } |
478 | |
479 | /** |
480 | * This sets the composed adapter factory that contains this factory. |
481 | * <!-- begin-user-doc --> |
482 | * <!-- end-user-doc --> |
483 | * @generated |
484 | */ |
485 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
486 | this.parentAdapterFactory = parentAdapterFactory; |
487 | } |
488 | |
489 | /** |
490 | * <!-- begin-user-doc --> |
491 | * <!-- end-user-doc --> |
492 | * @generated |
493 | */ |
494 | @Override |
495 | public boolean isFactoryForType(Object type) { |
496 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
497 | } |
498 | |
499 | /** |
500 | * This implementation substitutes the factory itself as the key for the adapter. |
501 | * <!-- begin-user-doc --> |
502 | * <!-- end-user-doc --> |
503 | * @generated |
504 | */ |
505 | @Override |
506 | public Adapter adapt(Notifier notifier, Object type) { |
507 | return super.adapt(notifier, this); |
508 | } |
509 | |
510 | /** |
511 | * <!-- begin-user-doc --> |
512 | * <!-- end-user-doc --> |
513 | * @generated |
514 | */ |
515 | @Override |
516 | public Object adapt(Object object, Object type) { |
517 | if (isFactoryForType(type)) { |
518 | Object adapter = super.adapt(object, type); |
519 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
520 | return adapter; |
521 | } |
522 | } |
523 | |
524 | return null; |
525 | } |
526 | |
527 | /** |
528 | * This adds a listener. |
529 | * <!-- begin-user-doc --> |
530 | * <!-- end-user-doc --> |
531 | * @generated |
532 | */ |
533 | public void addListener(INotifyChangedListener notifyChangedListener) { |
534 | changeNotifier.addListener(notifyChangedListener); |
535 | } |
536 | |
537 | /** |
538 | * This removes a listener. |
539 | * <!-- begin-user-doc --> |
540 | * <!-- end-user-doc --> |
541 | * @generated |
542 | */ |
543 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
544 | changeNotifier.removeListener(notifyChangedListener); |
545 | } |
546 | |
547 | /** |
548 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
549 | * <!-- begin-user-doc --> |
550 | * <!-- end-user-doc --> |
551 | * @generated |
552 | */ |
553 | public void fireNotifyChanged(Notification notification) { |
554 | changeNotifier.fireNotifyChanged(notification); |
555 | |
556 | if (parentAdapterFactory != null) { |
557 | parentAdapterFactory.fireNotifyChanged(notification); |
558 | } |
559 | } |
560 | |
561 | /** |
562 | * This disposes all of the item providers created by this factory. |
563 | * <!-- begin-user-doc --> |
564 | * <!-- end-user-doc --> |
565 | * @generated |
566 | */ |
567 | public void dispose() { |
568 | if (classItemProvider != null) classItemProvider.dispose(); |
569 | if (commentItemProvider != null) commentItemProvider.dispose(); |
570 | if (dataTypeItemProvider != null) dataTypeItemProvider.dispose(); |
571 | if (enumerationItemProvider != null) enumerationItemProvider.dispose(); |
572 | if (enumerationLiteralItemProvider != null) enumerationLiteralItemProvider.dispose(); |
573 | if (extentItemProvider != null) extentItemProvider.dispose(); |
574 | if (factoryItemProvider != null) factoryItemProvider.dispose(); |
575 | if (objectItemProvider != null) objectItemProvider.dispose(); |
576 | if (operationItemProvider != null) operationItemProvider.dispose(); |
577 | if (packageItemProvider != null) packageItemProvider.dispose(); |
578 | if (parameterItemProvider != null) parameterItemProvider.dispose(); |
579 | if (primitiveTypeItemProvider != null) primitiveTypeItemProvider.dispose(); |
580 | if (propertyItemProvider != null) propertyItemProvider.dispose(); |
581 | if (reflectiveCollectionItemProvider != null) reflectiveCollectionItemProvider.dispose(); |
582 | if (reflectiveSequenceItemProvider != null) reflectiveSequenceItemProvider.dispose(); |
583 | if (tagItemProvider != null) tagItemProvider.dispose(); |
584 | if (uriExtentItemProvider != null) uriExtentItemProvider.dispose(); |
585 | } |
586 | |
587 | } |