| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.stoex.provider; |
| 8 | |
| 9 | |
| 10 | import java.util.Collection; |
| 11 | import java.util.List; |
| 12 | |
| 13 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 14 | import org.eclipse.emf.common.notify.Notification; |
| 15 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 16 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 17 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 18 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 19 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 20 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 21 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 22 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 23 | |
| 24 | import de.uka.ipd.sdq.stoex.PowerExpression; |
| 25 | import de.uka.ipd.sdq.stoex.StoexFactory; |
| 26 | import de.uka.ipd.sdq.stoex.StoexPackage; |
| 27 | |
| 28 | /** |
| 29 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.stoex.PowerExpression} object. |
| 30 | * <!-- begin-user-doc --> |
| 31 | * <!-- end-user-doc --> |
| 32 | * @generated |
| 33 | */ |
| 34 | public class PowerExpressionItemProvider |
| 35 | extends PowerItemProvider |
| 36 | implements |
| 37 | IEditingDomainItemProvider, |
| 38 | IStructuredItemContentProvider, |
| 39 | ITreeItemContentProvider, |
| 40 | IItemLabelProvider, |
| 41 | IItemPropertySource { |
| 42 | /** |
| 43 | * <!-- begin-user-doc --> |
| 44 | * <!-- end-user-doc --> |
| 45 | * @generated |
| 46 | */ |
| 47 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 48 | |
| 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 PowerExpressionItemProvider(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 | } |
| 71 | return itemPropertyDescriptors; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 76 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 77 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 78 | * <!-- begin-user-doc --> |
| 79 | * <!-- end-user-doc --> |
| 80 | * @generated |
| 81 | */ |
| 82 | @Override |
| 83 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 84 | if (childrenFeatures == null) { |
| 85 | super.getChildrenFeatures(object); |
| 86 | childrenFeatures.add(StoexPackage.Literals.POWER_EXPRESSION__BASE); |
| 87 | childrenFeatures.add(StoexPackage.Literals.POWER_EXPRESSION__EXPONENT); |
| 88 | } |
| 89 | return childrenFeatures; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | @Override |
| 98 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 99 | // Check the type of the specified child object and return the proper feature to use for |
| 100 | // adding (see {@link AddCommand}) it as a child. |
| 101 | |
| 102 | return super.getChildFeature(object, child); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * This returns PowerExpression.gif. |
| 107 | * <!-- begin-user-doc --> |
| 108 | * <!-- end-user-doc --> |
| 109 | * @generated |
| 110 | */ |
| 111 | @Override |
| 112 | public Object getImage(Object object) { |
| 113 | return overlayImage(object, getResourceLocator().getImage("full/obj16/PowerExpression")); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * This returns the label text for the adapted class. |
| 118 | * <!-- begin-user-doc --> |
| 119 | * <!-- end-user-doc --> |
| 120 | * @generated |
| 121 | */ |
| 122 | @Override |
| 123 | public String getText(Object object) { |
| 124 | return getString("_UI_PowerExpression_type"); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 129 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 130 | * <!-- begin-user-doc --> |
| 131 | * <!-- end-user-doc --> |
| 132 | * @generated |
| 133 | */ |
| 134 | @Override |
| 135 | public void notifyChanged(Notification notification) { |
| 136 | updateChildren(notification); |
| 137 | |
| 138 | switch (notification.getFeatureID(PowerExpression.class)) { |
| 139 | case StoexPackage.POWER_EXPRESSION__BASE: |
| 140 | case StoexPackage.POWER_EXPRESSION__EXPONENT: |
| 141 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 142 | return; |
| 143 | } |
| 144 | super.notifyChanged(notification); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 149 | * that can be created under this object. |
| 150 | * <!-- begin-user-doc --> |
| 151 | * <!-- end-user-doc --> |
| 152 | * @generated |
| 153 | */ |
| 154 | @Override |
| 155 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 156 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 157 | |
| 158 | newChildDescriptors.add |
| 159 | (createChildParameter |
| 160 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 161 | StoexFactory.eINSTANCE.createVariable())); |
| 162 | |
| 163 | newChildDescriptors.add |
| 164 | (createChildParameter |
| 165 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 166 | StoexFactory.eINSTANCE.createProbabilityFunctionLiteral())); |
| 167 | |
| 168 | newChildDescriptors.add |
| 169 | (createChildParameter |
| 170 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 171 | StoexFactory.eINSTANCE.createParenthesis())); |
| 172 | |
| 173 | newChildDescriptors.add |
| 174 | (createChildParameter |
| 175 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 176 | StoexFactory.eINSTANCE.createIntLiteral())); |
| 177 | |
| 178 | newChildDescriptors.add |
| 179 | (createChildParameter |
| 180 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 181 | StoexFactory.eINSTANCE.createDoubleLiteral())); |
| 182 | |
| 183 | newChildDescriptors.add |
| 184 | (createChildParameter |
| 185 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 186 | StoexFactory.eINSTANCE.createBoolLiteral())); |
| 187 | |
| 188 | newChildDescriptors.add |
| 189 | (createChildParameter |
| 190 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 191 | StoexFactory.eINSTANCE.createStringLiteral())); |
| 192 | |
| 193 | newChildDescriptors.add |
| 194 | (createChildParameter |
| 195 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 196 | StoexFactory.eINSTANCE.createPowerExpression())); |
| 197 | |
| 198 | newChildDescriptors.add |
| 199 | (createChildParameter |
| 200 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 201 | StoexFactory.eINSTANCE.createNotExpression())); |
| 202 | |
| 203 | newChildDescriptors.add |
| 204 | (createChildParameter |
| 205 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 206 | StoexFactory.eINSTANCE.createNegativeExpression())); |
| 207 | |
| 208 | newChildDescriptors.add |
| 209 | (createChildParameter |
| 210 | (StoexPackage.Literals.POWER_EXPRESSION__BASE, |
| 211 | StoexFactory.eINSTANCE.createFunctionLiteral())); |
| 212 | |
| 213 | newChildDescriptors.add |
| 214 | (createChildParameter |
| 215 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 216 | StoexFactory.eINSTANCE.createVariable())); |
| 217 | |
| 218 | newChildDescriptors.add |
| 219 | (createChildParameter |
| 220 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 221 | StoexFactory.eINSTANCE.createProbabilityFunctionLiteral())); |
| 222 | |
| 223 | newChildDescriptors.add |
| 224 | (createChildParameter |
| 225 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 226 | StoexFactory.eINSTANCE.createParenthesis())); |
| 227 | |
| 228 | newChildDescriptors.add |
| 229 | (createChildParameter |
| 230 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 231 | StoexFactory.eINSTANCE.createIntLiteral())); |
| 232 | |
| 233 | newChildDescriptors.add |
| 234 | (createChildParameter |
| 235 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 236 | StoexFactory.eINSTANCE.createDoubleLiteral())); |
| 237 | |
| 238 | newChildDescriptors.add |
| 239 | (createChildParameter |
| 240 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 241 | StoexFactory.eINSTANCE.createBoolLiteral())); |
| 242 | |
| 243 | newChildDescriptors.add |
| 244 | (createChildParameter |
| 245 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 246 | StoexFactory.eINSTANCE.createStringLiteral())); |
| 247 | |
| 248 | newChildDescriptors.add |
| 249 | (createChildParameter |
| 250 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 251 | StoexFactory.eINSTANCE.createNotExpression())); |
| 252 | |
| 253 | newChildDescriptors.add |
| 254 | (createChildParameter |
| 255 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 256 | StoexFactory.eINSTANCE.createNegativeExpression())); |
| 257 | |
| 258 | newChildDescriptors.add |
| 259 | (createChildParameter |
| 260 | (StoexPackage.Literals.POWER_EXPRESSION__EXPONENT, |
| 261 | StoexFactory.eINSTANCE.createFunctionLiteral())); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
| 266 | * <!-- begin-user-doc --> |
| 267 | * <!-- end-user-doc --> |
| 268 | * @generated |
| 269 | */ |
| 270 | @Override |
| 271 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
| 272 | Object childFeature = feature; |
| 273 | Object childObject = child; |
| 274 | |
| 275 | boolean qualify = |
| 276 | childFeature == StoexPackage.Literals.POWER_EXPRESSION__BASE || |
| 277 | childFeature == StoexPackage.Literals.POWER_EXPRESSION__EXPONENT; |
| 278 | |
| 279 | if (qualify) { |
| 280 | return getString |
| 281 | ("_UI_CreateChild_text2", |
| 282 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
| 283 | } |
| 284 | return super.getCreateChildText(owner, feature, child, selection); |
| 285 | } |
| 286 | |
| 287 | } |