5
* $Id: ComponentResourceImpl.java,v 1.5 2011/08/10 21:40:14 rsanchez Exp $
7
package org.eclipse.wst.common.componentcore.internal.impl;
9
import java.util.Collection;
11
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.runtime.IPath;
13
import org.eclipse.emf.common.notify.Notification;
14
import org.eclipse.emf.common.notify.NotificationChain;
15
import org.eclipse.emf.common.util.EList;
16
import org.eclipse.emf.ecore.EClass;
17
import org.eclipse.emf.ecore.EStructuralFeature;
18
import org.eclipse.emf.ecore.InternalEObject;
19
import org.eclipse.emf.ecore.impl.ENotificationImpl;
20
import org.eclipse.emf.ecore.impl.EObjectImpl;
21
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
22
import org.eclipse.emf.ecore.util.EcoreUtil;
23
import org.eclipse.wst.common.componentcore.internal.ComponentResource;
24
import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage;
25
import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
26
import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil.ESynchronizedAdapterList;
29
* <!-- begin-user-doc -->
30
* An implementation of the model object '<em><b>Workbench Module Resource</b></em>'.
31
* <!-- end-user-doc -->
33
* The following features are implemented:
35
* <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getSourcePath <em>Source Path</em>}</li>
36
* <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getRuntimePath <em>Runtime Path</em>}</li>
37
* <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getExclusions <em>Exclusions</em>}</li>
38
* <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getComponent <em>Component</em>}</li>
39
* <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getResourceType <em>Resource Type</em>}</li>
40
* <li>{@link org.eclipse.wst.common.componentcore.internal.impl.ComponentResourceImpl#getTag <em>Tag</em>}</li>
46
public class ComponentResourceImpl extends EObjectImpl implements ComponentResource {
48
* The default value of the '{@link #getSourcePath() <em>Source Path</em>}' attribute.
49
* <!-- begin-user-doc -->
50
* <!-- end-user-doc -->
51
* @see #getSourcePath()
55
protected static final IPath SOURCE_PATH_EDEFAULT = null;
58
* The cached value of the '{@link #getSourcePath() <em>Source Path</em>}' attribute.
59
* <!-- begin-user-doc -->
60
* <!-- end-user-doc -->
61
* @see #getSourcePath()
65
protected IPath sourcePath = SOURCE_PATH_EDEFAULT;
68
* The default value of the '{@link #getRuntimePath() <em>Runtime Path</em>}' attribute.
69
* <!-- begin-user-doc -->
70
* <!-- end-user-doc -->
71
* @see #getRuntimePath()
75
protected static final IPath RUNTIME_PATH_EDEFAULT = null;
78
* The cached value of the '{@link #getRuntimePath() <em>Runtime Path</em>}' attribute.
79
* <!-- begin-user-doc -->
80
* <!-- end-user-doc -->
81
* @see #getRuntimePath()
85
protected IPath runtimePath = RUNTIME_PATH_EDEFAULT;
88
* The cached value of the '{@link #getExclusions() <em>Exclusions</em>}' attribute list.
89
* <!-- begin-user-doc -->
90
* <!-- end-user-doc -->
91
* @see #getExclusions()
95
protected EList exclusions;
98
* The default value of the '{@link #getResourceType() <em>Resource Type</em>}' attribute.
99
* <!-- begin-user-doc -->
100
* <!-- end-user-doc -->
101
* @see #getResourceType()
105
protected static final String RESOURCE_TYPE_EDEFAULT = "";
108
* The cached value of the '{@link #getResourceType() <em>Resource Type</em>}' attribute.
109
* <!-- begin-user-doc -->
110
* <!-- end-user-doc -->
111
* @see #getResourceType()
115
protected String resourceType = RESOURCE_TYPE_EDEFAULT;
118
* The default value of the '{@link #getTag() <em>Tag</em>}' attribute.
119
* <!-- begin-user-doc -->
120
* <!-- end-user-doc -->
125
protected static final String TAG_EDEFAULT = null;
128
* The cached value of the '{@link #getTag() <em>Tag</em>}' attribute.
129
* <!-- begin-user-doc -->
130
* <!-- end-user-doc -->
135
protected String tag = TAG_EDEFAULT;
137
protected IProject owningProject;
138
protected static final int VIRTUAL = 0;
139
protected static final int PERSISTED = 1;
141
private int type = PERSISTED;
144
* <!-- begin-user-doc -->
145
* <!-- end-user-doc -->
148
protected ComponentResourceImpl() {
153
* <!-- begin-user-doc -->
154
* <!-- end-user-doc -->
157
protected EClass eStaticClass() {
158
return ComponentcorePackage.eINSTANCE.getComponentResource();
162
* <!-- begin-user-doc -->
163
* <!-- end-user-doc -->
166
public IPath getSourcePath() {
171
* <!-- begin-user-doc -->
172
* <!-- end-user-doc -->
175
public void setSourcePath(IPath newSourcePath) {
176
IPath oldSourcePath = sourcePath;
177
sourcePath = newSourcePath;
178
if (eNotificationRequired())
179
eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH, oldSourcePath, sourcePath));
183
* <!-- begin-user-doc -->
184
* <!-- end-user-doc -->
187
public IPath getRuntimePath() {
192
* <!-- begin-user-doc -->
193
* <!-- end-user-doc -->
196
public void setRuntimePath(IPath newRuntimePath) {
197
IPath oldRuntimePath = runtimePath;
198
runtimePath = newRuntimePath;
199
if (eNotificationRequired())
200
eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH, oldRuntimePath, runtimePath));
204
* <!-- begin-user-doc -->
205
* <!-- end-user-doc -->
208
public EList getExclusions() {
209
if (exclusions == null) {
210
exclusions = new EDataTypeUniqueEList(String.class, this, ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS);
216
* <!-- begin-user-doc -->
217
* <!-- end-user-doc -->
220
public WorkbenchComponent getComponent() {
221
if (eContainerFeatureID != ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT) return null;
222
return (WorkbenchComponent)eContainer;
226
* <!-- begin-user-doc -->
227
* <!-- end-user-doc -->
230
public void setComponent(WorkbenchComponent newComponent) {
231
if (newComponent != eContainer || (eContainerFeatureID != ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT && newComponent != null)) {
232
if (EcoreUtil.isAncestor(this, newComponent))
233
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
234
NotificationChain msgs = null;
235
if (eContainer != null)
236
msgs = eBasicRemoveFromContainer(msgs);
237
if (newComponent != null)
238
msgs = ((InternalEObject)newComponent).eInverseAdd(this, ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES, WorkbenchComponent.class, msgs);
239
msgs = eBasicSetContainer((InternalEObject)newComponent, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, msgs);
240
if (msgs != null) msgs.dispatch();
242
else if (eNotificationRequired())
243
eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, newComponent, newComponent));
247
* <!-- begin-user-doc -->
248
* <!-- end-user-doc -->
251
public String getResourceType() {
256
* <!-- begin-user-doc -->
257
* <!-- end-user-doc -->
260
public void setResourceType(String newResourceType) {
261
String oldResourceType = resourceType;
262
resourceType = newResourceType;
263
if (eNotificationRequired())
264
eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE, oldResourceType, resourceType));
268
* <!-- begin-user-doc -->
269
* <!-- end-user-doc -->
272
public String getTag() {
277
* <!-- begin-user-doc -->
278
* <!-- end-user-doc -->
281
public void setTag(String newTag) {
284
if (eNotificationRequired())
285
eNotify(new ENotificationImpl(this, Notification.SET, ComponentcorePackage.COMPONENT_RESOURCE__TAG, oldTag, tag));
289
* <!-- begin-user-doc -->
290
* <!-- end-user-doc -->
293
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
294
if (featureID >= 0) {
295
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
296
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
297
if (eContainer != null)
298
msgs = eBasicRemoveFromContainer(msgs);
299
return eBasicSetContainer(otherEnd, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, msgs);
301
return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
304
if (eContainer != null)
305
msgs = eBasicRemoveFromContainer(msgs);
306
return eBasicSetContainer(otherEnd, featureID, msgs);
310
* <!-- begin-user-doc -->
311
* <!-- end-user-doc -->
314
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
315
if (featureID >= 0) {
316
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
317
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
318
return eBasicSetContainer(null, ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT, msgs);
320
return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
323
return eBasicSetContainer(null, featureID, msgs);
327
* <!-- begin-user-doc -->
328
* <!-- end-user-doc -->
331
public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
332
if (eContainerFeatureID >= 0) {
333
switch (eContainerFeatureID) {
334
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
335
return eContainer.eInverseRemove(this, ComponentcorePackage.WORKBENCH_COMPONENT__RESOURCES, WorkbenchComponent.class, msgs);
337
return eDynamicBasicRemoveFromContainer(msgs);
340
return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
344
* <!-- begin-user-doc -->
345
* <!-- end-user-doc -->
348
public Object eGet(EStructuralFeature eFeature, boolean resolve) {
349
switch (eDerivedStructuralFeatureID(eFeature)) {
350
case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH:
351
return getSourcePath();
352
case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH:
353
return getRuntimePath();
354
case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS:
355
return getExclusions();
356
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
357
return getComponent();
358
case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE:
359
return getResourceType();
360
case ComponentcorePackage.COMPONENT_RESOURCE__TAG:
363
return eDynamicGet(eFeature, resolve);
367
* <!-- begin-user-doc -->
368
* <!-- end-user-doc -->
371
public void eSet(EStructuralFeature eFeature, Object newValue) {
372
switch (eDerivedStructuralFeatureID(eFeature)) {
373
case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH:
374
setSourcePath((IPath)newValue);
376
case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH:
377
setRuntimePath((IPath)newValue);
379
case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS:
380
getExclusions().clear();
381
getExclusions().addAll((Collection)newValue);
383
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
384
setComponent((WorkbenchComponent)newValue);
386
case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE:
387
setResourceType((String)newValue);
389
case ComponentcorePackage.COMPONENT_RESOURCE__TAG:
390
setTag((String)newValue);
393
eDynamicSet(eFeature, newValue);
397
* <!-- begin-user-doc -->
398
* <!-- end-user-doc -->
401
public void eUnset(EStructuralFeature eFeature) {
402
switch (eDerivedStructuralFeatureID(eFeature)) {
403
case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH:
404
setSourcePath(SOURCE_PATH_EDEFAULT);
406
case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH:
407
setRuntimePath(RUNTIME_PATH_EDEFAULT);
409
case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS:
410
getExclusions().clear();
412
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
413
setComponent((WorkbenchComponent)null);
415
case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE:
416
setResourceType(RESOURCE_TYPE_EDEFAULT);
418
case ComponentcorePackage.COMPONENT_RESOURCE__TAG:
419
setTag(TAG_EDEFAULT);
422
eDynamicUnset(eFeature);
426
* <!-- begin-user-doc -->
427
* <!-- end-user-doc -->
430
public boolean eIsSet(EStructuralFeature eFeature) {
431
switch (eDerivedStructuralFeatureID(eFeature)) {
432
case ComponentcorePackage.COMPONENT_RESOURCE__SOURCE_PATH:
433
return SOURCE_PATH_EDEFAULT == null ? sourcePath != null : !SOURCE_PATH_EDEFAULT.equals(sourcePath);
434
case ComponentcorePackage.COMPONENT_RESOURCE__RUNTIME_PATH:
435
return RUNTIME_PATH_EDEFAULT == null ? runtimePath != null : !RUNTIME_PATH_EDEFAULT.equals(runtimePath);
436
case ComponentcorePackage.COMPONENT_RESOURCE__EXCLUSIONS:
437
return exclusions != null && !exclusions.isEmpty();
438
case ComponentcorePackage.COMPONENT_RESOURCE__COMPONENT:
439
return getComponent() != null;
440
case ComponentcorePackage.COMPONENT_RESOURCE__RESOURCE_TYPE:
441
return RESOURCE_TYPE_EDEFAULT == null ? resourceType != null : !RESOURCE_TYPE_EDEFAULT.equals(resourceType);
442
case ComponentcorePackage.COMPONENT_RESOURCE__TAG:
443
return TAG_EDEFAULT == null ? tag != null : !TAG_EDEFAULT.equals(tag);
445
return eDynamicIsSet(eFeature);
449
* <!-- begin-user-doc -->
450
* <!-- end-user-doc -->
453
public String toString() {
454
if (eIsProxy()) return super.toString();
456
StringBuffer result = new StringBuffer(super.toString());
457
result.append(" (sourcePath: ");
458
result.append(sourcePath);
459
result.append(", runtimePath: ");
460
result.append(runtimePath);
461
result.append(", exclusions: ");
462
result.append(exclusions);
463
result.append(", resourceType: ");
464
result.append(resourceType);
465
result.append(", tag: ");
468
return result.toString();
471
public int getType() {
476
public void setType(int type) {
480
public IProject getOwningProject() {
481
return owningProject;
484
public void setOwningProject(IProject aProject) {
485
owningProject = aProject;
489
public EList eAdapters()
491
if (eAdapters == null)
493
eAdapters = new ESynchronizedAdapterList(this);
499
} //ComponentResourceImpl