| 1 | /** |
| 2 | * Copyright 2008, sdq.ipd.uka.de, U KA |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.simucomframework.simucomstatus.impl; |
| 7 | |
| 8 | import de.uka.ipd.sdq.simucomframework.simucomstatus.PassiveResource; |
| 9 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusPackage; |
| 10 | import de.uka.ipd.sdq.simucomframework.simucomstatus.WaitForAcquire; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.Notification; |
| 13 | import org.eclipse.emf.common.notify.NotificationChain; |
| 14 | |
| 15 | import org.eclipse.emf.ecore.EClass; |
| 16 | import org.eclipse.emf.ecore.InternalEObject; |
| 17 | |
| 18 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 19 | |
| 20 | /** |
| 21 | * <!-- begin-user-doc --> |
| 22 | * An implementation of the model object '<em><b>Wait For Acquire</b></em>'. |
| 23 | * <!-- end-user-doc --> |
| 24 | * <p> |
| 25 | * The following features are implemented: |
| 26 | * <ul> |
| 27 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.WaitForAcquireImpl#getResource <em>Resource</em>}</li> |
| 28 | * </ul> |
| 29 | * </p> |
| 30 | * |
| 31 | * @generated |
| 32 | */ |
| 33 | public class WaitForAcquireImpl extends ActionImpl implements WaitForAcquire { |
| 34 | /** |
| 35 | * The cached value of the '{@link #getResource() <em>Resource</em>}' reference. |
| 36 | * <!-- begin-user-doc --> |
| 37 | * <!-- end-user-doc --> |
| 38 | * @see #getResource() |
| 39 | * @generated |
| 40 | * @ordered |
| 41 | */ |
| 42 | protected PassiveResource resource; |
| 43 | |
| 44 | /** |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @generated |
| 48 | */ |
| 49 | protected WaitForAcquireImpl() { |
| 50 | super(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * <!-- begin-user-doc --> |
| 55 | * <!-- end-user-doc --> |
| 56 | * @generated |
| 57 | */ |
| 58 | @Override |
| 59 | protected EClass eStaticClass() { |
| 60 | return SimucomstatusPackage.Literals.WAIT_FOR_ACQUIRE; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * <!-- begin-user-doc --> |
| 65 | * <!-- end-user-doc --> |
| 66 | * @generated |
| 67 | */ |
| 68 | public PassiveResource getResource() { |
| 69 | if (resource != null && resource.eIsProxy()) { |
| 70 | InternalEObject oldResource = (InternalEObject)resource; |
| 71 | resource = (PassiveResource)eResolveProxy(oldResource); |
| 72 | if (resource != oldResource) { |
| 73 | if (eNotificationRequired()) |
| 74 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE, oldResource, resource)); |
| 75 | } |
| 76 | } |
| 77 | return resource; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * <!-- begin-user-doc --> |
| 82 | * <!-- end-user-doc --> |
| 83 | * @generated |
| 84 | */ |
| 85 | public PassiveResource basicGetResource() { |
| 86 | return resource; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * <!-- begin-user-doc --> |
| 91 | * <!-- end-user-doc --> |
| 92 | * @generated |
| 93 | */ |
| 94 | public NotificationChain basicSetResource(PassiveResource newResource, NotificationChain msgs) { |
| 95 | PassiveResource oldResource = resource; |
| 96 | resource = newResource; |
| 97 | if (eNotificationRequired()) { |
| 98 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE, oldResource, newResource); |
| 99 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 100 | } |
| 101 | return msgs; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * <!-- begin-user-doc --> |
| 106 | * <!-- end-user-doc --> |
| 107 | * @generated |
| 108 | */ |
| 109 | public void setResource(PassiveResource newResource) { |
| 110 | if (newResource != resource) { |
| 111 | NotificationChain msgs = null; |
| 112 | if (resource != null) |
| 113 | msgs = ((InternalEObject)resource).eInverseRemove(this, SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES, PassiveResource.class, msgs); |
| 114 | if (newResource != null) |
| 115 | msgs = ((InternalEObject)newResource).eInverseAdd(this, SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES, PassiveResource.class, msgs); |
| 116 | msgs = basicSetResource(newResource, msgs); |
| 117 | if (msgs != null) msgs.dispatch(); |
| 118 | } |
| 119 | else if (eNotificationRequired()) |
| 120 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE, newResource, newResource)); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * <!-- begin-user-doc --> |
| 125 | * <!-- end-user-doc --> |
| 126 | * @generated |
| 127 | */ |
| 128 | @Override |
| 129 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 130 | switch (featureID) { |
| 131 | case SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE: |
| 132 | if (resource != null) |
| 133 | msgs = ((InternalEObject)resource).eInverseRemove(this, SimucomstatusPackage.PASSIVE_RESOURCE__WAITING_PROCESSES, PassiveResource.class, msgs); |
| 134 | return basicSetResource((PassiveResource)otherEnd, msgs); |
| 135 | } |
| 136 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * <!-- begin-user-doc --> |
| 141 | * <!-- end-user-doc --> |
| 142 | * @generated |
| 143 | */ |
| 144 | @Override |
| 145 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 146 | switch (featureID) { |
| 147 | case SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE: |
| 148 | return basicSetResource(null, msgs); |
| 149 | } |
| 150 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * <!-- begin-user-doc --> |
| 155 | * <!-- end-user-doc --> |
| 156 | * @generated |
| 157 | */ |
| 158 | @Override |
| 159 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 160 | switch (featureID) { |
| 161 | case SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE: |
| 162 | if (resolve) return getResource(); |
| 163 | return basicGetResource(); |
| 164 | } |
| 165 | return super.eGet(featureID, resolve, coreType); |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * <!-- begin-user-doc --> |
| 170 | * <!-- end-user-doc --> |
| 171 | * @generated |
| 172 | */ |
| 173 | @Override |
| 174 | public void eSet(int featureID, Object newValue) { |
| 175 | switch (featureID) { |
| 176 | case SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE: |
| 177 | setResource((PassiveResource)newValue); |
| 178 | return; |
| 179 | } |
| 180 | super.eSet(featureID, newValue); |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * <!-- begin-user-doc --> |
| 185 | * <!-- end-user-doc --> |
| 186 | * @generated |
| 187 | */ |
| 188 | @Override |
| 189 | public void eUnset(int featureID) { |
| 190 | switch (featureID) { |
| 191 | case SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE: |
| 192 | setResource((PassiveResource)null); |
| 193 | return; |
| 194 | } |
| 195 | super.eUnset(featureID); |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * <!-- begin-user-doc --> |
| 200 | * <!-- end-user-doc --> |
| 201 | * @generated |
| 202 | */ |
| 203 | @Override |
| 204 | public boolean eIsSet(int featureID) { |
| 205 | switch (featureID) { |
| 206 | case SimucomstatusPackage.WAIT_FOR_ACQUIRE__RESOURCE: |
| 207 | return resource != null; |
| 208 | } |
| 209 | return super.eIsSet(featureID); |
| 210 | } |
| 211 | |
| 212 | } //WaitForAcquireImpl |