1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package copyException.provider; |
8 | |
9 | import copyException.util.CopyExceptionAdapterFactory; |
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 CopyExceptionItemProviderAdapterFactory extends CopyExceptionAdapterFactory 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 CopyExceptionItemProviderAdapterFactory() { |
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 copyException.Model} instances. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected ModelItemProvider modelItemProvider; |
85 | |
86 | /** |
87 | * This creates an adapter for a {@link copyException.Model}. |
88 | * <!-- begin-user-doc --> |
89 | * <!-- end-user-doc --> |
90 | * @generated |
91 | */ |
92 | @Override |
93 | public Adapter createModelAdapter() { |
94 | if (modelItemProvider == null) { |
95 | modelItemProvider = new ModelItemProvider(this); |
96 | } |
97 | |
98 | return modelItemProvider; |
99 | } |
100 | |
101 | /** |
102 | * This keeps track of the one adapter used for all {@link copyException.Import} instances. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | protected ImportItemProvider importItemProvider; |
108 | |
109 | /** |
110 | * This creates an adapter for a {@link copyException.Import}. |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | @Override |
116 | public Adapter createImportAdapter() { |
117 | if (importItemProvider == null) { |
118 | importItemProvider = new ImportItemProvider(this); |
119 | } |
120 | |
121 | return importItemProvider; |
122 | } |
123 | |
124 | /** |
125 | * This keeps track of the one adapter used for all {@link copyException.DeletionException} instances. |
126 | * <!-- begin-user-doc --> |
127 | * <!-- end-user-doc --> |
128 | * @generated |
129 | */ |
130 | protected DeletionExceptionItemProvider deletionExceptionItemProvider; |
131 | |
132 | /** |
133 | * This creates an adapter for a {@link copyException.DeletionException}. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Adapter createDeletionExceptionAdapter() { |
140 | if (deletionExceptionItemProvider == null) { |
141 | deletionExceptionItemProvider = new DeletionExceptionItemProvider(this); |
142 | } |
143 | |
144 | return deletionExceptionItemProvider; |
145 | } |
146 | |
147 | /** |
148 | * This keeps track of the one adapter used for all {@link copyException.ReplacementException} instances. |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | protected ReplacementExceptionItemProvider replacementExceptionItemProvider; |
154 | |
155 | /** |
156 | * This creates an adapter for a {@link copyException.ReplacementException}. |
157 | * <!-- begin-user-doc --> |
158 | * <!-- end-user-doc --> |
159 | * @generated |
160 | */ |
161 | @Override |
162 | public Adapter createReplacementExceptionAdapter() { |
163 | if (replacementExceptionItemProvider == null) { |
164 | replacementExceptionItemProvider = new ReplacementExceptionItemProvider(this); |
165 | } |
166 | |
167 | return replacementExceptionItemProvider; |
168 | } |
169 | |
170 | /** |
171 | * This keeps track of the one adapter used for all {@link copyException.ReferenceException} instances. |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | protected ReferenceExceptionItemProvider referenceExceptionItemProvider; |
177 | |
178 | /** |
179 | * This creates an adapter for a {@link copyException.ReferenceException}. |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated |
183 | */ |
184 | @Override |
185 | public Adapter createReferenceExceptionAdapter() { |
186 | if (referenceExceptionItemProvider == null) { |
187 | referenceExceptionItemProvider = new ReferenceExceptionItemProvider(this); |
188 | } |
189 | |
190 | return referenceExceptionItemProvider; |
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 (modelItemProvider != null) modelItemProvider.dispose(); |
293 | if (importItemProvider != null) importItemProvider.dispose(); |
294 | if (deletionExceptionItemProvider != null) deletionExceptionItemProvider.dispose(); |
295 | if (replacementExceptionItemProvider != null) replacementExceptionItemProvider.dispose(); |
296 | if (referenceExceptionItemProvider != null) referenceExceptionItemProvider.dispose(); |
297 | } |
298 | |
299 | } |