1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.fzi.se.quality.provider; |
8 | |
9 | import de.fzi.se.quality.util.QualityAdapterFactory; |
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 QualityItemProviderAdapterFactory extends QualityAdapterFactory 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 QualityItemProviderAdapterFactory() { |
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 de.fzi.se.quality.QualityRepository} instances. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected QualityRepositoryItemProvider qualityRepositoryItemProvider; |
85 | |
86 | /** |
87 | * This creates an adapter for a {@link de.fzi.se.quality.QualityRepository}. |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @generated |
91 | */ |
92 | @Override |
93 | public Adapter createQualityRepositoryAdapter() { |
94 | if (qualityRepositoryItemProvider == null) { |
95 | qualityRepositoryItemProvider = new QualityRepositoryItemProvider(this); |
96 | } |
97 | |
98 | return qualityRepositoryItemProvider; |
99 | } |
100 | |
101 | /** |
102 | * This returns the root adapter factory that contains this factory. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | public ComposeableAdapterFactory getRootAdapterFactory() { |
108 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
109 | } |
110 | |
111 | /** |
112 | * This sets the composed adapter factory that contains this factory. |
113 | * <!-- begin-user-doc --> |
114 | * <!-- end-user-doc --> |
115 | * @generated |
116 | */ |
117 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
118 | this.parentAdapterFactory = parentAdapterFactory; |
119 | } |
120 | |
121 | /** |
122 | * <!-- begin-user-doc --> |
123 | * <!-- end-user-doc --> |
124 | * @generated |
125 | */ |
126 | @Override |
127 | public boolean isFactoryForType(Object type) { |
128 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
129 | } |
130 | |
131 | /** |
132 | * This implementation substitutes the factory itself as the key for the adapter. |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | @Override |
138 | public Adapter adapt(Notifier notifier, Object type) { |
139 | return super.adapt(notifier, this); |
140 | } |
141 | |
142 | /** |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | @Override |
148 | public Object adapt(Object object, Object type) { |
149 | if (isFactoryForType(type)) { |
150 | Object adapter = super.adapt(object, type); |
151 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
152 | return adapter; |
153 | } |
154 | } |
155 | |
156 | return null; |
157 | } |
158 | |
159 | /** |
160 | * This adds a listener. |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | public void addListener(INotifyChangedListener notifyChangedListener) { |
166 | changeNotifier.addListener(notifyChangedListener); |
167 | } |
168 | |
169 | /** |
170 | * This removes a listener. |
171 | * <!-- begin-user-doc --> |
172 | * <!-- end-user-doc --> |
173 | * @generated |
174 | */ |
175 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
176 | changeNotifier.removeListener(notifyChangedListener); |
177 | } |
178 | |
179 | /** |
180 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | public void fireNotifyChanged(Notification notification) { |
186 | changeNotifier.fireNotifyChanged(notification); |
187 | |
188 | if (parentAdapterFactory != null) { |
189 | parentAdapterFactory.fireNotifyChanged(notification); |
190 | } |
191 | } |
192 | |
193 | /** |
194 | * This disposes all of the item providers created by this factory. |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | public void dispose() { |
200 | if (qualityRepositoryItemProvider != null) qualityRepositoryItemProvider.dispose(); |
201 | } |
202 | |
203 | } |