| 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.ComposeableAdapterFactory; |
| 17 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 18 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 19 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 20 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 21 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 22 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 23 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 24 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 25 | |
| 26 | import de.uka.ipd.sdq.stoex.FunctionLiteral; |
| 27 | import de.uka.ipd.sdq.stoex.StoexFactory; |
| 28 | import de.uka.ipd.sdq.stoex.StoexPackage; |
| 29 | |
| 30 | /** |
| 31 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.stoex.FunctionLiteral} object. |
| 32 | * <!-- begin-user-doc --> |
| 33 | * <!-- end-user-doc --> |
| 34 | * @generated |
| 35 | */ |
| 36 | public class FunctionLiteralItemProvider |
| 37 | extends AtomItemProvider |
| 38 | implements |
| 39 | IEditingDomainItemProvider, |
| 40 | IStructuredItemContentProvider, |
| 41 | ITreeItemContentProvider, |
| 42 | IItemLabelProvider, |
| 43 | IItemPropertySource { |
| 44 | /** |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @generated |
| 48 | */ |
| 49 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 50 | |
| 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 FunctionLiteralItemProvider(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 | addIdPropertyDescriptor(object); |
| 73 | } |
| 74 | return itemPropertyDescriptors; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * This adds a property descriptor for the Id feature. |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | protected void addIdPropertyDescriptor(Object object) { |
| 84 | itemPropertyDescriptors.add |
| 85 | (createItemPropertyDescriptor |
| 86 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 87 | getResourceLocator(), |
| 88 | getString("_UI_FunctionLiteral_id_feature"), |
| 89 | getString("_UI_PropertyDescriptor_description", "_UI_FunctionLiteral_id_feature", "_UI_FunctionLiteral_type"), |
| 90 | StoexPackage.Literals.FUNCTION_LITERAL__ID, |
| 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(StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL); |
| 112 | } |
| 113 | return childrenFeatures; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | @Override |
| 122 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 123 | // Check the type of the specified child object and return the proper feature to use for |
| 124 | // adding (see {@link AddCommand}) it as a child. |
| 125 | |
| 126 | return super.getChildFeature(object, child); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * This returns FunctionLiteral.gif. |
| 131 | * <!-- begin-user-doc --> |
| 132 | * <!-- end-user-doc --> |
| 133 | * @generated |
| 134 | */ |
| 135 | @Override |
| 136 | public Object getImage(Object object) { |
| 137 | return overlayImage(object, getResourceLocator().getImage("full/obj16/FunctionLiteral")); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * This returns the label text for the adapted class. |
| 142 | * <!-- begin-user-doc --> |
| 143 | * <!-- end-user-doc --> |
| 144 | * @generated |
| 145 | */ |
| 146 | @Override |
| 147 | public String getText(Object object) { |
| 148 | String label = ((FunctionLiteral)object).getId(); |
| 149 | return label == null || label.length() == 0 ? |
| 150 | getString("_UI_FunctionLiteral_type") : |
| 151 | getString("_UI_FunctionLiteral_type") + " " + label; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 156 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 157 | * <!-- begin-user-doc --> |
| 158 | * <!-- end-user-doc --> |
| 159 | * @generated |
| 160 | */ |
| 161 | @Override |
| 162 | public void notifyChanged(Notification notification) { |
| 163 | updateChildren(notification); |
| 164 | |
| 165 | switch (notification.getFeatureID(FunctionLiteral.class)) { |
| 166 | case StoexPackage.FUNCTION_LITERAL__ID: |
| 167 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 168 | return; |
| 169 | case StoexPackage.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL: |
| 170 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 171 | return; |
| 172 | } |
| 173 | super.notifyChanged(notification); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 178 | * that can be created under this object. |
| 179 | * <!-- begin-user-doc --> |
| 180 | * <!-- end-user-doc --> |
| 181 | * @generated |
| 182 | */ |
| 183 | @Override |
| 184 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 185 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 186 | |
| 187 | newChildDescriptors.add |
| 188 | (createChildParameter |
| 189 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 190 | StoexFactory.eINSTANCE.createVariable())); |
| 191 | |
| 192 | newChildDescriptors.add |
| 193 | (createChildParameter |
| 194 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 195 | StoexFactory.eINSTANCE.createTermExpression())); |
| 196 | |
| 197 | newChildDescriptors.add |
| 198 | (createChildParameter |
| 199 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 200 | StoexFactory.eINSTANCE.createProductExpression())); |
| 201 | |
| 202 | newChildDescriptors.add |
| 203 | (createChildParameter |
| 204 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 205 | StoexFactory.eINSTANCE.createProbabilityFunctionLiteral())); |
| 206 | |
| 207 | newChildDescriptors.add |
| 208 | (createChildParameter |
| 209 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 210 | StoexFactory.eINSTANCE.createParenthesis())); |
| 211 | |
| 212 | newChildDescriptors.add |
| 213 | (createChildParameter |
| 214 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 215 | StoexFactory.eINSTANCE.createIntLiteral())); |
| 216 | |
| 217 | newChildDescriptors.add |
| 218 | (createChildParameter |
| 219 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 220 | StoexFactory.eINSTANCE.createDoubleLiteral())); |
| 221 | |
| 222 | newChildDescriptors.add |
| 223 | (createChildParameter |
| 224 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 225 | StoexFactory.eINSTANCE.createCompareExpression())); |
| 226 | |
| 227 | newChildDescriptors.add |
| 228 | (createChildParameter |
| 229 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 230 | StoexFactory.eINSTANCE.createBoolLiteral())); |
| 231 | |
| 232 | newChildDescriptors.add |
| 233 | (createChildParameter |
| 234 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 235 | StoexFactory.eINSTANCE.createStringLiteral())); |
| 236 | |
| 237 | newChildDescriptors.add |
| 238 | (createChildParameter |
| 239 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 240 | StoexFactory.eINSTANCE.createPowerExpression())); |
| 241 | |
| 242 | newChildDescriptors.add |
| 243 | (createChildParameter |
| 244 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 245 | StoexFactory.eINSTANCE.createBooleanOperatorExpression())); |
| 246 | |
| 247 | newChildDescriptors.add |
| 248 | (createChildParameter |
| 249 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 250 | StoexFactory.eINSTANCE.createNotExpression())); |
| 251 | |
| 252 | newChildDescriptors.add |
| 253 | (createChildParameter |
| 254 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 255 | StoexFactory.eINSTANCE.createNegativeExpression())); |
| 256 | |
| 257 | newChildDescriptors.add |
| 258 | (createChildParameter |
| 259 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 260 | StoexFactory.eINSTANCE.createFunctionLiteral())); |
| 261 | |
| 262 | newChildDescriptors.add |
| 263 | (createChildParameter |
| 264 | (StoexPackage.Literals.FUNCTION_LITERAL__PARAMETERS_FUNCTION_LITERAL, |
| 265 | StoexFactory.eINSTANCE.createIfElseExpression())); |
| 266 | } |
| 267 | |
| 268 | } |