| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.provider; |
| 8 | |
| 9 | |
| 10 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractFactory; |
| 11 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractPackage; |
| 12 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.RangeValue; |
| 13 | |
| 14 | import de.uka.ipd.sdq.dsexplore.qml.profile.QMLProfile.provider.QMLProfileEditPlugin; |
| 15 | |
| 16 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProvider; |
| 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.common.util.ResourceLocator; |
| 25 | |
| 26 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 27 | |
| 28 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 29 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 30 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 31 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 32 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 33 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 34 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 35 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 36 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 37 | |
| 38 | /** |
| 39 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.RangeValue} object. |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @generated |
| 43 | */ |
| 44 | public class RangeValueItemProvider |
| 45 | extends IdentifierItemProvider |
| 46 | implements |
| 47 | IEditingDomainItemProvider, |
| 48 | IStructuredItemContentProvider, |
| 49 | ITreeItemContentProvider, |
| 50 | IItemLabelProvider, |
| 51 | IItemPropertySource { |
| 52 | /** |
| 53 | * This constructs an instance from a factory and a notifier. |
| 54 | * <!-- begin-user-doc --> |
| 55 | * <!-- end-user-doc --> |
| 56 | * @generated |
| 57 | */ |
| 58 | public RangeValueItemProvider(AdapterFactory adapterFactory) { |
| 59 | super(adapterFactory); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * This returns the property descriptors for the adapted class. |
| 64 | * <!-- begin-user-doc --> |
| 65 | * <!-- end-user-doc --> |
| 66 | * @generated |
| 67 | */ |
| 68 | @Override |
| 69 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 70 | if (itemPropertyDescriptors == null) { |
| 71 | super.getPropertyDescriptors(object); |
| 72 | |
| 73 | addTypePropertyDescriptor(object); |
| 74 | } |
| 75 | return itemPropertyDescriptors; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * This adds a property descriptor for the Type feature. |
| 80 | * <!-- begin-user-doc --> |
| 81 | * <!-- end-user-doc --> |
| 82 | * @generated |
| 83 | */ |
| 84 | protected void addTypePropertyDescriptor(Object object) { |
| 85 | itemPropertyDescriptors.add |
| 86 | (createItemPropertyDescriptor |
| 87 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 88 | getResourceLocator(), |
| 89 | getString("_UI_RangeValue_type_feature"), |
| 90 | getString("_UI_PropertyDescriptor_description", "_UI_RangeValue_type_feature", "_UI_RangeValue_type"), |
| 91 | QMLContractPackage.Literals.RANGE_VALUE__TYPE, |
| 92 | true, |
| 93 | false, |
| 94 | false, |
| 95 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
| 96 | null, |
| 97 | null)); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 102 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 103 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 104 | * <!-- begin-user-doc --> |
| 105 | * <!-- end-user-doc --> |
| 106 | * @generated |
| 107 | */ |
| 108 | @Override |
| 109 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 110 | if (childrenFeatures == null) { |
| 111 | super.getChildrenFeatures(object); |
| 112 | childrenFeatures.add(QMLContractPackage.Literals.RANGE_VALUE__RANGE_LIMIT_LITERAL); |
| 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 RangeValue.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/RangeValue")); |
| 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 = ((RangeValue)object).getId(); |
| 150 | return label == null || label.length() == 0 ? |
| 151 | getString("_UI_RangeValue_type") : |
| 152 | getString("_UI_RangeValue_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(RangeValue.class)) { |
| 167 | case QMLContractPackage.RANGE_VALUE__TYPE: |
| 168 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 169 | return; |
| 170 | case QMLContractPackage.RANGE_VALUE__RANGE_LIMIT_LITERAL: |
| 171 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 172 | return; |
| 173 | } |
| 174 | super.notifyChanged(notification); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 179 | * that can be created under this object. |
| 180 | * <!-- begin-user-doc --> |
| 181 | * <!-- end-user-doc --> |
| 182 | * @generated |
| 183 | */ |
| 184 | @Override |
| 185 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 186 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 187 | |
| 188 | newChildDescriptors.add |
| 189 | (createChildParameter |
| 190 | (QMLContractPackage.Literals.RANGE_VALUE__RANGE_LIMIT_LITERAL, |
| 191 | QMLContractFactory.eINSTANCE.createNumericLiteral())); |
| 192 | |
| 193 | newChildDescriptors.add |
| 194 | (createChildParameter |
| 195 | (QMLContractPackage.Literals.RANGE_VALUE__RANGE_LIMIT_LITERAL, |
| 196 | QMLContractFactory.eINSTANCE.createEnumLiteral())); |
| 197 | |
| 198 | newChildDescriptors.add |
| 199 | (createChildParameter |
| 200 | (QMLContractPackage.Literals.RANGE_VALUE__RANGE_LIMIT_LITERAL, |
| 201 | QMLContractFactory.eINSTANCE.createSetLiteral())); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Return the resource locator for this item provider's resources. |
| 206 | * <!-- begin-user-doc --> |
| 207 | * <!-- end-user-doc --> |
| 208 | * @generated |
| 209 | */ |
| 210 | @Override |
| 211 | public ResourceLocator getResourceLocator() { |
| 212 | return QMLProfileEditPlugin.INSTANCE; |
| 213 | } |
| 214 | |
| 215 | } |