Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEObjectItemProvider.java8
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEditPlugin.java2
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProvider.java12
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProviderAdapterFactory.java24
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecore3
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecorediag4
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.genmodel3
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/Resource.java11
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/ResourcePackage.java6
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceFactoryImpl.java9
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceImpl.java60
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourcePackageImpl.java31
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceAdapterFactory.java20
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceSwitch.java27
-rw-r--r--plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceUtil.java11
15 files changed, 150 insertions, 81 deletions
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEObjectItemProvider.java b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEObjectItemProvider.java
index 03d8e89fc51..817dca7e2de 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEObjectItemProvider.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEObjectItemProvider.java
@@ -28,7 +28,8 @@ import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
/**
- * This is the item provider adapter for a {@link org.eclipse.papyrus.resource.ResourceEObject} object. <!-- begin-user-doc --> <!-- end-user-doc -->
+ * This is the item provider adapter for a {@link org.eclipse.papyrus.resource.ResourceEObject}
+ * object. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@@ -53,7 +54,7 @@ public class ResourceEObjectItemProvider extends ItemProviderAdapter implements
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
- if(itemPropertyDescriptors == null) {
+ if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
}
@@ -83,7 +84,8 @@ public class ResourceEObjectItemProvider extends ItemProviderAdapter implements
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
- * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged} . <!-- begin-user-doc --> <!-- end-user-doc -->
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}
+ * . <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEditPlugin.java b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEditPlugin.java
index c55f052be48..b4aa6cccaef 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEditPlugin.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceEditPlugin.java
@@ -44,7 +44,7 @@ public final class ResourceEditPlugin extends EMFPlugin {
* @generated
*/
public ResourceEditPlugin() {
- super(new ResourceLocator[]{});
+ super(new ResourceLocator[] {});
}
/**
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProvider.java b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProvider.java
index 1538a28c520..2aa5ba09197 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProvider.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProvider.java
@@ -59,7 +59,7 @@ public class ResourceItemProvider extends ItemProviderAdapter implements IEditin
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
- if(itemPropertyDescriptors == null) {
+ if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
}
@@ -68,7 +68,8 @@ public class ResourceItemProvider extends ItemProviderAdapter implements IEditin
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate
- * feature for an {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * feature for an {@link org.eclipse.emf.edit.command.AddCommand},
+ * {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
@@ -76,7 +77,7 @@ public class ResourceItemProvider extends ItemProviderAdapter implements IEditin
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
- if(childrenFeatures == null) {
+ if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ResourcePackage.Literals.RESOURCE__EOBJECTS);
}
@@ -119,7 +120,8 @@ public class ResourceItemProvider extends ItemProviderAdapter implements IEditin
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
- * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged} . <!-- begin-user-doc --> <!-- end-user-doc -->
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}
+ * . <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@@ -127,7 +129,7 @@ public class ResourceItemProvider extends ItemProviderAdapter implements IEditin
public void notifyChanged(Notification notification) {
updateChildren(notification);
- switch(notification.getFeatureID(Resource.class)) {
+ switch (notification.getFeatureID(Resource.class)) {
case ResourcePackage.RESOURCE__EOBJECTS:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProviderAdapterFactory.java b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProviderAdapterFactory.java
index 914240963be..6b27e36b9d7 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProviderAdapterFactory.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource.edit/src/org/eclipse/papyrus/resource/provider/ResourceItemProviderAdapterFactory.java
@@ -34,8 +34,8 @@ import org.eclipse.papyrus.resource.util.ResourceAdapterFactory;
/**
* This is the factory that is used to provide the interfaces needed to support Viewers. The
- * adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. The adapters also
- * support Eclipse property sheets.
+ * adapters generated by this factory convert EMF adapter notifications into calls to
+ * {@link #fireNotifyChanged fireNotifyChanged}. The adapters also support Eclipse property sheets.
* Note that most of the adapters are shared among multiple instances. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
@@ -82,7 +82,8 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
}
/**
- * This keeps track of the one adapter used for all {@link org.eclipse.papyrus.resource.Resource} instances. <!-- begin-user-doc --> <!--
+ * This keeps track of the one adapter used for all
+ * {@link org.eclipse.papyrus.resource.Resource} instances. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated
@@ -97,7 +98,7 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
*/
@Override
public Adapter createResourceAdapter() {
- if(resourceItemProvider == null) {
+ if (resourceItemProvider == null) {
resourceItemProvider = new ResourceItemProvider(this);
}
@@ -105,7 +106,8 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
}
/**
- * This keeps track of the one adapter used for all {@link org.eclipse.papyrus.resource.ResourceEObject} instances. <!-- begin-user-doc --> <!--
+ * This keeps track of the one adapter used for all
+ * {@link org.eclipse.papyrus.resource.ResourceEObject} instances. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated
@@ -120,7 +122,7 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
*/
@Override
public Adapter createResourceEObjectAdapter() {
- if(resourceEObjectItemProvider == null) {
+ if (resourceEObjectItemProvider == null) {
resourceEObjectItemProvider = new ResourceEObjectItemProvider(this);
}
@@ -175,9 +177,9 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
*/
@Override
public Object adapt(Object object, Object type) {
- if(isFactoryForType(type)) {
+ if (isFactoryForType(type)) {
Object adapter = super.adapt(object, type);
- if(!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
+ if (!(type instanceof Class<?>) || (((Class<?>) type).isInstance(adapter))) {
return adapter;
}
}
@@ -212,7 +214,7 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
public void fireNotifyChanged(Notification notification) {
changeNotifier.fireNotifyChanged(notification);
- if(parentAdapterFactory != null) {
+ if (parentAdapterFactory != null) {
parentAdapterFactory.fireNotifyChanged(notification);
}
}
@@ -224,9 +226,9 @@ public class ResourceItemProviderAdapterFactory extends ResourceAdapterFactory i
* @generated
*/
public void dispose() {
- if(resourceItemProvider != null)
+ if (resourceItemProvider != null)
resourceItemProvider.dispose();
- if(resourceEObjectItemProvider != null)
+ if (resourceEObjectItemProvider != null)
resourceEObjectItemProvider.dispose();
}
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecore b/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecore
index 570f6882597..6b01cf9c136 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecore
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecore
@@ -4,6 +4,9 @@
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="resource"
nsURI="http://www.eclipse.org/papyurs/0.7.0/Resource" nsPrefix="resource">
<eClassifiers xsi:type="ecore:EClass" name="Resource">
+ <eOperations name="setResource">
+ <eParameters name="r" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EResource"/>
+ </eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="eobjects" upperBound="-1"
eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject" volatile="true"
transient="true" containment="true"/>
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecorediag b/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecorediag
index 568ade511b4..3c3f7f3c752 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecorediag
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.ecorediag
@@ -8,6 +8,10 @@
<styles xmi:type="notation:FilteringStyle" xmi:id="_l5eDh65mEd6h2ecTXi7wcw"/>
</children>
<children xmi:type="notation:Node" xmi:id="_l5eDiK5mEd6h2ecTXi7wcw" type="5002">
+ <children xmi:type="notation:Node" xmi:id="_n7r08eWzEd6SJ_7l1eHvag" type="2002">
+ <element xmi:type="ecore:EOperation" href="resource.ecore#//Resource/setResource"/>
+ <layoutConstraint xmi:type="notation:Location" xmi:id="_n7r08uWzEd6SJ_7l1eHvag"/>
+ </children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_l5eDia5mEd6h2ecTXi7wcw"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_l5eDiq5mEd6h2ecTXi7wcw"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_l5eDi65mEd6h2ecTXi7wcw"/>
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.genmodel b/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.genmodel
index bd33ffd7dfd..5c55c823459 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.genmodel
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/model/resource.genmodel
@@ -10,6 +10,9 @@
ecorePackage="resource.ecore#/">
<genClasses ecoreClass="resource.ecore#//Resource">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference resource.ecore#//Resource/eobjects"/>
+ <genOperations ecoreOperation="resource.ecore#//Resource/setResource">
+ <genParameters ecoreParameter="resource.ecore#//Resource/setResource/r"/>
+ </genOperations>
</genClasses>
<genClasses ecoreClass="resource.ecore#//ResourceEObject"/>
</genPackages>
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/Resource.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/Resource.java
index feab5a78b1a..57f9450c703 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/Resource.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/Resource.java
@@ -37,7 +37,8 @@ public interface Resource extends EObject {
* Returns the value of the '<em><b>Eobjects</b></em>' containment reference list. The list
* contents are of type {@link org.eclipse.emf.ecore.EObject}. <!-- begin-user-doc -->
* <p>
- * If the meaning of the '<em>Eobjects</em>' containment reference list isn't clear, there really should be more of a description here...
+ * If the meaning of the '<em>Eobjects</em>' containment reference list isn't clear, there
+ * really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
@@ -48,4 +49,12 @@ public interface Resource extends EObject {
*/
EList<EObject> getEobjects();
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @model
+ * @generated
+ */
+ void setResource(org.eclipse.emf.ecore.resource.Resource r);
+
} // Resource
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/ResourcePackage.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/ResourcePackage.java
index b734f6546ad..10f9435be66 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/ResourcePackage.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/ResourcePackage.java
@@ -121,7 +121,8 @@ public interface ResourcePackage extends EPackage {
EClass getResource();
/**
- * Returns the meta object for the containment reference list ' {@link org.eclipse.papyrus.resource.Resource#getEobjects <em>Eobjects</em>}'. <!--
+ * Returns the meta object for the containment reference list '
+ * {@link org.eclipse.papyrus.resource.Resource#getEobjects <em>Eobjects</em>}'. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @return the meta object for the containment reference list '<em>Eobjects</em>'.
@@ -183,7 +184,8 @@ public interface ResourcePackage extends EPackage {
EReference RESOURCE__EOBJECTS = eINSTANCE.getResource_Eobjects();
/**
- * The meta object literal for the ' {@link org.eclipse.papyrus.resource.impl.ResourceEObjectImpl <em>EObject</em>}' class.
+ * The meta object literal for the '
+ * {@link org.eclipse.papyrus.resource.impl.ResourceEObjectImpl <em>EObject</em>}' class.
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see org.eclipse.papyrus.resource.impl.ResourceEObjectImpl
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceFactoryImpl.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceFactoryImpl.java
index 960ea2f8cd0..3323674844c 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceFactoryImpl.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceFactoryImpl.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.papyrus.resource.*;
import org.eclipse.papyrus.resource.Resource;
import org.eclipse.papyrus.resource.ResourceEObject;
import org.eclipse.papyrus.resource.ResourceFactory;
@@ -37,9 +38,9 @@ public class ResourceFactoryImpl extends EFactoryImpl implements ResourceFactory
*/
public static ResourceFactory init() {
try {
- ResourceFactory theResourceFactory = (ResourceFactory)EPackage.Registry.INSTANCE
+ ResourceFactory theResourceFactory = (ResourceFactory) EPackage.Registry.INSTANCE
.getEFactory("http://www.eclipse.org/papyurs/0.7.0/Resource");
- if(theResourceFactory != null) {
+ if (theResourceFactory != null) {
return theResourceFactory;
}
} catch (Exception exception) {
@@ -64,7 +65,7 @@ public class ResourceFactoryImpl extends EFactoryImpl implements ResourceFactory
*/
@Override
public EObject create(EClass eClass) {
- switch(eClass.getClassifierID()) {
+ switch (eClass.getClassifierID()) {
case ResourcePackage.RESOURCE:
return createResource();
case ResourcePackage.RESOURCE_EOBJECT:
@@ -100,7 +101,7 @@ public class ResourceFactoryImpl extends EFactoryImpl implements ResourceFactory
* @generated
*/
public ResourcePackage getResourcePackage() {
- return (ResourcePackage)getEPackage();
+ return (ResourcePackage) getEPackage();
}
/**
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceImpl.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceImpl.java
index 6c76aa3c83e..23734bb561a 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceImpl.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourceImpl.java
@@ -14,6 +14,8 @@
package org.eclipse.papyrus.resource.impl;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicEList;
@@ -41,6 +43,14 @@ import org.eclipse.papyrus.resource.ResourcePackage;
public class ResourceImpl extends EObjectImpl implements Resource {
/**
+ * Map to register the managed EMF resources with the papyrus resource TODO don't forget to
+ * unload your resource after using it.
+ */
+ private static Map<org.eclipse.emf.ecore.resource.Resource, Resource> resources = new HashMap<org.eclipse.emf.ecore.resource.Resource, Resource>();
+
+ private org.eclipse.emf.ecore.resource.Resource eobjectResource = null;
+
+ /**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
@@ -65,12 +75,42 @@ public class ResourceImpl extends EObjectImpl implements Resource {
* @generated NOT
*/
public EList<EObject> getEobjects() {
- if (eResource() != null)
- {
- return eResource().getContents();
+ if (eobjectResource != null) {
+ return eobjectResource.getContents();
}
return new BasicEList<EObject>();
}
+
+ /**
+ * Gets the Papyrus resource from the EMF resource
+ *
+ * @param r the EMF resource
+ *
+ * @return the Papyrus resource
+ */
+ public static Resource getResource(org.eclipse.emf.ecore.resource.Resource r) {
+ return resources.get(r);
+ }
+
+ /**
+ * <!-- begin-user-doc --> Register the EMF resource <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ public void setResource(org.eclipse.emf.ecore.resource.Resource r) {
+ eobjectResource = r;
+ resources.put(r, this);
+ }
+
+ /**
+ * Unregister the EMF resource
+ *
+ * @param r
+ * the resource
+ */
+ public static void dispose(org.eclipse.emf.ecore.resource.Resource r) {
+ resources.remove(r);
+ }
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
@@ -79,9 +119,9 @@ public class ResourceImpl extends EObjectImpl implements Resource {
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
- switch(featureID) {
+ switch (featureID) {
case ResourcePackage.RESOURCE__EOBJECTS:
- return ((InternalEList<?>)getEobjects()).basicRemove(otherEnd, msgs);
+ return ((InternalEList<?>) getEobjects()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
@@ -93,7 +133,7 @@ public class ResourceImpl extends EObjectImpl implements Resource {
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
- switch(featureID) {
+ switch (featureID) {
case ResourcePackage.RESOURCE__EOBJECTS:
return getEobjects();
}
@@ -108,10 +148,10 @@ public class ResourceImpl extends EObjectImpl implements Resource {
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
- switch(featureID) {
+ switch (featureID) {
case ResourcePackage.RESOURCE__EOBJECTS:
getEobjects().clear();
- getEobjects().addAll((Collection<? extends EObject>)newValue);
+ getEobjects().addAll((Collection<? extends EObject>) newValue);
return;
}
super.eSet(featureID, newValue);
@@ -124,7 +164,7 @@ public class ResourceImpl extends EObjectImpl implements Resource {
*/
@Override
public void eUnset(int featureID) {
- switch(featureID) {
+ switch (featureID) {
case ResourcePackage.RESOURCE__EOBJECTS:
getEobjects().clear();
return;
@@ -139,7 +179,7 @@ public class ResourceImpl extends EObjectImpl implements Resource {
*/
@Override
public boolean eIsSet(int featureID) {
- switch(featureID) {
+ switch (featureID) {
case ResourcePackage.RESOURCE__EOBJECTS:
return !getEobjects().isEmpty();
}
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourcePackageImpl.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourcePackageImpl.java
index 461502d8e79..2cb0af56924 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourcePackageImpl.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/impl/ResourcePackageImpl.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.resource.impl;
import static org.eclipse.papyrus.resource.ResourcePackage.RESOURCE;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.impl.EPackageImpl;
@@ -46,13 +47,13 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
private EClass resourceEObjectEClass = null;
/**
- * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the
- * package package URI
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package package URI
* value.
* <p>
* Note: the correct way to create the package is via the static factory method {@link #init
- * init()}, which also performs initialization of the package, or returns the registered package, if one already exists. <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * init()}, which also performs initialization of the package, or returns the registered
+ * package, if one already exists. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see org.eclipse.emf.ecore.EPackage.Registry
* @see org.eclipse.papyrus.resource.ResourcePackage#eNS_URI
@@ -75,8 +76,9 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
* upon which it depends.
*
* <p>
- * This method is used to initialize {@link ResourcePackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly.
- * Instead, they should simply access that field to obtain the package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ * This method is used to initialize {@link ResourcePackage#eINSTANCE} when that field is
+ * accessed. Clients should not invoke it directly. Instead, they should simply access that
+ * field to obtain the package. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #eNS_URI
* @see #createPackageContents()
@@ -84,11 +86,11 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
* @generated
*/
public static ResourcePackage init() {
- if(isInited)
- return (ResourcePackage)EPackage.Registry.INSTANCE.getEPackage(ResourcePackage.eNS_URI);
+ if (isInited)
+ return (ResourcePackage) EPackage.Registry.INSTANCE.getEPackage(ResourcePackage.eNS_URI);
// Obtain or create and register package
- ResourcePackageImpl theResourcePackage = (ResourcePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ResourcePackageImpl ? EPackage.Registry.INSTANCE
+ ResourcePackageImpl theResourcePackage = (ResourcePackageImpl) (EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ResourcePackageImpl ? EPackage.Registry.INSTANCE
.get(eNS_URI)
: new ResourcePackageImpl());
@@ -123,7 +125,7 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
* @generated
*/
public EReference getResource_Eobjects() {
- return (EReference)resourceEClass.getEStructuralFeatures().get(0);
+ return (EReference) resourceEClass.getEStructuralFeatures().get(0);
}
/**
@@ -141,7 +143,7 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
* @generated
*/
public ResourceFactory getResourceFactory() {
- return (ResourceFactory)getEFactoryInstance();
+ return (ResourceFactory) getEFactoryInstance();
}
/**
@@ -158,7 +160,7 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
* @generated
*/
public void createPackageContents() {
- if(isCreated)
+ if (isCreated)
return;
isCreated = true;
@@ -183,7 +185,7 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
* @generated
*/
public void initializePackageContents() {
- if(isInitialized)
+ if (isInitialized)
return;
isInitialized = true;
@@ -205,6 +207,9 @@ public class ResourcePackageImpl extends EPackageImpl implements ResourcePackage
Resource.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES,
!IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ EOperation op = addEOperation(resourceEClass, null, "setResource", 0, 1, IS_UNIQUE, IS_ORDERED);
+ addEParameter(op, ecorePackage.getEResource(), "r", 0, 1, IS_UNIQUE, IS_ORDERED);
+
initEClass(resourceEObjectEClass, ResourceEObject.class, "ResourceEObject", !IS_ABSTRACT, !IS_INTERFACE,
IS_GENERATED_INSTANCE_CLASS);
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceAdapterFactory.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceAdapterFactory.java
index 78871822859..a3bfe5ffc44 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceAdapterFactory.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceAdapterFactory.java
@@ -17,13 +17,14 @@ import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.resource.*;
import org.eclipse.papyrus.resource.Resource;
import org.eclipse.papyrus.resource.ResourceEObject;
import org.eclipse.papyrus.resource.ResourcePackage;
/**
- * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides an adapter <code>createXXX</code> method for each class of the model.
- * <!-- end-user-doc -->
+ * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It provides an adapter
+ * <code>createXXX</code> method for each class of the model. <!-- end-user-doc -->
*
* @see org.eclipse.papyrus.resource.ResourcePackage
* @generated
@@ -43,7 +44,7 @@ public class ResourceAdapterFactory extends AdapterFactoryImpl {
* @generated
*/
public ResourceAdapterFactory() {
- if(modelPackage == null) {
+ if (modelPackage == null) {
modelPackage = ResourcePackage.eINSTANCE;
}
}
@@ -58,11 +59,11 @@ public class ResourceAdapterFactory extends AdapterFactoryImpl {
*/
@Override
public boolean isFactoryForType(Object object) {
- if(object == modelPackage) {
+ if (object == modelPackage) {
return true;
}
- if(object instanceof EObject) {
- return ((EObject)object).eClass().getEPackage() == modelPackage;
+ if (object instanceof EObject) {
+ return ((EObject) object).eClass().getEPackage() == modelPackage;
}
return false;
}
@@ -95,13 +96,13 @@ public class ResourceAdapterFactory extends AdapterFactoryImpl {
* Creates an adapter for the <code>target</code>. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param target
- * the object to adapt.
+ * the object to adapt.
* @return the adapter for the <code>target</code>.
* @generated
*/
@Override
public Adapter createAdapter(Notifier target) {
- return modelSwitch.doSwitch((EObject)target);
+ return modelSwitch.doSwitch((EObject) target);
}
/**
@@ -119,7 +120,8 @@ public class ResourceAdapterFactory extends AdapterFactoryImpl {
}
/**
- * Creates a new adapter for an object of class ' {@link org.eclipse.papyrus.resource.ResourceEObject <em>EObject</em>}'. <!-- begin-user-doc
+ * Creates a new adapter for an object of class '
+ * {@link org.eclipse.papyrus.resource.ResourceEObject <em>EObject</em>}'. <!-- begin-user-doc
* --> This default implementation returns null so that we can easily ignore cases; it's useful
* to ignore a case when inheritance will catch all the cases anyway. <!-- end-user-doc -->
*
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceSwitch.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceSwitch.java
index a123d7f01b6..d3d4eef7c07 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceSwitch.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceSwitch.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.resource.*;
import org.eclipse.papyrus.resource.Resource;
import org.eclipse.papyrus.resource.ResourceEObject;
import org.eclipse.papyrus.resource.ResourcePackage;
@@ -46,7 +47,7 @@ public class ResourceSwitch<T> {
* @generated
*/
public ResourceSwitch() {
- if(modelPackage == null) {
+ if (modelPackage == null) {
modelPackage = ResourcePackage.eINSTANCE;
}
}
@@ -70,7 +71,7 @@ public class ResourceSwitch<T> {
* @generated
*/
protected T doSwitch(EClass theEClass, EObject theEObject) {
- if(theEClass.eContainer() == modelPackage) {
+ if (theEClass.eContainer() == modelPackage) {
return doSwitch(theEClass.getClassifierID(), theEObject);
} else {
List<EClass> eSuperTypes = theEClass.getESuperTypes();
@@ -86,20 +87,18 @@ public class ResourceSwitch<T> {
* @generated
*/
protected T doSwitch(int classifierID, EObject theEObject) {
- switch(classifierID) {
- case ResourcePackage.RESOURCE:
- {
- Resource resource = (Resource)theEObject;
+ switch (classifierID) {
+ case ResourcePackage.RESOURCE: {
+ Resource resource = (Resource) theEObject;
T result = caseResource(resource);
- if(result == null)
+ if (result == null)
result = defaultCase(theEObject);
return result;
}
- case ResourcePackage.RESOURCE_EOBJECT:
- {
- ResourceEObject resourceEObject = (ResourceEObject)theEObject;
+ case ResourcePackage.RESOURCE_EOBJECT: {
+ ResourceEObject resourceEObject = (ResourceEObject) theEObject;
T result = caseResourceEObject(resourceEObject);
- if(result == null)
+ if (result == null)
result = defaultCase(theEObject);
return result;
}
@@ -114,7 +113,7 @@ public class ResourceSwitch<T> {
* terminate the switch. <!-- end-user-doc -->
*
* @param object
- * the target of the switch.
+ * the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Resource</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
@@ -129,7 +128,7 @@ public class ResourceSwitch<T> {
* terminate the switch. <!-- end-user-doc -->
*
* @param object
- * the target of the switch.
+ * the target of the switch.
* @return the result of interpreting the object as an instance of '<em>EObject</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
@@ -144,7 +143,7 @@ public class ResourceSwitch<T> {
* terminate the switch, but this is the last case anyway. <!-- end-user-doc -->
*
* @param object
- * the target of the switch.
+ * the target of the switch.
* @return the result of interpreting the object as an instance of '<em>EObject</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject)
* @generated
diff --git a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceUtil.java b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceUtil.java
index bbe506e8f9f..1588043f54d 100644
--- a/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceUtil.java
+++ b/plugins/profile-tool/org.eclipse.papyrus.resource/src/org/eclipse/papyrus/resource/util/ResourceUtil.java
@@ -18,6 +18,7 @@ import java.util.Iterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.resource.Resource;
import org.eclipse.papyrus.resource.ResourceFactory;
+import org.eclipse.papyrus.resource.impl.ResourceImpl;
/**
* This class provides static methods to help users using Resources
@@ -53,16 +54,10 @@ public class ResourceUtil {
if (eResource == null) {
return null;
}
- Resource result = null;
- for (EObject e : eResource.getContents()) {
- if (e instanceof Resource) {
- result = (Resource) e;
- break;
- }
- }
+ Resource result = ResourceImpl.getResource(eResource);
if (result == null) {
result = ResourceFactory.eINSTANCE.createResource();
- eResource.getContents().add(result);
+ result.setResource(eResource);
}
return result;
}

Back to the top