1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EssentialOCL.provider; |
8 | |
9 | |
10 | import EssentialOCL.CollectionRange; |
11 | import EssentialOCL.EssentialOCLFactory; |
12 | import EssentialOCL.EssentialOCLPackage; |
13 | |
14 | import QVTRelation.QVTRelationFactory; |
15 | |
16 | import QVTTemplate.QVTTemplateFactory; |
17 | |
18 | import java.util.Collection; |
19 | import java.util.List; |
20 | |
21 | import org.eclipse.emf.common.notify.AdapterFactory; |
22 | import org.eclipse.emf.common.notify.Notification; |
23 | |
24 | import org.eclipse.emf.ecore.EStructuralFeature; |
25 | |
26 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
27 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
28 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
29 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
30 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
31 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
32 | import org.eclipse.emf.edit.provider.ViewerNotification; |
33 | |
34 | /** |
35 | * This is the item provider adapter for a {@link EssentialOCL.CollectionRange} object. |
36 | * <!-- begin-user-doc --> |
37 | * <!-- end-user-doc --> |
38 | * @generated |
39 | */ |
40 | public class CollectionRangeItemProvider |
41 | extends CollectionLiteralPartItemProvider |
42 | implements |
43 | IEditingDomainItemProvider, |
44 | IStructuredItemContentProvider, |
45 | ITreeItemContentProvider, |
46 | IItemLabelProvider, |
47 | IItemPropertySource { |
48 | /** |
49 | * This constructs an instance from a factory and a notifier. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @generated |
53 | */ |
54 | public CollectionRangeItemProvider(AdapterFactory adapterFactory) { |
55 | super(adapterFactory); |
56 | } |
57 | |
58 | /** |
59 | * This returns the property descriptors for the adapted class. |
60 | * <!-- begin-user-doc --> |
61 | * <!-- end-user-doc --> |
62 | * @generated |
63 | */ |
64 | @Override |
65 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
66 | if (itemPropertyDescriptors == null) { |
67 | super.getPropertyDescriptors(object); |
68 | |
69 | } |
70 | return itemPropertyDescriptors; |
71 | } |
72 | |
73 | /** |
74 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
75 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
76 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @generated |
80 | */ |
81 | @Override |
82 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
83 | if (childrenFeatures == null) { |
84 | super.getChildrenFeatures(object); |
85 | childrenFeatures.add(EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST); |
86 | childrenFeatures.add(EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST); |
87 | } |
88 | return childrenFeatures; |
89 | } |
90 | |
91 | /** |
92 | * <!-- begin-user-doc --> |
93 | * <!-- end-user-doc --> |
94 | * @generated |
95 | */ |
96 | @Override |
97 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
98 | // Check the type of the specified child object and return the proper feature to use for |
99 | // adding (see {@link AddCommand}) it as a child. |
100 | |
101 | return super.getChildFeature(object, child); |
102 | } |
103 | |
104 | /** |
105 | * This returns CollectionRange.gif. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | @Override |
111 | public Object getImage(Object object) { |
112 | return overlayImage(object, getResourceLocator().getImage("full/obj16/CollectionRange")); |
113 | } |
114 | |
115 | /** |
116 | * This returns the label text for the adapted class. |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | @Override |
122 | public String getText(Object object) { |
123 | String label = ((CollectionRange)object).getName(); |
124 | return label == null || label.length() == 0 ? |
125 | getString("_UI_CollectionRange_type") : |
126 | getString("_UI_CollectionRange_type") + " " + label; |
127 | } |
128 | |
129 | /** |
130 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
131 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | @Override |
137 | public void notifyChanged(Notification notification) { |
138 | updateChildren(notification); |
139 | |
140 | switch (notification.getFeatureID(CollectionRange.class)) { |
141 | case EssentialOCLPackage.COLLECTION_RANGE__FIRST: |
142 | case EssentialOCLPackage.COLLECTION_RANGE__LAST: |
143 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
144 | return; |
145 | } |
146 | super.notifyChanged(notification); |
147 | } |
148 | |
149 | /** |
150 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
151 | * that can be created under this object. |
152 | * <!-- begin-user-doc --> |
153 | * <!-- end-user-doc --> |
154 | * @generated |
155 | */ |
156 | @Override |
157 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
158 | super.collectNewChildDescriptors(newChildDescriptors, object); |
159 | |
160 | newChildDescriptors.add |
161 | (createChildParameter |
162 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
163 | EssentialOCLFactory.eINSTANCE.createBooleanLiteralExp())); |
164 | |
165 | newChildDescriptors.add |
166 | (createChildParameter |
167 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
168 | EssentialOCLFactory.eINSTANCE.createCollectionLiteralExp())); |
169 | |
170 | newChildDescriptors.add |
171 | (createChildParameter |
172 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
173 | EssentialOCLFactory.eINSTANCE.createEnumLiteralExp())); |
174 | |
175 | newChildDescriptors.add |
176 | (createChildParameter |
177 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
178 | EssentialOCLFactory.eINSTANCE.createIfExp())); |
179 | |
180 | newChildDescriptors.add |
181 | (createChildParameter |
182 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
183 | EssentialOCLFactory.eINSTANCE.createIntegerLiteralExp())); |
184 | |
185 | newChildDescriptors.add |
186 | (createChildParameter |
187 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
188 | EssentialOCLFactory.eINSTANCE.createInvalidLiteralExp())); |
189 | |
190 | newChildDescriptors.add |
191 | (createChildParameter |
192 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
193 | EssentialOCLFactory.eINSTANCE.createIterateExp())); |
194 | |
195 | newChildDescriptors.add |
196 | (createChildParameter |
197 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
198 | EssentialOCLFactory.eINSTANCE.createIteratorExp())); |
199 | |
200 | newChildDescriptors.add |
201 | (createChildParameter |
202 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
203 | EssentialOCLFactory.eINSTANCE.createLetExp())); |
204 | |
205 | newChildDescriptors.add |
206 | (createChildParameter |
207 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
208 | EssentialOCLFactory.eINSTANCE.createNavigationCallExp())); |
209 | |
210 | newChildDescriptors.add |
211 | (createChildParameter |
212 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
213 | EssentialOCLFactory.eINSTANCE.createNullLiteralExp())); |
214 | |
215 | newChildDescriptors.add |
216 | (createChildParameter |
217 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
218 | EssentialOCLFactory.eINSTANCE.createOperationCallExp())); |
219 | |
220 | newChildDescriptors.add |
221 | (createChildParameter |
222 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
223 | EssentialOCLFactory.eINSTANCE.createPropertyCallExp())); |
224 | |
225 | newChildDescriptors.add |
226 | (createChildParameter |
227 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
228 | EssentialOCLFactory.eINSTANCE.createRealLiteralExp())); |
229 | |
230 | newChildDescriptors.add |
231 | (createChildParameter |
232 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
233 | EssentialOCLFactory.eINSTANCE.createStringLiteralExp())); |
234 | |
235 | newChildDescriptors.add |
236 | (createChildParameter |
237 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
238 | EssentialOCLFactory.eINSTANCE.createTupleLiteralExp())); |
239 | |
240 | newChildDescriptors.add |
241 | (createChildParameter |
242 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
243 | EssentialOCLFactory.eINSTANCE.createTypeExp())); |
244 | |
245 | newChildDescriptors.add |
246 | (createChildParameter |
247 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
248 | EssentialOCLFactory.eINSTANCE.createUnlimitedNaturalExp())); |
249 | |
250 | newChildDescriptors.add |
251 | (createChildParameter |
252 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
253 | EssentialOCLFactory.eINSTANCE.createVariableExp())); |
254 | |
255 | newChildDescriptors.add |
256 | (createChildParameter |
257 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
258 | QVTRelationFactory.eINSTANCE.createOppositePropertyCallExp())); |
259 | |
260 | newChildDescriptors.add |
261 | (createChildParameter |
262 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
263 | QVTRelationFactory.eINSTANCE.createRelationCallExp())); |
264 | |
265 | newChildDescriptors.add |
266 | (createChildParameter |
267 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
268 | QVTTemplateFactory.eINSTANCE.createCollectionTemplateExp())); |
269 | |
270 | newChildDescriptors.add |
271 | (createChildParameter |
272 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST, |
273 | QVTTemplateFactory.eINSTANCE.createObjectTemplateExp())); |
274 | |
275 | newChildDescriptors.add |
276 | (createChildParameter |
277 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
278 | EssentialOCLFactory.eINSTANCE.createBooleanLiteralExp())); |
279 | |
280 | newChildDescriptors.add |
281 | (createChildParameter |
282 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
283 | EssentialOCLFactory.eINSTANCE.createCollectionLiteralExp())); |
284 | |
285 | newChildDescriptors.add |
286 | (createChildParameter |
287 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
288 | EssentialOCLFactory.eINSTANCE.createEnumLiteralExp())); |
289 | |
290 | newChildDescriptors.add |
291 | (createChildParameter |
292 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
293 | EssentialOCLFactory.eINSTANCE.createIfExp())); |
294 | |
295 | newChildDescriptors.add |
296 | (createChildParameter |
297 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
298 | EssentialOCLFactory.eINSTANCE.createIntegerLiteralExp())); |
299 | |
300 | newChildDescriptors.add |
301 | (createChildParameter |
302 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
303 | EssentialOCLFactory.eINSTANCE.createInvalidLiteralExp())); |
304 | |
305 | newChildDescriptors.add |
306 | (createChildParameter |
307 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
308 | EssentialOCLFactory.eINSTANCE.createIterateExp())); |
309 | |
310 | newChildDescriptors.add |
311 | (createChildParameter |
312 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
313 | EssentialOCLFactory.eINSTANCE.createIteratorExp())); |
314 | |
315 | newChildDescriptors.add |
316 | (createChildParameter |
317 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
318 | EssentialOCLFactory.eINSTANCE.createLetExp())); |
319 | |
320 | newChildDescriptors.add |
321 | (createChildParameter |
322 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
323 | EssentialOCLFactory.eINSTANCE.createNavigationCallExp())); |
324 | |
325 | newChildDescriptors.add |
326 | (createChildParameter |
327 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
328 | EssentialOCLFactory.eINSTANCE.createNullLiteralExp())); |
329 | |
330 | newChildDescriptors.add |
331 | (createChildParameter |
332 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
333 | EssentialOCLFactory.eINSTANCE.createOperationCallExp())); |
334 | |
335 | newChildDescriptors.add |
336 | (createChildParameter |
337 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
338 | EssentialOCLFactory.eINSTANCE.createPropertyCallExp())); |
339 | |
340 | newChildDescriptors.add |
341 | (createChildParameter |
342 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
343 | EssentialOCLFactory.eINSTANCE.createRealLiteralExp())); |
344 | |
345 | newChildDescriptors.add |
346 | (createChildParameter |
347 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
348 | EssentialOCLFactory.eINSTANCE.createStringLiteralExp())); |
349 | |
350 | newChildDescriptors.add |
351 | (createChildParameter |
352 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
353 | EssentialOCLFactory.eINSTANCE.createTupleLiteralExp())); |
354 | |
355 | newChildDescriptors.add |
356 | (createChildParameter |
357 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
358 | EssentialOCLFactory.eINSTANCE.createTypeExp())); |
359 | |
360 | newChildDescriptors.add |
361 | (createChildParameter |
362 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
363 | EssentialOCLFactory.eINSTANCE.createUnlimitedNaturalExp())); |
364 | |
365 | newChildDescriptors.add |
366 | (createChildParameter |
367 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
368 | EssentialOCLFactory.eINSTANCE.createVariableExp())); |
369 | |
370 | newChildDescriptors.add |
371 | (createChildParameter |
372 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
373 | QVTRelationFactory.eINSTANCE.createOppositePropertyCallExp())); |
374 | |
375 | newChildDescriptors.add |
376 | (createChildParameter |
377 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
378 | QVTRelationFactory.eINSTANCE.createRelationCallExp())); |
379 | |
380 | newChildDescriptors.add |
381 | (createChildParameter |
382 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
383 | QVTTemplateFactory.eINSTANCE.createCollectionTemplateExp())); |
384 | |
385 | newChildDescriptors.add |
386 | (createChildParameter |
387 | (EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST, |
388 | QVTTemplateFactory.eINSTANCE.createObjectTemplateExp())); |
389 | } |
390 | |
391 | /** |
392 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
393 | * <!-- begin-user-doc --> |
394 | * <!-- end-user-doc --> |
395 | * @generated |
396 | */ |
397 | @Override |
398 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
399 | Object childFeature = feature; |
400 | Object childObject = child; |
401 | |
402 | boolean qualify = |
403 | childFeature == EssentialOCLPackage.Literals.COLLECTION_RANGE__FIRST || |
404 | childFeature == EssentialOCLPackage.Literals.COLLECTION_RANGE__LAST; |
405 | |
406 | if (qualify) { |
407 | return getString |
408 | ("_UI_CreateChild_text2", |
409 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
410 | } |
411 | return super.getCreateChildText(owner, feature, child, selection); |
412 | } |
413 | |
414 | } |