1 | /** |
2 | * Copyright 2006, SDQ Group, University Karlsruhe (TH) |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.context.computed_allocation.provider; |
7 | |
8 | import de.uka.ipd.sdq.context.computed_allocation.util.ComputedAllocationAdapterFactory; |
9 | |
10 | import java.util.ArrayList; |
11 | import java.util.Collection; |
12 | |
13 | import org.eclipse.emf.common.notify.Adapter; |
14 | import org.eclipse.emf.common.notify.Notification; |
15 | import org.eclipse.emf.common.notify.Notifier; |
16 | |
17 | import org.eclipse.emf.edit.provider.ChangeNotifier; |
18 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
19 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
20 | import org.eclipse.emf.edit.provider.IChangeNotifier; |
21 | import org.eclipse.emf.edit.provider.IDisposable; |
22 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
23 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
24 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
25 | import org.eclipse.emf.edit.provider.INotifyChangedListener; |
26 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
27 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
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 ComputedAllocationItemProviderAdapterFactory extends ComputedAllocationAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { |
39 | /** |
40 | * <!-- begin-user-doc --> |
41 | * <!-- end-user-doc --> |
42 | * @generated |
43 | */ |
44 | public static final String copyright = "Copyright 2006, SDQ Group, University Karlsruhe (TH)"; |
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 ComputedAllocationItemProviderAdapterFactory() { |
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.context.computed_allocation.ComputedAllocationContext} instances. |
86 | * <!-- begin-user-doc --> |
87 | * <!-- end-user-doc --> |
88 | * @generated |
89 | */ |
90 | protected ComputedAllocationContextItemProvider computedAllocationContextItemProvider; |
91 | |
92 | /** |
93 | * This creates an adapter for a {@link de.uka.ipd.sdq.context.computed_allocation.ComputedAllocationContext}. |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | @Override |
99 | public Adapter createComputedAllocationContextAdapter() { |
100 | if (computedAllocationContextItemProvider == null) { |
101 | computedAllocationContextItemProvider = new ComputedAllocationContextItemProvider(this); |
102 | } |
103 | |
104 | return computedAllocationContextItemProvider; |
105 | } |
106 | |
107 | /** |
108 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.context.computed_allocation.ResourceDemand} instances. |
109 | * <!-- begin-user-doc --> |
110 | * <!-- end-user-doc --> |
111 | * @generated |
112 | */ |
113 | protected ResourceDemandItemProvider resourceDemandItemProvider; |
114 | |
115 | /** |
116 | * This creates an adapter for a {@link de.uka.ipd.sdq.context.computed_allocation.ResourceDemand}. |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | @Override |
122 | public Adapter createResourceDemandAdapter() { |
123 | if (resourceDemandItemProvider == null) { |
124 | resourceDemandItemProvider = new ResourceDemandItemProvider(this); |
125 | } |
126 | |
127 | return resourceDemandItemProvider; |
128 | } |
129 | |
130 | /** |
131 | * This keeps track of the one adapter used for all {@link de.uka.ipd.sdq.context.computed_allocation.ComputedAllocation} instances. |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | protected ComputedAllocationItemProvider computedAllocationItemProvider; |
137 | |
138 | /** |
139 | * This creates an adapter for a {@link de.uka.ipd.sdq.context.computed_allocation.ComputedAllocation}. |
140 | * <!-- begin-user-doc --> |
141 | * <!-- end-user-doc --> |
142 | * @generated |
143 | */ |
144 | @Override |
145 | public Adapter createComputedAllocationAdapter() { |
146 | if (computedAllocationItemProvider == null) { |
147 | computedAllocationItemProvider = new ComputedAllocationItemProvider(this); |
148 | } |
149 | |
150 | return computedAllocationItemProvider; |
151 | } |
152 | |
153 | /** |
154 | * This returns the root adapter factory that contains this factory. |
155 | * <!-- begin-user-doc --> |
156 | * <!-- end-user-doc --> |
157 | * @generated |
158 | */ |
159 | public ComposeableAdapterFactory getRootAdapterFactory() { |
160 | return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); |
161 | } |
162 | |
163 | /** |
164 | * This sets the composed adapter factory that contains this factory. |
165 | * <!-- begin-user-doc --> |
166 | * <!-- end-user-doc --> |
167 | * @generated |
168 | */ |
169 | public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { |
170 | this.parentAdapterFactory = parentAdapterFactory; |
171 | } |
172 | |
173 | /** |
174 | * <!-- begin-user-doc --> |
175 | * <!-- end-user-doc --> |
176 | * @generated |
177 | */ |
178 | @Override |
179 | public boolean isFactoryForType(Object type) { |
180 | return supportedTypes.contains(type) || super.isFactoryForType(type); |
181 | } |
182 | |
183 | /** |
184 | * This implementation substitutes the factory itself as the key for the adapter. |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated |
188 | */ |
189 | @Override |
190 | public Adapter adapt(Notifier notifier, Object type) { |
191 | return super.adapt(notifier, this); |
192 | } |
193 | |
194 | /** |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | @Override |
200 | public Object adapt(Object object, Object type) { |
201 | if (isFactoryForType(type)) { |
202 | Object adapter = super.adapt(object, type); |
203 | if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) { |
204 | return adapter; |
205 | } |
206 | } |
207 | |
208 | return null; |
209 | } |
210 | |
211 | /** |
212 | * This adds a listener. |
213 | * <!-- begin-user-doc --> |
214 | * <!-- end-user-doc --> |
215 | * @generated |
216 | */ |
217 | public void addListener(INotifyChangedListener notifyChangedListener) { |
218 | changeNotifier.addListener(notifyChangedListener); |
219 | } |
220 | |
221 | /** |
222 | * This removes a listener. |
223 | * <!-- begin-user-doc --> |
224 | * <!-- end-user-doc --> |
225 | * @generated |
226 | */ |
227 | public void removeListener(INotifyChangedListener notifyChangedListener) { |
228 | changeNotifier.removeListener(notifyChangedListener); |
229 | } |
230 | |
231 | /** |
232 | * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. |
233 | * <!-- begin-user-doc --> |
234 | * <!-- end-user-doc --> |
235 | * @generated |
236 | */ |
237 | public void fireNotifyChanged(Notification notification) { |
238 | changeNotifier.fireNotifyChanged(notification); |
239 | |
240 | if (parentAdapterFactory != null) { |
241 | parentAdapterFactory.fireNotifyChanged(notification); |
242 | } |
243 | } |
244 | |
245 | /** |
246 | * This disposes all of the item providers created by this factory. |
247 | * <!-- begin-user-doc --> |
248 | * <!-- end-user-doc --> |
249 | * @generated |
250 | */ |
251 | public void dispose() { |
252 | if (computedAllocationContextItemProvider != null) computedAllocationContextItemProvider.dispose(); |
253 | if (resourceDemandItemProvider != null) resourceDemandItemProvider.dispose(); |
254 | if (computedAllocationItemProvider != null) computedAllocationItemProvider.dispose(); |
255 | } |
256 | |
257 | } |