1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EMOF.provider; |
8 | |
9 | |
10 | import EMOF.EMOFFactory; |
11 | import EMOF.EMOFPackage; |
12 | import EMOF.Operation; |
13 | |
14 | import QVTBase.QVTBaseFactory; |
15 | |
16 | import java.util.Collection; |
17 | import java.util.List; |
18 | |
19 | import org.eclipse.emf.common.notify.AdapterFactory; |
20 | import org.eclipse.emf.common.notify.Notification; |
21 | |
22 | import org.eclipse.emf.ecore.EStructuralFeature; |
23 | |
24 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
25 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
26 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
27 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
28 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
29 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
30 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
31 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
32 | import org.eclipse.emf.edit.provider.ViewerNotification; |
33 | |
34 | /** |
35 | * This is the item provider adapter for a {@link EMOF.Operation} object. |
36 | * <!-- begin-user-doc --> |
37 | * <!-- end-user-doc --> |
38 | * @generated |
39 | */ |
40 | public class OperationItemProvider |
41 | extends TypedElementItemProvider |
42 | implements |
43 | IEditingDomainItemProvider, |
44 | IStructuredItemContentProvider, |
45 | ITreeItemContentProvider, |
46 | IItemLabelProvider, |
47 | IItemPropertySource { |
48 | /** |
49 | * This constructs an instance from a factory and a notifier. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @generated |
53 | */ |
54 | public OperationItemProvider(AdapterFactory adapterFactory) { |
55 | super(adapterFactory); |
56 | } |
57 | |
58 | /** |
59 | * This returns the property descriptors for the adapted class. |
60 | * <!-- begin-user-doc --> |
61 | * <!-- end-user-doc --> |
62 | * @generated |
63 | */ |
64 | @Override |
65 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
66 | if (itemPropertyDescriptors == null) { |
67 | super.getPropertyDescriptors(object); |
68 | |
69 | addIsOrderedPropertyDescriptor(object); |
70 | addIsUniquePropertyDescriptor(object); |
71 | addLowerPropertyDescriptor(object); |
72 | addUpperPropertyDescriptor(object); |
73 | addRaisedExceptionPropertyDescriptor(object); |
74 | } |
75 | return itemPropertyDescriptors; |
76 | } |
77 | |
78 | /** |
79 | * This adds a property descriptor for the Is Ordered feature. |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | protected void addIsOrderedPropertyDescriptor(Object object) { |
85 | itemPropertyDescriptors.add |
86 | (createItemPropertyDescriptor |
87 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
88 | getResourceLocator(), |
89 | getString("_UI_MultiplicityElement_isOrdered_feature"), |
90 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_isOrdered_feature", "_UI_MultiplicityElement_type"), |
91 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__IS_ORDERED, |
92 | true, |
93 | false, |
94 | false, |
95 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
96 | null, |
97 | null)); |
98 | } |
99 | |
100 | /** |
101 | * This adds a property descriptor for the Is Unique feature. |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | protected void addIsUniquePropertyDescriptor(Object object) { |
107 | itemPropertyDescriptors.add |
108 | (createItemPropertyDescriptor |
109 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
110 | getResourceLocator(), |
111 | getString("_UI_MultiplicityElement_isUnique_feature"), |
112 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_isUnique_feature", "_UI_MultiplicityElement_type"), |
113 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__IS_UNIQUE, |
114 | true, |
115 | false, |
116 | false, |
117 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
118 | null, |
119 | null)); |
120 | } |
121 | |
122 | /** |
123 | * This adds a property descriptor for the Lower feature. |
124 | * <!-- begin-user-doc --> |
125 | * <!-- end-user-doc --> |
126 | * @generated |
127 | */ |
128 | protected void addLowerPropertyDescriptor(Object object) { |
129 | itemPropertyDescriptors.add |
130 | (createItemPropertyDescriptor |
131 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
132 | getResourceLocator(), |
133 | getString("_UI_MultiplicityElement_lower_feature"), |
134 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_lower_feature", "_UI_MultiplicityElement_type"), |
135 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__LOWER, |
136 | true, |
137 | false, |
138 | false, |
139 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
140 | null, |
141 | null)); |
142 | } |
143 | |
144 | /** |
145 | * This adds a property descriptor for the Upper feature. |
146 | * <!-- begin-user-doc --> |
147 | * <!-- end-user-doc --> |
148 | * @generated |
149 | */ |
150 | protected void addUpperPropertyDescriptor(Object object) { |
151 | itemPropertyDescriptors.add |
152 | (createItemPropertyDescriptor |
153 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
154 | getResourceLocator(), |
155 | getString("_UI_MultiplicityElement_upper_feature"), |
156 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_upper_feature", "_UI_MultiplicityElement_type"), |
157 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__UPPER, |
158 | true, |
159 | false, |
160 | false, |
161 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
162 | null, |
163 | null)); |
164 | } |
165 | |
166 | /** |
167 | * This adds a property descriptor for the Raised Exception feature. |
168 | * <!-- begin-user-doc --> |
169 | * <!-- end-user-doc --> |
170 | * @generated |
171 | */ |
172 | protected void addRaisedExceptionPropertyDescriptor(Object object) { |
173 | itemPropertyDescriptors.add |
174 | (createItemPropertyDescriptor |
175 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
176 | getResourceLocator(), |
177 | getString("_UI_Operation_raisedException_feature"), |
178 | getString("_UI_PropertyDescriptor_description", "_UI_Operation_raisedException_feature", "_UI_Operation_type"), |
179 | EMOFPackage.Literals.OPERATION__RAISED_EXCEPTION, |
180 | true, |
181 | false, |
182 | true, |
183 | null, |
184 | null, |
185 | null)); |
186 | } |
187 | |
188 | /** |
189 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
190 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
191 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
192 | * <!-- begin-user-doc --> |
193 | * <!-- end-user-doc --> |
194 | * @generated |
195 | */ |
196 | @Override |
197 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
198 | if (childrenFeatures == null) { |
199 | super.getChildrenFeatures(object); |
200 | childrenFeatures.add(EMOFPackage.Literals.OPERATION__OWNED_PARAMETER); |
201 | } |
202 | return childrenFeatures; |
203 | } |
204 | |
205 | /** |
206 | * <!-- begin-user-doc --> |
207 | * <!-- end-user-doc --> |
208 | * @generated |
209 | */ |
210 | @Override |
211 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
212 | // Check the type of the specified child object and return the proper feature to use for |
213 | // adding (see {@link AddCommand}) it as a child. |
214 | |
215 | return super.getChildFeature(object, child); |
216 | } |
217 | |
218 | /** |
219 | * This returns Operation.gif. |
220 | * <!-- begin-user-doc --> |
221 | * <!-- end-user-doc --> |
222 | * @generated |
223 | */ |
224 | @Override |
225 | public Object getImage(Object object) { |
226 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Operation")); |
227 | } |
228 | |
229 | /** |
230 | * This returns the label text for the adapted class. |
231 | * <!-- begin-user-doc --> |
232 | * <!-- end-user-doc --> |
233 | * @generated |
234 | */ |
235 | @Override |
236 | public String getText(Object object) { |
237 | String label = ((Operation)object).getName(); |
238 | return label == null || label.length() == 0 ? |
239 | getString("_UI_Operation_type") : |
240 | getString("_UI_Operation_type") + " " + label; |
241 | } |
242 | |
243 | /** |
244 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
245 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
246 | * <!-- begin-user-doc --> |
247 | * <!-- end-user-doc --> |
248 | * @generated |
249 | */ |
250 | @Override |
251 | public void notifyChanged(Notification notification) { |
252 | updateChildren(notification); |
253 | |
254 | switch (notification.getFeatureID(Operation.class)) { |
255 | case EMOFPackage.OPERATION__IS_ORDERED: |
256 | case EMOFPackage.OPERATION__IS_UNIQUE: |
257 | case EMOFPackage.OPERATION__LOWER: |
258 | case EMOFPackage.OPERATION__UPPER: |
259 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
260 | return; |
261 | case EMOFPackage.OPERATION__OWNED_PARAMETER: |
262 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
263 | return; |
264 | } |
265 | super.notifyChanged(notification); |
266 | } |
267 | |
268 | /** |
269 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
270 | * that can be created under this object. |
271 | * <!-- begin-user-doc --> |
272 | * <!-- end-user-doc --> |
273 | * @generated |
274 | */ |
275 | @Override |
276 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
277 | super.collectNewChildDescriptors(newChildDescriptors, object); |
278 | |
279 | newChildDescriptors.add |
280 | (createChildParameter |
281 | (EMOFPackage.Literals.OPERATION__OWNED_PARAMETER, |
282 | EMOFFactory.eINSTANCE.createParameter())); |
283 | |
284 | newChildDescriptors.add |
285 | (createChildParameter |
286 | (EMOFPackage.Literals.OPERATION__OWNED_PARAMETER, |
287 | QVTBaseFactory.eINSTANCE.createFunctionParameter())); |
288 | } |
289 | |
290 | } |