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.ComposeableAdapterFactory; |
17 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
18 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
19 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
20 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
21 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
22 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
23 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
24 | import org.eclipse.emf.edit.provider.ViewerNotification; |
25 | |
26 | import de.uka.ipd.sdq.stoex.BooleanOperations; |
27 | import de.uka.ipd.sdq.stoex.BooleanOperatorExpression; |
28 | import de.uka.ipd.sdq.stoex.StoexFactory; |
29 | import de.uka.ipd.sdq.stoex.StoexPackage; |
30 | |
31 | /** |
32 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.stoex.BooleanOperatorExpression} object. |
33 | * <!-- begin-user-doc --> |
34 | * <!-- end-user-doc --> |
35 | * @generated |
36 | */ |
37 | public class BooleanOperatorExpressionItemProvider |
38 | extends BooleanExpressionItemProvider |
39 | implements |
40 | IEditingDomainItemProvider, |
41 | IStructuredItemContentProvider, |
42 | ITreeItemContentProvider, |
43 | IItemLabelProvider, |
44 | IItemPropertySource { |
45 | /** |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @generated |
49 | */ |
50 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
51 | |
52 | /** |
53 | * This constructs an instance from a factory and a notifier. |
54 | * <!-- begin-user-doc --> |
55 | * <!-- end-user-doc --> |
56 | * @generated |
57 | */ |
58 | public BooleanOperatorExpressionItemProvider(AdapterFactory adapterFactory) { |
59 | super(adapterFactory); |
60 | } |
61 | |
62 | /** |
63 | * This returns the property descriptors for the adapted class. |
64 | * <!-- begin-user-doc --> |
65 | * <!-- end-user-doc --> |
66 | * @generated |
67 | */ |
68 | @Override |
69 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
70 | if (itemPropertyDescriptors == null) { |
71 | super.getPropertyDescriptors(object); |
72 | |
73 | addOperationPropertyDescriptor(object); |
74 | } |
75 | return itemPropertyDescriptors; |
76 | } |
77 | |
78 | /** |
79 | * This adds a property descriptor for the Operation feature. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected void addOperationPropertyDescriptor(Object object) { |
85 | itemPropertyDescriptors.add |
86 | (createItemPropertyDescriptor |
87 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
88 | getResourceLocator(), |
89 | getString("_UI_BooleanOperatorExpression_operation_feature"), |
90 | getString("_UI_PropertyDescriptor_description", "_UI_BooleanOperatorExpression_operation_feature", "_UI_BooleanOperatorExpression_type"), |
91 | StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__OPERATION, |
92 | true, |
93 | false, |
94 | false, |
95 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
96 | null, |
97 | null)); |
98 | } |
99 | |
100 | /** |
101 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
102 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
103 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
104 | * <!-- begin-user-doc --> |
105 | * <!-- end-user-doc --> |
106 | * @generated |
107 | */ |
108 | @Override |
109 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
110 | if (childrenFeatures == null) { |
111 | super.getChildrenFeatures(object); |
112 | childrenFeatures.add(StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT); |
113 | childrenFeatures.add(StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT); |
114 | } |
115 | return childrenFeatures; |
116 | } |
117 | |
118 | /** |
119 | * <!-- begin-user-doc --> |
120 | * <!-- end-user-doc --> |
121 | * @generated |
122 | */ |
123 | @Override |
124 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
125 | // Check the type of the specified child object and return the proper feature to use for |
126 | // adding (see {@link AddCommand}) it as a child. |
127 | |
128 | return super.getChildFeature(object, child); |
129 | } |
130 | |
131 | /** |
132 | * This returns BooleanOperatorExpression.gif. |
133 | * <!-- begin-user-doc --> |
134 | * <!-- end-user-doc --> |
135 | * @generated |
136 | */ |
137 | @Override |
138 | public Object getImage(Object object) { |
139 | return overlayImage(object, getResourceLocator().getImage("full/obj16/BooleanOperatorExpression")); |
140 | } |
141 | |
142 | /** |
143 | * This returns the label text for the adapted class. |
144 | * <!-- begin-user-doc --> |
145 | * <!-- end-user-doc --> |
146 | * @generated |
147 | */ |
148 | @Override |
149 | public String getText(Object object) { |
150 | BooleanOperations labelValue = ((BooleanOperatorExpression)object).getOperation(); |
151 | String label = labelValue == null ? null : labelValue.toString(); |
152 | return label == null || label.length() == 0 ? |
153 | getString("_UI_BooleanOperatorExpression_type") : |
154 | getString("_UI_BooleanOperatorExpression_type") + " " + label; |
155 | } |
156 | |
157 | /** |
158 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
159 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | @Override |
165 | public void notifyChanged(Notification notification) { |
166 | updateChildren(notification); |
167 | |
168 | switch (notification.getFeatureID(BooleanOperatorExpression.class)) { |
169 | case StoexPackage.BOOLEAN_OPERATOR_EXPRESSION__OPERATION: |
170 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
171 | return; |
172 | case StoexPackage.BOOLEAN_OPERATOR_EXPRESSION__LEFT: |
173 | case StoexPackage.BOOLEAN_OPERATOR_EXPRESSION__RIGHT: |
174 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
175 | return; |
176 | } |
177 | super.notifyChanged(notification); |
178 | } |
179 | |
180 | /** |
181 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
182 | * that can be created under this object. |
183 | * <!-- begin-user-doc --> |
184 | * <!-- end-user-doc --> |
185 | * @generated |
186 | */ |
187 | @Override |
188 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
189 | super.collectNewChildDescriptors(newChildDescriptors, object); |
190 | |
191 | newChildDescriptors.add |
192 | (createChildParameter |
193 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
194 | StoexFactory.eINSTANCE.createVariable())); |
195 | |
196 | newChildDescriptors.add |
197 | (createChildParameter |
198 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
199 | StoexFactory.eINSTANCE.createTermExpression())); |
200 | |
201 | newChildDescriptors.add |
202 | (createChildParameter |
203 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
204 | StoexFactory.eINSTANCE.createProductExpression())); |
205 | |
206 | newChildDescriptors.add |
207 | (createChildParameter |
208 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
209 | StoexFactory.eINSTANCE.createProbabilityFunctionLiteral())); |
210 | |
211 | newChildDescriptors.add |
212 | (createChildParameter |
213 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
214 | StoexFactory.eINSTANCE.createParenthesis())); |
215 | |
216 | newChildDescriptors.add |
217 | (createChildParameter |
218 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
219 | StoexFactory.eINSTANCE.createIntLiteral())); |
220 | |
221 | newChildDescriptors.add |
222 | (createChildParameter |
223 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
224 | StoexFactory.eINSTANCE.createDoubleLiteral())); |
225 | |
226 | newChildDescriptors.add |
227 | (createChildParameter |
228 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
229 | StoexFactory.eINSTANCE.createCompareExpression())); |
230 | |
231 | newChildDescriptors.add |
232 | (createChildParameter |
233 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
234 | StoexFactory.eINSTANCE.createBoolLiteral())); |
235 | |
236 | newChildDescriptors.add |
237 | (createChildParameter |
238 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
239 | StoexFactory.eINSTANCE.createStringLiteral())); |
240 | |
241 | newChildDescriptors.add |
242 | (createChildParameter |
243 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
244 | StoexFactory.eINSTANCE.createPowerExpression())); |
245 | |
246 | newChildDescriptors.add |
247 | (createChildParameter |
248 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
249 | StoexFactory.eINSTANCE.createBooleanOperatorExpression())); |
250 | |
251 | newChildDescriptors.add |
252 | (createChildParameter |
253 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
254 | StoexFactory.eINSTANCE.createNotExpression())); |
255 | |
256 | newChildDescriptors.add |
257 | (createChildParameter |
258 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
259 | StoexFactory.eINSTANCE.createNegativeExpression())); |
260 | |
261 | newChildDescriptors.add |
262 | (createChildParameter |
263 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT, |
264 | StoexFactory.eINSTANCE.createFunctionLiteral())); |
265 | |
266 | newChildDescriptors.add |
267 | (createChildParameter |
268 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
269 | StoexFactory.eINSTANCE.createVariable())); |
270 | |
271 | newChildDescriptors.add |
272 | (createChildParameter |
273 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
274 | StoexFactory.eINSTANCE.createTermExpression())); |
275 | |
276 | newChildDescriptors.add |
277 | (createChildParameter |
278 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
279 | StoexFactory.eINSTANCE.createProductExpression())); |
280 | |
281 | newChildDescriptors.add |
282 | (createChildParameter |
283 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
284 | StoexFactory.eINSTANCE.createProbabilityFunctionLiteral())); |
285 | |
286 | newChildDescriptors.add |
287 | (createChildParameter |
288 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
289 | StoexFactory.eINSTANCE.createParenthesis())); |
290 | |
291 | newChildDescriptors.add |
292 | (createChildParameter |
293 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
294 | StoexFactory.eINSTANCE.createIntLiteral())); |
295 | |
296 | newChildDescriptors.add |
297 | (createChildParameter |
298 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
299 | StoexFactory.eINSTANCE.createDoubleLiteral())); |
300 | |
301 | newChildDescriptors.add |
302 | (createChildParameter |
303 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
304 | StoexFactory.eINSTANCE.createCompareExpression())); |
305 | |
306 | newChildDescriptors.add |
307 | (createChildParameter |
308 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
309 | StoexFactory.eINSTANCE.createBoolLiteral())); |
310 | |
311 | newChildDescriptors.add |
312 | (createChildParameter |
313 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
314 | StoexFactory.eINSTANCE.createStringLiteral())); |
315 | |
316 | newChildDescriptors.add |
317 | (createChildParameter |
318 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
319 | StoexFactory.eINSTANCE.createPowerExpression())); |
320 | |
321 | newChildDescriptors.add |
322 | (createChildParameter |
323 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
324 | StoexFactory.eINSTANCE.createBooleanOperatorExpression())); |
325 | |
326 | newChildDescriptors.add |
327 | (createChildParameter |
328 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
329 | StoexFactory.eINSTANCE.createNotExpression())); |
330 | |
331 | newChildDescriptors.add |
332 | (createChildParameter |
333 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
334 | StoexFactory.eINSTANCE.createNegativeExpression())); |
335 | |
336 | newChildDescriptors.add |
337 | (createChildParameter |
338 | (StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT, |
339 | StoexFactory.eINSTANCE.createFunctionLiteral())); |
340 | } |
341 | |
342 | /** |
343 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
344 | * <!-- begin-user-doc --> |
345 | * <!-- end-user-doc --> |
346 | * @generated |
347 | */ |
348 | @Override |
349 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
350 | Object childFeature = feature; |
351 | Object childObject = child; |
352 | |
353 | boolean qualify = |
354 | childFeature == StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__LEFT || |
355 | childFeature == StoexPackage.Literals.BOOLEAN_OPERATOR_EXPRESSION__RIGHT; |
356 | |
357 | if (qualify) { |
358 | return getString |
359 | ("_UI_CreateChild_text2", |
360 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
361 | } |
362 | return super.getCreateChildText(owner, feature, child, selection); |
363 | } |
364 | |
365 | } |