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