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