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