| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EssentialOCL.provider; |
| 8 | |
| 9 | |
| 10 | import EssentialOCL.CollectionLiteralExp; |
| 11 | import EssentialOCL.EssentialOCLFactory; |
| 12 | import EssentialOCL.EssentialOCLPackage; |
| 13 | |
| 14 | import java.util.Collection; |
| 15 | import java.util.List; |
| 16 | |
| 17 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 18 | import org.eclipse.emf.common.notify.Notification; |
| 19 | |
| 20 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 21 | |
| 22 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 23 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 24 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 25 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 26 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 27 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 28 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 29 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 31 | |
| 32 | /** |
| 33 | * This is the item provider adapter for a {@link EssentialOCL.CollectionLiteralExp} object. |
| 34 | * <!-- begin-user-doc --> |
| 35 | * <!-- end-user-doc --> |
| 36 | * @generated |
| 37 | */ |
| 38 | public class CollectionLiteralExpItemProvider |
| 39 | extends LiteralExpItemProvider |
| 40 | implements |
| 41 | IEditingDomainItemProvider, |
| 42 | IStructuredItemContentProvider, |
| 43 | ITreeItemContentProvider, |
| 44 | IItemLabelProvider, |
| 45 | IItemPropertySource { |
| 46 | /** |
| 47 | * This constructs an instance from a factory and a notifier. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @generated |
| 51 | */ |
| 52 | public CollectionLiteralExpItemProvider(AdapterFactory adapterFactory) { |
| 53 | super(adapterFactory); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * This returns the property descriptors for the adapted class. |
| 58 | * <!-- begin-user-doc --> |
| 59 | * <!-- end-user-doc --> |
| 60 | * @generated |
| 61 | */ |
| 62 | @Override |
| 63 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 64 | if (itemPropertyDescriptors == null) { |
| 65 | super.getPropertyDescriptors(object); |
| 66 | |
| 67 | addKindPropertyDescriptor(object); |
| 68 | } |
| 69 | return itemPropertyDescriptors; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * This adds a property descriptor for the Kind feature. |
| 74 | * <!-- begin-user-doc --> |
| 75 | * <!-- end-user-doc --> |
| 76 | * @generated |
| 77 | */ |
| 78 | protected void addKindPropertyDescriptor(Object object) { |
| 79 | itemPropertyDescriptors.add |
| 80 | (createItemPropertyDescriptor |
| 81 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 82 | getResourceLocator(), |
| 83 | getString("_UI_CollectionLiteralExp_kind_feature"), |
| 84 | getString("_UI_PropertyDescriptor_description", "_UI_CollectionLiteralExp_kind_feature", "_UI_CollectionLiteralExp_type"), |
| 85 | EssentialOCLPackage.Literals.COLLECTION_LITERAL_EXP__KIND, |
| 86 | true, |
| 87 | false, |
| 88 | false, |
| 89 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
| 90 | null, |
| 91 | null)); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 96 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 97 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 98 | * <!-- begin-user-doc --> |
| 99 | * <!-- end-user-doc --> |
| 100 | * @generated |
| 101 | */ |
| 102 | @Override |
| 103 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 104 | if (childrenFeatures == null) { |
| 105 | super.getChildrenFeatures(object); |
| 106 | childrenFeatures.add(EssentialOCLPackage.Literals.COLLECTION_LITERAL_EXP__PART); |
| 107 | } |
| 108 | return childrenFeatures; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * <!-- begin-user-doc --> |
| 113 | * <!-- end-user-doc --> |
| 114 | * @generated |
| 115 | */ |
| 116 | @Override |
| 117 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 118 | // Check the type of the specified child object and return the proper feature to use for |
| 119 | // adding (see {@link AddCommand}) it as a child. |
| 120 | |
| 121 | return super.getChildFeature(object, child); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * This returns CollectionLiteralExp.gif. |
| 126 | * <!-- begin-user-doc --> |
| 127 | * <!-- end-user-doc --> |
| 128 | * @generated |
| 129 | */ |
| 130 | @Override |
| 131 | public Object getImage(Object object) { |
| 132 | return overlayImage(object, getResourceLocator().getImage("full/obj16/CollectionLiteralExp")); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * This returns the label text for the adapted class. |
| 137 | * <!-- begin-user-doc --> |
| 138 | * <!-- end-user-doc --> |
| 139 | * @generated |
| 140 | */ |
| 141 | @Override |
| 142 | public String getText(Object object) { |
| 143 | String label = ((CollectionLiteralExp)object).getName(); |
| 144 | return label == null || label.length() == 0 ? |
| 145 | getString("_UI_CollectionLiteralExp_type") : |
| 146 | getString("_UI_CollectionLiteralExp_type") + " " + label; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 151 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 152 | * <!-- begin-user-doc --> |
| 153 | * <!-- end-user-doc --> |
| 154 | * @generated |
| 155 | */ |
| 156 | @Override |
| 157 | public void notifyChanged(Notification notification) { |
| 158 | updateChildren(notification); |
| 159 | |
| 160 | switch (notification.getFeatureID(CollectionLiteralExp.class)) { |
| 161 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__KIND: |
| 162 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 163 | return; |
| 164 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 165 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 166 | return; |
| 167 | } |
| 168 | super.notifyChanged(notification); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 173 | * that can be created under this object. |
| 174 | * <!-- begin-user-doc --> |
| 175 | * <!-- end-user-doc --> |
| 176 | * @generated |
| 177 | */ |
| 178 | @Override |
| 179 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 180 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 181 | |
| 182 | newChildDescriptors.add |
| 183 | (createChildParameter |
| 184 | (EssentialOCLPackage.Literals.COLLECTION_LITERAL_EXP__PART, |
| 185 | EssentialOCLFactory.eINSTANCE.createCollectionItem())); |
| 186 | |
| 187 | newChildDescriptors.add |
| 188 | (createChildParameter |
| 189 | (EssentialOCLPackage.Literals.COLLECTION_LITERAL_EXP__PART, |
| 190 | EssentialOCLFactory.eINSTANCE.createCollectionRange())); |
| 191 | } |
| 192 | |
| 193 | } |