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