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