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