1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourceenvironment.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.resourceenvironment.util.ResourceenvironmentAdapterFactory; |
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 ResourceenvironmentItemProviderAdapterFactory extends ResourceenvironmentAdapterFactory 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 ResourceenvironmentItemProviderAdapterFactory() { |
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.resourceenvironment.ResourceEnvironment} instances. |
85 | * <!-- begin-user-doc --> |
86 | * <!-- end-user-doc --> |
87 | * @generated |
88 | */ |
89 | protected ResourceEnvironmentItemProvider resourceEnvironmentItemProvider; |
90 | |
91 | /** |
92 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.ResourceEnvironment}. |
93 | * <!-- begin-user-doc --> |
94 | * <!-- end-user-doc --> |
95 | * @generated |
96 | */ |
97 | @Override |
98 | public Adapter createResourceEnvironmentAdapter() { |
99 | if (resourceEnvironmentItemProvider == null) { |
100 | resourceEnvironmentItemProvider = new ResourceEnvironmentItemProvider(this); |
101 | } |
102 | |
103 | return resourceEnvironmentItemProvider; |
104 | } |
105 | |
106 | /** |
107 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource} instances. |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | protected LinkingResourceItemProvider linkingResourceItemProvider; |
113 | |
114 | /** |
115 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource}. |
116 | * <!-- begin-user-doc --> |
117 | * <!-- end-user-doc --> |
118 | * @generated |
119 | */ |
120 | @Override |
121 | public Adapter createLinkingResourceAdapter() { |
122 | if (linkingResourceItemProvider == null) { |
123 | linkingResourceItemProvider = new LinkingResourceItemProvider(this); |
124 | } |
125 | |
126 | return linkingResourceItemProvider; |
127 | } |
128 | |
129 | /** |
130 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer} instances. |
131 | * <!-- begin-user-doc --> |
132 | * <!-- end-user-doc --> |
133 | * @generated |
134 | */ |
135 | protected ResourceContainerItemProvider resourceContainerItemProvider; |
136 | |
137 | /** |
138 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer}. |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | @Override |
144 | public Adapter createResourceContainerAdapter() { |
145 | if (resourceContainerItemProvider == null) { |
146 | resourceContainerItemProvider = new ResourceContainerItemProvider(this); |
147 | } |
148 | |
149 | return resourceContainerItemProvider; |
150 | } |
151 | |
152 | /** |
153 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification} instances. |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | protected ProcessingResourceSpecificationItemProvider processingResourceSpecificationItemProvider; |
159 | |
160 | /** |
161 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification}. |
162 | * <!-- begin-user-doc --> |
163 | * <!-- end-user-doc --> |
164 | * @generated |
165 | */ |
166 | @Override |
167 | public Adapter createProcessingResourceSpecificationAdapter() { |
168 | if (processingResourceSpecificationItemProvider == null) { |
169 | processingResourceSpecificationItemProvider = new ProcessingResourceSpecificationItemProvider(this); |
170 | } |
171 | |
172 | return processingResourceSpecificationItemProvider; |
173 | } |
174 | |
175 | /** |
176 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.pcm.resourceenvironment.CommunicationLinkResourceSpecification} instances. |
177 | * <!-- begin-user-doc --> |
178 | * <!-- end-user-doc --> |
179 | * @generated |
180 | */ |
181 | protected CommunicationLinkResourceSpecificationItemProvider communicationLinkResourceSpecificationItemProvider; |
182 | |
183 | /** |
184 | * This creates an adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.CommunicationLinkResourceSpecification}. |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated |
188 | */ |
189 | @Override |
190 | public Adapter createCommunicationLinkResourceSpecificationAdapter() { |
191 | if (communicationLinkResourceSpecificationItemProvider == null) { |
192 | communicationLinkResourceSpecificationItemProvider = new CommunicationLinkResourceSpecificationItemProvider(this); |
193 | } |
194 | |
195 | return communicationLinkResourceSpecificationItemProvider; |
196 | } |
197 | |
198 | /** |
199 | * This returns the root adapter factory that contains this factory. |
200 | * <!-- begin-user-doc --> |
201 | * <!-- end-user-doc --> |
202 | * @generated |
203 | */ |
204 | public ComposeableAdapterFactory getRootAdapterFactory() { |
205 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
206 | } |
207 | |
208 | /** |
209 | * This sets the composed adapter factory that contains this factory. |
210 | * <!-- begin-user-doc --> |
211 | * <!-- end-user-doc --> |
212 | * @generated |
213 | */ |
214 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
215 | this.parentAdapterFactory = parentAdapterFactory; |
216 | } |
217 | |
218 | /** |
219 | * <!-- begin-user-doc --> |
220 | * <!-- end-user-doc --> |
221 | * @generated |
222 | */ |
223 | @Override |
224 | public boolean isFactoryForType(Object type) { |
225 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
226 | } |
227 | |
228 | /** |
229 | * This implementation substitutes the factory itself as the key for the adapter. |
230 | * <!-- begin-user-doc --> |
231 | * <!-- end-user-doc --> |
232 | * @generated |
233 | */ |
234 | @Override |
235 | public Adapter adapt(Notifier notifier, Object type) { |
236 | return super.adapt(notifier, this); |
237 | } |
238 | |
239 | /** |
240 | * <!-- begin-user-doc --> |
241 | * <!-- end-user-doc --> |
242 | * @generated |
243 | */ |
244 | @Override |
245 | public Object adapt(Object object, Object type) { |
246 | if (isFactoryForType(type)) { |
247 | Object adapter = super.adapt(object, type); |
248 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
249 | return adapter; |
250 | } |
251 | } |
252 | |
253 | return null; |
254 | } |
255 | |
256 | /** |
257 | * This adds a listener. |
258 | * <!-- begin-user-doc --> |
259 | * <!-- end-user-doc --> |
260 | * @generated |
261 | */ |
262 | public void addListener(INotifyChangedListener notifyChangedListener) { |
263 | changeNotifier.addListener(notifyChangedListener); |
264 | } |
265 | |
266 | /** |
267 | * This removes a listener. |
268 | * <!-- begin-user-doc --> |
269 | * <!-- end-user-doc --> |
270 | * @generated |
271 | */ |
272 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
273 | changeNotifier.removeListener(notifyChangedListener); |
274 | } |
275 | |
276 | /** |
277 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
278 | * <!-- begin-user-doc --> |
279 | * <!-- end-user-doc --> |
280 | * @generated |
281 | */ |
282 | public void fireNotifyChanged(Notification notification) { |
283 | changeNotifier.fireNotifyChanged(notification); |
284 | |
285 | if (parentAdapterFactory != null) { |
286 | parentAdapterFactory.fireNotifyChanged(notification); |
287 | } |
288 | } |
289 | |
290 | /** |
291 | * This disposes all of the item providers created by this factory. |
292 | * <!-- begin-user-doc --> |
293 | * <!-- end-user-doc --> |
294 | * @generated |
295 | */ |
296 | public void dispose() { |
297 | if (resourceEnvironmentItemProvider != null) resourceEnvironmentItemProvider.dispose(); |
298 | if (linkingResourceItemProvider != null) linkingResourceItemProvider.dispose(); |
299 | if (resourceContainerItemProvider != null) resourceContainerItemProvider.dispose(); |
300 | if (processingResourceSpecificationItemProvider != null) processingResourceSpecificationItemProvider.dispose(); |
301 | if (communicationLinkResourceSpecificationItemProvider != null) communicationLinkResourceSpecificationItemProvider.dispose(); |
302 | } |
303 | |
304 | } |