1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EssentialOCL.provider; |
8 | |
9 | |
10 | import EMOF.provider.QvtmodelsEditPlugin; |
11 | import EMOF.provider.TypedElementItemProvider; |
12 | |
13 | import EssentialOCL.EssentialOCLFactory; |
14 | import EssentialOCL.EssentialOCLPackage; |
15 | import EssentialOCL.Variable; |
16 | |
17 | import QVTRelation.QVTRelationFactory; |
18 | |
19 | import QVTTemplate.QVTTemplateFactory; |
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.ViewerNotification; |
39 | |
40 | /** |
41 | * This is the item provider adapter for a {@link EssentialOCL.Variable} object. |
42 | * <!-- begin-user-doc --> |
43 | * <!-- end-user-doc --> |
44 | * @generated |
45 | */ |
46 | public class VariableItemProvider |
47 | extends TypedElementItemProvider |
48 | implements |
49 | IEditingDomainItemProvider, |
50 | IStructuredItemContentProvider, |
51 | ITreeItemContentProvider, |
52 | IItemLabelProvider, |
53 | IItemPropertySource { |
54 | /** |
55 | * This constructs an instance from a factory and a notifier. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @generated |
59 | */ |
60 | public VariableItemProvider(AdapterFactory adapterFactory) { |
61 | super(adapterFactory); |
62 | } |
63 | |
64 | /** |
65 | * This returns the property descriptors for the adapted class. |
66 | * <!-- begin-user-doc --> |
67 | * <!-- end-user-doc --> |
68 | * @generated |
69 | */ |
70 | @Override |
71 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
72 | if (itemPropertyDescriptors == null) { |
73 | super.getPropertyDescriptors(object); |
74 | |
75 | addRepresentedParameterPropertyDescriptor(object); |
76 | } |
77 | return itemPropertyDescriptors; |
78 | } |
79 | |
80 | /** |
81 | * This adds a property descriptor for the Represented Parameter feature. |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected void addRepresentedParameterPropertyDescriptor(Object object) { |
87 | itemPropertyDescriptors.add |
88 | (createItemPropertyDescriptor |
89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
90 | getResourceLocator(), |
91 | getString("_UI_Variable_representedParameter_feature"), |
92 | getString("_UI_PropertyDescriptor_description", "_UI_Variable_representedParameter_feature", "_UI_Variable_type"), |
93 | EssentialOCLPackage.Literals.VARIABLE__REPRESENTED_PARAMETER, |
94 | true, |
95 | false, |
96 | true, |
97 | null, |
98 | null, |
99 | null)); |
100 | } |
101 | |
102 | /** |
103 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
104 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
105 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | @Override |
111 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
112 | if (childrenFeatures == null) { |
113 | super.getChildrenFeatures(object); |
114 | childrenFeatures.add(EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION); |
115 | } |
116 | return childrenFeatures; |
117 | } |
118 | |
119 | /** |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | @Override |
125 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
126 | // Check the type of the specified child object and return the proper feature to use for |
127 | // adding (see {@link AddCommand}) it as a child. |
128 | |
129 | return super.getChildFeature(object, child); |
130 | } |
131 | |
132 | /** |
133 | * This returns Variable.gif. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Object getImage(Object object) { |
140 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Variable")); |
141 | } |
142 | |
143 | /** |
144 | * This returns the label text for the adapted class. |
145 | * <!-- begin-user-doc --> |
146 | * <!-- end-user-doc --> |
147 | * @generated |
148 | */ |
149 | @Override |
150 | public String getText(Object object) { |
151 | String label = ((Variable)object).getName(); |
152 | return label == null || label.length() == 0 ? |
153 | getString("_UI_Variable_type") : |
154 | getString("_UI_Variable_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(Variable.class)) { |
169 | case EssentialOCLPackage.VARIABLE__INIT_EXPRESSION: |
170 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
171 | return; |
172 | } |
173 | super.notifyChanged(notification); |
174 | } |
175 | |
176 | /** |
177 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
178 | * that can be created under this object. |
179 | * <!-- begin-user-doc --> |
180 | * <!-- end-user-doc --> |
181 | * @generated |
182 | */ |
183 | @Override |
184 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
185 | super.collectNewChildDescriptors(newChildDescriptors, object); |
186 | |
187 | newChildDescriptors.add |
188 | (createChildParameter |
189 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
190 | EssentialOCLFactory.eINSTANCE.createBooleanLiteralExp())); |
191 | |
192 | newChildDescriptors.add |
193 | (createChildParameter |
194 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
195 | EssentialOCLFactory.eINSTANCE.createCollectionLiteralExp())); |
196 | |
197 | newChildDescriptors.add |
198 | (createChildParameter |
199 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
200 | EssentialOCLFactory.eINSTANCE.createEnumLiteralExp())); |
201 | |
202 | newChildDescriptors.add |
203 | (createChildParameter |
204 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
205 | EssentialOCLFactory.eINSTANCE.createIfExp())); |
206 | |
207 | newChildDescriptors.add |
208 | (createChildParameter |
209 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
210 | EssentialOCLFactory.eINSTANCE.createIntegerLiteralExp())); |
211 | |
212 | newChildDescriptors.add |
213 | (createChildParameter |
214 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
215 | EssentialOCLFactory.eINSTANCE.createInvalidLiteralExp())); |
216 | |
217 | newChildDescriptors.add |
218 | (createChildParameter |
219 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
220 | EssentialOCLFactory.eINSTANCE.createIterateExp())); |
221 | |
222 | newChildDescriptors.add |
223 | (createChildParameter |
224 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
225 | EssentialOCLFactory.eINSTANCE.createIteratorExp())); |
226 | |
227 | newChildDescriptors.add |
228 | (createChildParameter |
229 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
230 | EssentialOCLFactory.eINSTANCE.createLetExp())); |
231 | |
232 | newChildDescriptors.add |
233 | (createChildParameter |
234 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
235 | EssentialOCLFactory.eINSTANCE.createNavigationCallExp())); |
236 | |
237 | newChildDescriptors.add |
238 | (createChildParameter |
239 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
240 | EssentialOCLFactory.eINSTANCE.createNullLiteralExp())); |
241 | |
242 | newChildDescriptors.add |
243 | (createChildParameter |
244 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
245 | EssentialOCLFactory.eINSTANCE.createOperationCallExp())); |
246 | |
247 | newChildDescriptors.add |
248 | (createChildParameter |
249 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
250 | EssentialOCLFactory.eINSTANCE.createPropertyCallExp())); |
251 | |
252 | newChildDescriptors.add |
253 | (createChildParameter |
254 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
255 | EssentialOCLFactory.eINSTANCE.createRealLiteralExp())); |
256 | |
257 | newChildDescriptors.add |
258 | (createChildParameter |
259 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
260 | EssentialOCLFactory.eINSTANCE.createStringLiteralExp())); |
261 | |
262 | newChildDescriptors.add |
263 | (createChildParameter |
264 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
265 | EssentialOCLFactory.eINSTANCE.createTupleLiteralExp())); |
266 | |
267 | newChildDescriptors.add |
268 | (createChildParameter |
269 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
270 | EssentialOCLFactory.eINSTANCE.createTypeExp())); |
271 | |
272 | newChildDescriptors.add |
273 | (createChildParameter |
274 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
275 | EssentialOCLFactory.eINSTANCE.createUnlimitedNaturalExp())); |
276 | |
277 | newChildDescriptors.add |
278 | (createChildParameter |
279 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
280 | EssentialOCLFactory.eINSTANCE.createVariableExp())); |
281 | |
282 | newChildDescriptors.add |
283 | (createChildParameter |
284 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
285 | QVTRelationFactory.eINSTANCE.createOppositePropertyCallExp())); |
286 | |
287 | newChildDescriptors.add |
288 | (createChildParameter |
289 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
290 | QVTRelationFactory.eINSTANCE.createRelationCallExp())); |
291 | |
292 | newChildDescriptors.add |
293 | (createChildParameter |
294 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
295 | QVTTemplateFactory.eINSTANCE.createCollectionTemplateExp())); |
296 | |
297 | newChildDescriptors.add |
298 | (createChildParameter |
299 | (EssentialOCLPackage.Literals.VARIABLE__INIT_EXPRESSION, |
300 | QVTTemplateFactory.eINSTANCE.createObjectTemplateExp())); |
301 | } |
302 | |
303 | /** |
304 | * Return the resource locator for this item provider's resources. |
305 | * <!-- begin-user-doc --> |
306 | * <!-- end-user-doc --> |
307 | * @generated |
308 | */ |
309 | @Override |
310 | public ResourceLocator getResourceLocator() { |
311 | return QvtmodelsEditPlugin.INSTANCE; |
312 | } |
313 | |
314 | } |