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