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