| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.seff.provider; |
| 7 | |
| 8 | |
| 9 | import java.util.Collection; |
| 10 | import java.util.List; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 15 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 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.ItemPropertyDescriptor; |
| 23 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 24 | |
| 25 | import de.uka.ipd.sdq.pcm.parameter.ParameterFactory; |
| 26 | import de.uka.ipd.sdq.pcm.seff.ExternalCallAction; |
| 27 | import de.uka.ipd.sdq.pcm.seff.SeffPackage; |
| 28 | import de.uka.ipd.sdq.pcm.seff.seff_reliability.Seff_reliabilityPackage; |
| 29 | |
| 30 | /** |
| 31 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.seff.ExternalCallAction} object. |
| 32 | * <!-- begin-user-doc --> |
| 33 | * <!-- end-user-doc --> |
| 34 | * @generated |
| 35 | */ |
| 36 | public class ExternalCallActionItemProvider |
| 37 | extends AbstractActionItemProvider |
| 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 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 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 ExternalCallActionItemProvider(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 | addFailureTypes_FailureHandlingEntityPropertyDescriptor(object); |
| 73 | addCalledService_ExternalServicePropertyDescriptor(object); |
| 74 | addRole_ExternalServicePropertyDescriptor(object); |
| 75 | addRetryCountPropertyDescriptor(object); |
| 76 | } |
| 77 | return itemPropertyDescriptors; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * This adds a property descriptor for the Failure Types Failure Handling Entity feature. |
| 82 | * <!-- begin-user-doc --> |
| 83 | * <!-- end-user-doc --> |
| 84 | * @generated |
| 85 | */ |
| 86 | protected void addFailureTypes_FailureHandlingEntityPropertyDescriptor(Object object) { |
| 87 | itemPropertyDescriptors.add |
| 88 | (createItemPropertyDescriptor |
| 89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 90 | getResourceLocator(), |
| 91 | getString("_UI_FailureHandlingEntity_failureTypes_FailureHandlingEntity_feature"), |
| 92 | getString("_UI_PropertyDescriptor_description", "_UI_FailureHandlingEntity_failureTypes_FailureHandlingEntity_feature", "_UI_FailureHandlingEntity_type"), |
| 93 | Seff_reliabilityPackage.Literals.FAILURE_HANDLING_ENTITY__FAILURE_TYPES_FAILURE_HANDLING_ENTITY, |
| 94 | true, |
| 95 | false, |
| 96 | true, |
| 97 | null, |
| 98 | null, |
| 99 | null)); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * This adds a property descriptor for the Called Service External Service feature. |
| 104 | * <!-- begin-user-doc --> |
| 105 | * <!-- end-user-doc --> |
| 106 | * @generated |
| 107 | */ |
| 108 | protected void addCalledService_ExternalServicePropertyDescriptor(Object object) { |
| 109 | itemPropertyDescriptors.add |
| 110 | (createItemPropertyDescriptor |
| 111 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 112 | getResourceLocator(), |
| 113 | getString("_UI_ExternalCallAction_calledService_ExternalService_feature"), |
| 114 | getString("_UI_PropertyDescriptor_description", "_UI_ExternalCallAction_calledService_ExternalService_feature", "_UI_ExternalCallAction_type"), |
| 115 | SeffPackage.Literals.EXTERNAL_CALL_ACTION__CALLED_SERVICE_EXTERNAL_SERVICE, |
| 116 | true, |
| 117 | false, |
| 118 | true, |
| 119 | null, |
| 120 | null, |
| 121 | null)); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * This adds a property descriptor for the Role External Service feature. |
| 126 | * <!-- begin-user-doc --> |
| 127 | * <!-- end-user-doc --> |
| 128 | * @generated |
| 129 | */ |
| 130 | protected void addRole_ExternalServicePropertyDescriptor(Object object) { |
| 131 | itemPropertyDescriptors.add |
| 132 | (createItemPropertyDescriptor |
| 133 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 134 | getResourceLocator(), |
| 135 | getString("_UI_ExternalCallAction_role_ExternalService_feature"), |
| 136 | getString("_UI_PropertyDescriptor_description", "_UI_ExternalCallAction_role_ExternalService_feature", "_UI_ExternalCallAction_type"), |
| 137 | SeffPackage.Literals.EXTERNAL_CALL_ACTION__ROLE_EXTERNAL_SERVICE, |
| 138 | true, |
| 139 | false, |
| 140 | true, |
| 141 | null, |
| 142 | null, |
| 143 | null)); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * This adds a property descriptor for the Retry Count feature. |
| 148 | * <!-- begin-user-doc --> |
| 149 | * <!-- end-user-doc --> |
| 150 | * @generated |
| 151 | */ |
| 152 | protected void addRetryCountPropertyDescriptor(Object object) { |
| 153 | itemPropertyDescriptors.add |
| 154 | (createItemPropertyDescriptor |
| 155 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 156 | getResourceLocator(), |
| 157 | getString("_UI_ExternalCallAction_retryCount_feature"), |
| 158 | getString("_UI_PropertyDescriptor_description", "_UI_ExternalCallAction_retryCount_feature", "_UI_ExternalCallAction_type"), |
| 159 | SeffPackage.Literals.EXTERNAL_CALL_ACTION__RETRY_COUNT, |
| 160 | true, |
| 161 | false, |
| 162 | false, |
| 163 | ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, |
| 164 | null, |
| 165 | null)); |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 170 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 171 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 172 | * <!-- begin-user-doc --> |
| 173 | * <!-- end-user-doc --> |
| 174 | * @generated |
| 175 | */ |
| 176 | @Override |
| 177 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 178 | if (childrenFeatures == null) { |
| 179 | super.getChildrenFeatures(object); |
| 180 | childrenFeatures.add(SeffPackage.Literals.CALL_ACTION__INPUT_VARIABLE_USAGES_CALL_ACTION); |
| 181 | childrenFeatures.add(SeffPackage.Literals.CALL_RETURN_ACTION__RETURN_VARIABLE_USAGE_CALL_RETURN_ACTION); |
| 182 | } |
| 183 | return childrenFeatures; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * <!-- begin-user-doc --> |
| 188 | * <!-- end-user-doc --> |
| 189 | * @generated |
| 190 | */ |
| 191 | @Override |
| 192 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 193 | // Check the type of the specified child object and return the proper feature to use for |
| 194 | // adding (see {@link AddCommand}) it as a child. |
| 195 | |
| 196 | return super.getChildFeature(object, child); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * This returns ExternalCallAction.gif. |
| 201 | * <!-- begin-user-doc --> |
| 202 | * <!-- end-user-doc --> |
| 203 | * @generated |
| 204 | */ |
| 205 | @Override |
| 206 | public Object getImage(Object object) { |
| 207 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ExternalCallAction")); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * This returns the label text for the adapted class. |
| 212 | * <!-- begin-user-doc --> |
| 213 | * <!-- end-user-doc --> |
| 214 | * @generated |
| 215 | */ |
| 216 | @Override |
| 217 | public String getText(Object object) { |
| 218 | String label = ((ExternalCallAction)object).getId(); |
| 219 | return label == null || label.length() == 0 ? |
| 220 | getString("_UI_ExternalCallAction_type") : |
| 221 | getString("_UI_ExternalCallAction_type") + " " + label; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 226 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 227 | * <!-- begin-user-doc --> |
| 228 | * <!-- end-user-doc --> |
| 229 | * @generated |
| 230 | */ |
| 231 | @Override |
| 232 | public void notifyChanged(Notification notification) { |
| 233 | updateChildren(notification); |
| 234 | |
| 235 | switch (notification.getFeatureID(ExternalCallAction.class)) { |
| 236 | case SeffPackage.EXTERNAL_CALL_ACTION__RETRY_COUNT: |
| 237 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 238 | return; |
| 239 | case SeffPackage.EXTERNAL_CALL_ACTION__INPUT_VARIABLE_USAGES_CALL_ACTION: |
| 240 | case SeffPackage.EXTERNAL_CALL_ACTION__RETURN_VARIABLE_USAGE_CALL_RETURN_ACTION: |
| 241 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 242 | return; |
| 243 | } |
| 244 | super.notifyChanged(notification); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 249 | * that can be created under this object. |
| 250 | * <!-- begin-user-doc --> |
| 251 | * <!-- end-user-doc --> |
| 252 | * @generated |
| 253 | */ |
| 254 | @Override |
| 255 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 256 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 257 | |
| 258 | newChildDescriptors.add |
| 259 | (createChildParameter |
| 260 | (SeffPackage.Literals.CALL_ACTION__INPUT_VARIABLE_USAGES_CALL_ACTION, |
| 261 | ParameterFactory.eINSTANCE.createVariableUsage())); |
| 262 | |
| 263 | newChildDescriptors.add |
| 264 | (createChildParameter |
| 265 | (SeffPackage.Literals.CALL_RETURN_ACTION__RETURN_VARIABLE_USAGE_CALL_RETURN_ACTION, |
| 266 | ParameterFactory.eINSTANCE.createVariableUsage())); |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
| 271 | * <!-- begin-user-doc --> |
| 272 | * <!-- end-user-doc --> |
| 273 | * @generated |
| 274 | */ |
| 275 | @Override |
| 276 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
| 277 | Object childFeature = feature; |
| 278 | Object childObject = child; |
| 279 | |
| 280 | boolean qualify = |
| 281 | childFeature == SeffPackage.Literals.CALL_ACTION__INPUT_VARIABLE_USAGES_CALL_ACTION || |
| 282 | childFeature == SeffPackage.Literals.CALL_RETURN_ACTION__RETURN_VARIABLE_USAGE_CALL_RETURN_ACTION; |
| 283 | |
| 284 | if (qualify) { |
| 285 | return getString |
| 286 | ("_UI_CreateChild_text2", |
| 287 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
| 288 | } |
| 289 | return super.getCreateChildText(owner, feature, child, selection); |
| 290 | } |
| 291 | |
| 292 | } |