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