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