diff options
| author | Laurent Fasani | 2015-01-19 14:57:42 +0000 |
|---|---|---|
| committer | Laurent Fasani | 2015-02-03 15:53:51 +0000 |
| commit | dcf15fcea1ab20d648052daa39b341399f017afc (patch) | |
| tree | 85148a4eda082ab5742c0e3ac37b1c4da431f51d | |
| parent | ad71ae7b47efd934f7bda281b138c2b199881a1b (diff) | |
| download | org.eclipse.sirius-dcf15fcea1ab20d648052daa39b341399f017afc.tar.gz org.eclipse.sirius-dcf15fcea1ab20d648052daa39b341399f017afc.tar.xz org.eclipse.sirius-dcf15fcea1ab20d648052daa39b341399f017afc.zip | |
[458216] Prevent resolving proxy when removing CrossRefAdapter
All ECrossReferenceAdapter used in sirius session implement
SiriusCrossReferenceAdapter extending SiriusCrossReferenceAdapterImpl
for some to do it.
Before unloading or removing a resource, all SiriusCrossReferenceAdapter
are put to
"disableResolveProxy" in order to avoid reload the unloading resource.
The same instance of SiriusCrossReferencerAdapter is set on a resource
and all its content.
Dependency from org.eclipse.sirius.tests.junit to plugin
org.eclipse.sirius.tests.sample.component has been added.
component metamodel has been modified
* add Component.reference property
* in genmodel,Containement proxies put to true
* Component.children put to "Resolve proxies"=true
Bug: 458216
Change-Id: I1199955d26da624571be122d11cc46d012547469
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
35 files changed, 1197 insertions, 775 deletions
diff --git a/packaging/org.eclipse.sirius.tests.parent/pom.xml b/packaging/org.eclipse.sirius.tests.parent/pom.xml index 48f4e9df7d..671c308028 100644 --- a/packaging/org.eclipse.sirius.tests.parent/pom.xml +++ b/packaging/org.eclipse.sirius.tests.parent/pom.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (c) 2007, 2013 THALES GLOBAL SERVICES All rights reserved. This program and the accompanying materials are made available under the terms +<!-- Copyright (c) 2007, 2015 THALES GLOBAL SERVICES All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Obeo - Initial API and implementation --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> @@ -71,6 +71,7 @@ <module>../../plugins/org.eclipse.sirius.tests.sample.docbook.design</module> <module>../../plugins/org.eclipse.sirius.tests.sample.migration</module> <module>../../plugins/org.eclipse.sirius.tests.sample.migration.design</module> + <module>../../plugins/org.eclipse.sirius.tests.sample.component</module> <module>../../plugins/org.eclipse.sirius.tests.junit</module> <module>../../plugins/org.eclipse.sirius.tests.tree</module> <module>../../plugins/org.eclipse.sirius.tests.swtbot</module> diff --git a/packaging/org.eclipse.sirius.tests/feature.xml b/packaging/org.eclipse.sirius.tests/feature.xml index 69bde28795..a7bd818895 100644 --- a/packaging/org.eclipse.sirius.tests/feature.xml +++ b/packaging/org.eclipse.sirius.tests/feature.xml @@ -90,6 +90,12 @@ modelers, using JUnit or SWTbot. Install this if you want to write automated tes version="0.0.0" unpack="false"/> + <plugin id="org.eclipse.sirius.tests.sample.component" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + <plugin id="org.eclipse.sirius.tests.junit" download-size="0" install-size="0" diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/ECrossReferenceAdapterWithUnproxyCapability.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/ECrossReferenceAdapterWithUnproxyCapability.java index b037b01dde..749dbe3311 100644 --- a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/ECrossReferenceAdapterWithUnproxyCapability.java +++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/ECrossReferenceAdapterWithUnproxyCapability.java @@ -19,7 +19,6 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; import org.eclipse.emf.ecore.util.EcoreUtil; import com.google.common.collect.Lists; @@ -32,7 +31,7 @@ import com.google.common.collect.Maps; * @noextend This class is not intended to be subclassed by clients. * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> */ -public class ECrossReferenceAdapterWithUnproxyCapability extends ECrossReferenceAdapter { +public class ECrossReferenceAdapterWithUnproxyCapability extends SiriusCrossReferenceAdapterImpl { /** * InverseCrossReferencer to allow access to {@link #removeProxies(URI)} in * '@link InternalCrossReferencer}. diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/LazyCrossReferencer.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/LazyCrossReferencer.java index cad35199fe..519c89ea8d 100644 --- a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/LazyCrossReferencer.java +++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/LazyCrossReferencer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 THALES GLOBAL SERVICES. + * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,11 +40,10 @@ import com.google.common.collect.Iterables; * @author mchauvin */ public class LazyCrossReferencer extends ECrossReferenceAdapterWithUnproxyCapability { - private boolean resolveEnabled = true; - - private boolean initialized; - - private ECrossReferenceAdapterWithUnproxyCapability adapter = new InternalCrossReferencer(); + /** + * Flag to know if the LazyCrossReferencer has been initialized. + */ + protected boolean initialized; /** * Subclasses should override, and call super.initialize(). @@ -53,151 +52,87 @@ public class LazyCrossReferencer extends ECrossReferenceAdapterWithUnproxyCapabi initialized = true; } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#dump() - */ @Override public void dump() { if (!initialized) { initialize(); } - adapter.dump(); + super.dump(); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getInverseReferences(org.eclipse.emf.ecore.EObject, - * boolean) - */ @Override public Collection<Setting> getInverseReferences(final EObject object, final boolean resolve) { if (!initialized) { initialize(); } - return adapter.getInverseReferences(object, resolve); + return super.getInverseReferences(object, resolve); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getInverseReferences(org.eclipse.emf.ecore.EObject) - */ @Override public Collection<Setting> getInverseReferences(final EObject object) { if (!initialized) { initialize(); } - return adapter.getInverseReferences(object); + return super.getInverseReferences(object); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getNonNavigableInverseReferences(org.eclipse.emf.ecore.EObject, - * boolean) - */ @Override public Collection<Setting> getNonNavigableInverseReferences(final EObject object, final boolean resolve) { if (!initialized) { initialize(); } - return adapter.getNonNavigableInverseReferences(object, resolve); + return super.getNonNavigableInverseReferences(object, resolve); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getNonNavigableInverseReferences(org.eclipse.emf.ecore.EObject) - */ @Override public Collection<Setting> getNonNavigableInverseReferences(final EObject object) { if (!initialized) { initialize(); } - return adapter.getNonNavigableInverseReferences(object); + return super.getNonNavigableInverseReferences(object); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#getTarget() - */ @Override public Notifier getTarget() { if (!initialized) { initialize(); } - return adapter.getTarget(); + return super.getTarget(); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#isAdapterForType(java.lang.Object) - */ @Override public boolean isAdapterForType(final Object type) { if (!initialized) { initialize(); } - return adapter.isAdapterForType(type); + return super.isAdapterForType(type); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ @Override public void notifyChanged(final Notification notification) { if (!initialized) { initialize(); } - adapter.notifyChanged(notification); + super.notifyChanged(notification); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#setTarget(org.eclipse.emf.common.notify.Notifier) - */ @Override public void setTarget(final Notifier target) { if (!initialized) { initialize(); } - adapter.setTarget(target); + super.setTarget(target); } - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecore.util.ECrossReferenceAdapter#unsetTarget(org.eclipse.emf.common.notify.Notifier) - */ @Override public void unsetTarget(final Notifier target) { if (!initialized) { initialize(); } - adapter.unsetTarget(target); + super.unsetTarget(target); } - /** - * Disable the resolution of the proxy. - */ - public void disableResolve() { - resolveEnabled = false; - } - /** - * Enable the resolution of the proxy. - */ - public void enableResolve() { - resolveEnabled = true; - } /** * Look at all EObjects of this resource and resolve proxy cross reference @@ -207,67 +142,50 @@ public class LazyCrossReferencer extends ECrossReferenceAdapterWithUnproxyCapabi * Each cross reference pointing to a proxy of this * <code>resource</code> will be resolved. */ + @Override public void resolveProxyCrossReferences(Resource resource) { if (initialized) { // The resolution of proxy is called only is the cross-referencer // has already been initialized. - adapter.resolveProxyCrossReferences(resource); + super.resolveProxyCrossReferences(resource); } } + @Override + protected void handleContainment(Notification notification) { + deregisterDeletedElements(notification); + + super.handleContainment(notification); + } + /** - * @see LazyCrossReferencer. This class is the delegated adapter. + * This method removes the current cross referencer adapter from adapters of + * removed elements. The removeAdapter method propagate the removal to all + * contents of its parameter. + * + * @param notification + * a containment notification */ - private class InternalCrossReferencer extends ECrossReferenceAdapterWithUnproxyCapability { - - /** - * {@inheritDoc} - */ - protected boolean resolve() { - if (resolveEnabled) { - return super.resolve(); + protected void deregisterDeletedElements(Notification notification) { + switch (notification.getEventType()) { + + case Notification.UNSET: + case Notification.SET: + case Notification.REMOVE: + Object oldValue = notification.getOldValue(); + if (oldValue instanceof Notifier) { + removeAdapter((Notifier) oldValue); } - return false; - }; - - /** - * {@inheritDoc} - */ - protected void handleContainment(Notification notification) { - deregisterDeletedElements(notification); + break; - super.handleContainment(notification); - } - - /** - * This method removes the current cross referencer adapter from - * adapters of removed elements. The removeAdapter method propagate the - * removal to all contents of its parameter. - * - * @param notification - * a containment notification - */ - private void deregisterDeletedElements(Notification notification) { - switch (notification.getEventType()) { - - case Notification.UNSET: - case Notification.SET: - case Notification.REMOVE: - Object oldValue = notification.getOldValue(); - if (oldValue instanceof Notifier) { - removeAdapter((Notifier) oldValue); - } - break; - - case Notification.REMOVE_MANY: - for (Notifier oldVal : Iterables.filter((Collection<?>) notification.getOldValue(), Notifier.class)) { - removeAdapter(oldVal); - } - break; - - default: - break; + case Notification.REMOVE_MANY: + for (Notifier oldVal : Iterables.filter((Collection<?>) notification.getOldValue(), Notifier.class)) { + removeAdapter(oldVal); } + break; + + default: + break; } - }; + } } diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/SiriusCrossReferenceAdapter.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/SiriusCrossReferenceAdapter.java new file mode 100644 index 0000000000..ed00e1d90e --- /dev/null +++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/SiriusCrossReferenceAdapter.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.common.tools.api.util; + +/** + * Contract for {@link ECrossReferenceAdapter} which resolve proxy ability can + * be disabled. + * + * @see {@link SiriusCrossReferenceAdapterImpl} + * + * @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a> + */ +public interface SiriusCrossReferenceAdapter { + + /** + * Disable the resolution of the proxy. + */ + void disableResolveProxy(); + + /** + * Enable the resolution of the proxy. + */ + void enableResolveProxy(); +} diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/SiriusCrossReferenceAdapterImpl.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/SiriusCrossReferenceAdapterImpl.java new file mode 100644 index 0000000000..2d22b99f22 --- /dev/null +++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/SiriusCrossReferenceAdapterImpl.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.common.tools.api.util; + +import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; + +/** + * Specific {@link ECrossReferenceAdapter} which resolve proxy ability can be + * disabled. All {@link ECrossReferenceAdapter} used for Sirius should extend + * this adapter in place of {@link ECrossReferenceAdapter} + * + * @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a> + */ +public class SiriusCrossReferenceAdapterImpl extends ECrossReferenceAdapter implements SiriusCrossReferenceAdapter { + + /** + * Tell if the resolution of the proxy is enabled or not. + */ + private boolean resolveProxyEnabled = true; + + /** + * Disable the resolution of the proxy. + */ + @Override + public void disableResolveProxy() { + resolveProxyEnabled = false; + } + + /** + * Enable the resolution of the proxy. + */ + @Override + public void enableResolveProxy() { + resolveProxyEnabled = true; + } + + @Override + protected boolean resolve() { + if (resolveProxyEnabled) { + return super.resolve(); + } + return false; + } +} diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html index 1fb5d13cea..b620d7997f 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html @@ -93,8 +93,18 @@ <code>org.eclipse.sirius.common</code> </h4> <ul> + <li>The + <code>org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter</code> interface and the + <code>org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl</code> have been added to have the capability to disable the proxy resolution. This feature is typically used to prevent loading a resource during its unloading. + <strong>Warning</strong> : + <em>Every additional custom CrossReferenceAdapter</em> should extend + <code>SiriusCrossReferenceAdapterImpl</code> or at least implement + <code>SiriusCrossReferenceAdapter</code> with the same implementation as + <code>SiriusCrossReferenceAdapterImpl</code>. + </li> <li> - <code>org.eclipse.sirius.common.tools.api.util.ECrossReferenceAdapterWithUnproxyCapability</code> is a specific kind of ECrossReferenceAdapter. It provides the capability to resolve all proxy cross references to a given resource. It is now used by the Session as semantic cross referencer. This type is exposed as API but it is not intended to be used/referenced/extended by user code (as the below + <code>org.eclipse.sirius.common.tools.api.util.ECrossReferenceAdapterWithUnproxyCapability</code> is a specific kind of + <code>SiriusCrossReferenceAdapter</code>. It provides the capability to resolve all proxy cross references to a given resource. It is now used by the Session as semantic cross referencer. This type is exposed as API but it is not intended to be used/referenced/extended by user code (as the below <code>LazyCrossReferencer</code> type). </li> <li> @@ -109,6 +119,12 @@ <code>org.eclipse.sirius.common.tools.api.resource.ResourceSetSync</code> has a new state <code>CHANGES_CANCELED</code> used to define the state where the user canceled its changes. </li> + <li>The + <code>org.eclipse.sirius.common.tools.api.util.LazyCrossReferencer.enableResolve()</code> and + <code>disableResolve()</code> methods has been moved to + <code>SiriusCrossReferenceAdapter.enableResolveProxy()</code> and + <code>disableResolveProxy()</code>. + </li> </ul> <h4 id="Changesinorg.eclipse.sirius.ecore.extender">Changes in <code>org.eclipse.sirius.ecore.extender</code> @@ -2192,4 +2208,4 @@ void removeSelectedView(DView view); <li>The ability to print table representations has been disabled for the 0.9 release due to an external dependency issue (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=422223" target="_blank">bug #422223</a>: for the details). It should be re-introduced in 1.0.</li> </ul> </body> -</html> +</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile index 7e68bf2886..3cb60af163 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile @@ -30,10 +30,12 @@ h4. Changes in @org.eclipse.sirius@ h4. Changes in @org.eclipse.sirius.common@ -* @org.eclipse.sirius.common.tools.api.util.ECrossReferenceAdapterWithUnproxyCapability@ is a specific kind of ECrossReferenceAdapter. It provides the capability to resolve all proxy cross references to a given resource. It is now used by the Session as semantic cross referencer. This type is exposed as API but it is not intended to be used/referenced/extended by user code (as the below @LazyCrossReferencer@ type). +* The @org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter@ interface and the @org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl@ have been added to have the capability to disable the proxy resolution. This feature is typically used to prevent loading a resource during its unloading. *Warning* : _Every additional custom CrossReferenceAdapter_ should extend @SiriusCrossReferenceAdapterImpl@ or at least implement @SiriusCrossReferenceAdapter@ with the same implementation as @SiriusCrossReferenceAdapterImpl@. +* @org.eclipse.sirius.common.tools.api.util.ECrossReferenceAdapterWithUnproxyCapability@ is a specific kind of @SiriusCrossReferenceAdapter@. It provides the capability to resolve all proxy cross references to a given resource. It is now used by the Session as semantic cross referencer. This type is exposed as API but it is not intended to be used/referenced/extended by user code (as the below @LazyCrossReferencer@ type). * @org.eclipse.sirius.common.tools.api.util.LazyCrossReferencer@ now extends @ECrossReferenceAdapterWithUnproxyCapability@ and implements @resolveProxyCrossReferences(Resource)@. * The static method @org.eclipse.sirius.common.tools.api.util.ReflectionHelper.getFieldValueWithoutException(Class<?>, String)@ has been added to return an internal static value of a class. * @org.eclipse.sirius.common.tools.api.resource.ResourceSetSync@ has a new state @CHANGES_CANCELED@ used to define the state where the user canceled its changes. +* The @org.eclipse.sirius.common.tools.api.util.LazyCrossReferencer.enableResolve()@ and @disableResolve()@ methods has been moved to @SiriusCrossReferenceAdapter.enableResolveProxy()@ and @disableResolveProxy()@. h4. Changes in @org.eclipse.sirius.ecore.extender@ diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.html b/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.html index 3a5f193334..cd6e73ba14 100644 --- a/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.html +++ b/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.html @@ -72,6 +72,15 @@ </li> </ul> </li> + <li>The Sirius platform publishs a set of API, and the next sections describe some which require particular attention: + <ul> + <li> + <a href="siriusCrossReferenceAdapter.html"> + <strong>SiriusCrossReferenceAdapter</strong> + </a> + </li> + </ul> + </li> </ul> </body> </html>
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.textile b/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.textile index da3557d7f3..786027df5c 100644 --- a/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.textile +++ b/plugins/org.eclipse.sirius.doc/doc/developer/Sirius Developer Manual.textile @@ -13,3 +13,5 @@ This document gives an overview of the internals of the _Sirius_ platform, and d ** "*Provide tab-bar extensions*":extensions-provide_tabbar_extensions.html ** "*Provide custom representation files migration*":extensions-provide_migrate_contribution.html ** "*Provide custom repair participant*":extensions-provide_repair_contribution.html +* The Sirius platform publishs a set of API, and the next sections describe some which require particular attention: +** "*SiriusCrossReferenceAdapter*":siriusCrossReferenceAdapter.html
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/siriusCrossReferenceAdapter.html b/plugins/org.eclipse.sirius.doc/doc/developer/siriusCrossReferenceAdapter.html new file mode 100644 index 0000000000..2878977043 --- /dev/null +++ b/plugins/org.eclipse.sirius.doc/doc/developer/siriusCrossReferenceAdapter.html @@ -0,0 +1,25 @@ +<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <title>siriusCrossReferenceAdapter</title> + <link type="text/css" rel="stylesheet" href="../resources/bootstrap.css"/> + <link type="text/css" rel="stylesheet" href="../resources/custom.css"/> + </head> + <body> + <h1 id="SiriusCrossReferenceAdapter">SiriusCrossReferenceAdapter</h1> + <p>The + <code>org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter</code> interface is designed to disable the proxy resolution of the InverseCrossReferencer. + </p> + <p>This capability is typically used to prevent loading a resource during its unloading.</p> + <p>Furthermore, it is not recommended to add other ECrossReferenceAdapter additionally to those created by Sirius. Note that you can get the semantic CrossReferencer with + <code>org.eclipse.sirius.business.api.session.Session.getSemanticCrossReferencer()</code>. + </p> + <p>However, in the case where an additional custom ECrossReferenceAdapter is needed, it should extend + <code>org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl</code> or at least implement + <code>SiriusCrossReferenceAdapter</code> with the same implementation as + <code>SiriusCrossReferenceAdapterImpl</code>. + <br/>Otherwise, there is no guarantee that load during unload won’t come up. + </p> + </body> +</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.doc/doc/developer/siriusCrossReferenceAdapter.textile b/plugins/org.eclipse.sirius.doc/doc/developer/siriusCrossReferenceAdapter.textile new file mode 100644 index 0000000000..caefa72dcf --- /dev/null +++ b/plugins/org.eclipse.sirius.doc/doc/developer/siriusCrossReferenceAdapter.textile @@ -0,0 +1,11 @@ + +h1. SiriusCrossReferenceAdapter + +The @org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter@ interface is designed to disable the proxy resolution of the InverseCrossReferencer. + +This capability is typically used to prevent loading a resource during its unloading. + +Furthermore, it is not recommended to add other ECrossReferenceAdapter additionally to those created by Sirius. Note that you can get the semantic CrossReferencer with @org.eclipse.sirius.business.api.session.Session.getSemanticCrossReferencer()@. + +However, in the case where an additional custom ECrossReferenceAdapter is needed, it should extend @org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl@ or at least implement @SiriusCrossReferenceAdapter@ with the same implementation as @SiriusCrossReferenceAdapterImpl@. +Otherwise, there is no guarantee that load during unload won't come up. diff --git a/plugins/org.eclipse.sirius.tests.junit/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.tests.junit/META-INF/MANIFEST.MF index c9ee0da2d7..4a731cb49e 100644 --- a/plugins/org.eclipse.sirius.tests.junit/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.sirius.tests.junit/META-INF/MANIFEST.MF @@ -63,7 +63,8 @@ Require-Bundle: org.eclipse.sirius.tests.sample.benchmark, org.eclipse.acceleo.common;bundle-version="3.4.1", org.eclipse.sirius.diagram.ui;bundle-version="1.0.0", org.eclipse.sdk, - org.eclipse.platform + org.eclipse.platform, + org.eclipse.sirius.tests.sample.component Bundle-Activator: org.eclipse.sirius.tests.SiriusTestsPlugin Eclipse-LazyStart: true Bundle-Localization: plugin diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java index 5e281c843f..1a40a3b667 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/common/AllCommonPluginTests.java @@ -59,6 +59,7 @@ import org.eclipse.sirius.tests.unit.common.OperationCanceledExceptionSessionTes import org.eclipse.sirius.tests.unit.common.PreferencesTests; import org.eclipse.sirius.tests.unit.common.RefreshEditorsPrecommitListenerTests; import org.eclipse.sirius.tests.unit.common.RestoreSessionFromEditorInputTests; +import org.eclipse.sirius.tests.unit.common.SiriusCrossReferenceAdapterTests; import org.eclipse.sirius.tests.unit.common.TransientSessionTests; import org.eclipse.sirius.tests.unit.common.WorkspaceResourceSyncTestCase; import org.eclipse.sirius.tests.unit.common.interpreter.CompoundInterpreterTestCase; @@ -259,6 +260,7 @@ public class AllCommonPluginTests extends TestCase { suite.addTestSuite(TransientSessionTests.class); suite.addTestSuite(RestoreSessionFromEditorInputTests.class); + suite.addTestSuite(SiriusCrossReferenceAdapterTests.class); } /** diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/EditingDomainFactoryServiceTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/EditingDomainFactoryServiceTests.java index 905e6cdfae..dac5b2d1c4 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/EditingDomainFactoryServiceTests.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/EditingDomainFactoryServiceTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,7 +24,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.sirius.business.api.session.DefaultLocalSessionCreationOperation; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionCreationOperation; -import org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter; +import org.eclipse.sirius.business.internal.resource.parser.AirDCrossReferenceAdapterImpl; import org.eclipse.sirius.common.tools.api.editing.DefaultEditingDomainFactory; import org.eclipse.sirius.common.tools.api.editing.EditingDomainFactoryDescriptor; import org.eclipse.sirius.common.tools.api.editing.EditingDomainFactoryRegistry; @@ -137,7 +137,7 @@ public class EditingDomainFactoryServiceTests { } private void assertExpectedAirdCrossReferencerAdapterNumber(SharedTestEditingDomainFactory sharedEditingDomainFactory, int expected) { - assertEquals(expected, Iterables.size(Iterables.filter(sharedEditingDomainFactory.sharedDomain.getResourceSet().eAdapters(), AirDCrossReferenceAdapter.class))); + assertEquals(expected, Iterables.size(Iterables.filter(sharedEditingDomainFactory.sharedDomain.getResourceSet().eAdapters(), AirDCrossReferenceAdapterImpl.class))); } @After diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/SiriusCrossReferenceAdapterTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/SiriusCrossReferenceAdapterTests.java new file mode 100644 index 0000000000..c8f98dc418 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/SiriusCrossReferenceAdapterTests.java @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright (c) 2015 THALES GLOBAL SERVICES. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.unit.common; + +import java.io.File; +import java.util.Iterator; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.internal.EMFTransactionStatusCodes; +import org.eclipse.sirius.common.tools.api.resource.ResourceSetSync; +import org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter; +import org.eclipse.sirius.tests.sample.component.Component; +import org.eclipse.sirius.tests.sample.component.ComponentFactory; +import org.eclipse.sirius.tests.support.api.SiriusTestCase; +import org.eclipse.sirius.tools.api.command.ICommandFactory; + +/** + * Class containing tests to update of {@link SiriusCrossReferenceAdapter} after + * CRUD action on resources through DAnalysisSessionImpl such + * unload/reload/remove resource, close session. + * + * @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a> + */ +public class SiriusCrossReferenceAdapterTests extends SiriusTestCase { + + private TransactionalEditingDomain editingDomain; + + static final String fragmentFileName = "fragComponent.component"; + + @Override + protected void setUp() throws Exception { + super.setUp(); + setWarningCatchActive(true); + + } + + /** + * Check that fragmented resource is not reloaded during its unload when it + * has been externally modified. + * + * @throws Exception + */ + public void testDisablingCrossReferencerWhileReloadingResource() throws Exception { + genericSetUp(); + + initSemanticResource(); + + // simulation an EXTERNAL CHANGE of fragmentResource + File fragFile = ResourcesPlugin.getWorkspace().getRoot().getProject(TEMPORARY_PROJECT_NAME).getFile(fragmentFileName).getLocation().toFile(); + fragFile.setLastModified(System.currentTimeMillis()); + + ResourceSetSync resourceSetSync = ResourceSetSync.getResourceSetSync(editingDomain).get(); + resourceSetSync.statusChanged(editingDomain.getResourceSet().getResources().get(2), ResourceSetSync.ResourceStatus.SYNC, ResourceSetSync.ResourceStatus.EXTERNAL_CHANGED); + + //check that no warning "loading resource while unloading it" has been dispatched + for (Iterator<IStatus> warning = warnings.values().iterator(); warning.hasNext();) { + IStatus status = warning.next(); + if (status.getCode() == EMFTransactionStatusCodes.RELOAD_DURING_UNLOAD) { + fail("Resource is being reloaded during its unload."); + } + } + } + + /** + * Check that fragmented resource is not reloaded during its unload when it + * has been externally deleted. + * + * @throws Exception + */ + public void testDisablingCrossReferencerWhileDeletingResource() throws Exception { + + // create session with empty aird + genericSetUp(); + + // add semantic resources + initSemanticResource(); + + // simulation of DELETION of fragmentResource + File fragFile = ResourcesPlugin.getWorkspace().getRoot().getProject(TEMPORARY_PROJECT_NAME).getFile(fragmentFileName).getLocation().toFile(); + fragFile.delete(); + ResourceSetSync resourceSetSync = ResourceSetSync.getResourceSetSync(editingDomain).get(); + resourceSetSync.statusChanged(editingDomain.getResourceSet().getResources().get(2), ResourceSetSync.ResourceStatus.SYNC, ResourceSetSync.ResourceStatus.DELETED); + // Warning : Avoid using ResourcesPlugin because event are sent too late. + // ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, + // null); + + // check that no warning "loading resource while unloading it" has been + // dispatched + for (Iterator<IStatus> warning = warnings.values().iterator(); warning.hasNext();) { + IStatus status = warning.next(); + if (status.getCode() == EMFTransactionStatusCodes.RELOAD_DURING_UNLOAD) { + fail("Resource is being reloaded during its unload."); + } + } + } + + /** + * Initialize semantic resources + */ + private void initSemanticResource() { + final ResourceSet rset = session.getTransactionalEditingDomain().getResourceSet(); + editingDomain = session.getTransactionalEditingDomain(); + + // initialize model + final Component componentRoot = ComponentFactory.eINSTANCE.createComponent(); + componentRoot.setName("compoRoot"); + componentRoot.setPayload(true); + + final Component component1 = ComponentFactory.eINSTANCE.createComponent(); + component1.setName("compo1"); + component1.setPayload(true); + + componentRoot.getChildren().add(component1); + + Component component2 = ComponentFactory.eINSTANCE.createComponent(); + component2.setName("compo2"); + component1.getChildren().add(component2); + component2.setReference(component1); + + // create resources + final URI fileMainComponentUri = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + "Maincomponent.component", true); + final Resource rsMainComponent = rset.createResource(fileMainComponentUri); + + final URI fileFragComponentUri = URI.createPlatformResourceURI("/" + TEMPORARY_PROJECT_NAME + "/" + fragmentFileName, true); + final Resource rsFragComponent = rset.createResource(fileFragComponentUri); + + editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { + + @Override + protected void doExecute() { + // add content to resource + rsMainComponent.getContents().add(componentRoot); + rsFragComponent.getContents().add(component1); + + // add resources to session + session.addSemanticResource(fileMainComponentUri, new NullProgressMonitor()); + session.addSemanticResource(fileFragComponentUri, new NullProgressMonitor()); + + // save session + session.save(new NullProgressMonitor()); + } + }); + } + + @Override + protected ICommandFactory getCommandFactory() { + return null; + } + +} diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/resource/AirDCrossReferenceAdapterTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/resource/AirDCrossReferenceAdapterTest.java index 6d36430df9..4e7382f3fe 100644 --- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/resource/AirDCrossReferenceAdapterTest.java +++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/resource/AirDCrossReferenceAdapterTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,7 @@ import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter; +import org.eclipse.sirius.business.internal.resource.parser.AirDCrossReferenceAdapterImpl; import org.eclipse.sirius.business.internal.resource.parser.AirDResourceImpl; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DDiagramElement; @@ -80,8 +80,9 @@ public class AirDCrossReferenceAdapterTest extends SiriusDiagramTestCase impleme private boolean shouldContainAirDCrossReferencer(Resource resource) { return Iterables.any(resource.eAdapters(), new Predicate<Adapter>() { + @Override public boolean apply(Adapter input) { - return input instanceof AirDCrossReferenceAdapter; + return input instanceof AirDCrossReferenceAdapterImpl; } }); } diff --git a/plugins/org.eclipse.sirius.tests.sample.component/model/component.ecore b/plugins/org.eclipse.sirius.tests.sample.component/model/component.ecore index c590d5f529..5502da7bc4 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/model/component.ecore +++ b/plugins/org.eclipse.sirius.tests.sample.component/model/component.ecore @@ -10,5 +10,6 @@ eType="#//Component" containment="true"/> <eStructuralFeatures xsi:type="ecore:EReference" name="references" upperBound="-1" eType="#//Component"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//Component"/> </eClassifiers> </ecore:EPackage> diff --git a/plugins/org.eclipse.sirius.tests.sample.component/model/component.genmodel b/plugins/org.eclipse.sirius.tests.sample.component/model/component.genmodel index 52b7f40847..2bdd81f0a0 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/model/component.genmodel +++ b/plugins/org.eclipse.sirius.tests.sample.component/model/component.genmodel @@ -3,9 +3,9 @@ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2015 Obeo
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

Contributors:
 Obeo - initial API and implementation" modelDirectory="/org.eclipse.sirius.tests.sample.component/src" modelPluginID="org.eclipse.sirius.tests.sample.component" modelName="Component" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" - rootImplementsInterface="" importerID="org.eclipse.emf.importer.ecore" complianceLevel="6.0" - copyrightFields="false" runtimeVersion="2.8" language="" classNamePattern="" operationReflection="true" - importOrganizing="true"> + rootImplementsInterface="" importerID="org.eclipse.emf.importer.ecore" containmentProxies="true" + complianceLevel="6.0" copyrightFields="false" runtimeVersion="2.8" language="" + classNamePattern="" operationReflection="true" importOrganizing="true"> <foreignModel>component.ecore</foreignModel> <genPackages prefix="Component" basePackage="org.eclipse.sirius.tests.sample" disposableProviderFactory="true" ecorePackage="component.ecore#/"> @@ -14,6 +14,7 @@ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute component.ecore#//Component/payload"/> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference component.ecore#//Component/children"/> <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference component.ecore#//Component/references"/> + <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference component.ecore#//Component/reference"/> </genClasses> </genPackages> </genmodel:GenModel> diff --git a/plugins/org.eclipse.sirius.tests.sample.component/pom.xml b/plugins/org.eclipse.sirius.tests.sample.component/pom.xml new file mode 100644 index 0000000000..dd88910873 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.sample.component/pom.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2015 Obeo + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Obeo - Initial API and implementation +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.sirius</groupId> + <artifactId>sirius-tests-parent</artifactId> + <version>3.0.0-SNAPSHOT</version> + <relativePath>../../packaging/org.eclipse.sirius.tests.parent</relativePath> + </parent> + + <artifactId>org.eclipse.sirius.tests.sample.component</artifactId> + <packaging>eclipse-plugin</packaging> + <version>3.0.0-SNAPSHOT</version> + +</project> diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/Component.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/Component.java index 1c18959a90..7d81a1ccff 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/Component.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/Component.java @@ -15,17 +15,22 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; /** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Component</b></em>'. - * <!-- end-user-doc --> + * <!-- begin-user-doc --> A representation of the model object ' + * <em><b>Component</b></em>'. <!-- end-user-doc --> * * <p> * The following features are supported: * <ul> - * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.sirius.tests.sample.component.Component#isPayload <em>Payload</em>}</li> - * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getChildren <em>Children</em>}</li> - * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getReferences <em>References</em>}</li> + * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getName <em> + * Name</em>}</li> + * <li>{@link org.eclipse.sirius.tests.sample.component.Component#isPayload <em> + * Payload</em>}</li> + * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getChildren + * <em>Children</em>}</li> + * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getReferences + * <em>References</em>}</li> + * <li>{@link org.eclipse.sirius.tests.sample.component.Component#getReference + * <em>Reference</em>}</li> * </ul> * </p> * @@ -35,13 +40,14 @@ import org.eclipse.emf.ecore.EObject; */ public interface Component extends EObject { /** - * Returns the value of the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> + * Returns the value of the '<em><b>Name</b></em>' attribute. <!-- + * begin-user-doc --> * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, - * there really should be more of a description here... + * If the meaning of the '<em>Name</em>' attribute isn't clear, there really + * should be more of a description here... * </p> * <!-- end-user-doc --> + * * @return the value of the '<em>Name</em>' attribute. * @see #setName(String) * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#getComponent_Name() @@ -51,23 +57,26 @@ public interface Component extends EObject { String getName(); /** - * Sets the value of the '{@link org.eclipse.sirius.tests.sample.component.Component#getName <em>Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Name</em>' attribute. + * Sets the value of the ' + * {@link org.eclipse.sirius.tests.sample.component.Component#getName + * <em>Name</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @param value + * the new value of the '<em>Name</em>' attribute. * @see #getName() * @generated */ void setName(String value); /** - * Returns the value of the '<em><b>Payload</b></em>' attribute. - * <!-- begin-user-doc --> + * Returns the value of the '<em><b>Payload</b></em>' attribute. <!-- + * begin-user-doc --> * <p> - * If the meaning of the '<em>Payload</em>' attribute isn't clear, - * there really should be more of a description here... + * If the meaning of the '<em>Payload</em>' attribute isn't clear, there + * really should be more of a description here... * </p> * <!-- end-user-doc --> + * * @return the value of the '<em>Payload</em>' attribute. * @see #setPayload(boolean) * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#getComponent_Payload() @@ -77,40 +86,47 @@ public interface Component extends EObject { boolean isPayload(); /** - * Sets the value of the '{@link org.eclipse.sirius.tests.sample.component.Component#isPayload <em>Payload</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Payload</em>' attribute. + * Sets the value of the ' + * {@link org.eclipse.sirius.tests.sample.component.Component#isPayload + * <em>Payload</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc + * --> + * + * @param value + * the new value of the '<em>Payload</em>' attribute. * @see #isPayload() * @generated */ void setPayload(boolean value); /** - * Returns the value of the '<em><b>Children</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.sirius.tests.sample.component.Component}. - * <!-- begin-user-doc --> + * Returns the value of the '<em><b>Children</b></em>' containment reference + * list. The list contents are of type + * {@link org.eclipse.sirius.tests.sample.component.Component}. <!-- + * begin-user-doc --> * <p> - * If the meaning of the '<em>Children</em>' containment reference list isn't clear, - * there really should be more of a description here... + * If the meaning of the '<em>Children</em>' containment reference list + * isn't clear, there really should be more of a description here... * </p> * <!-- end-user-doc --> + * * @return the value of the '<em>Children</em>' containment reference list. * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#getComponent_Children() - * @model containment="true" + * @model containment="true" resolveProxies="true" * @generated */ EList<Component> getChildren(); /** - * Returns the value of the '<em><b>References</b></em>' reference list. - * The list contents are of type {@link org.eclipse.sirius.tests.sample.component.Component}. - * <!-- begin-user-doc --> + * Returns the value of the '<em><b>References</b></em>' reference list. The + * list contents are of type + * {@link org.eclipse.sirius.tests.sample.component.Component}. <!-- + * begin-user-doc --> * <p> * If the meaning of the '<em>References</em>' reference list isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> + * * @return the value of the '<em>References</em>' reference list. * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#getComponent_References() * @model @@ -118,4 +134,34 @@ public interface Component extends EObject { */ EList<Component> getReferences(); + /** + * Returns the value of the '<em><b>Reference</b></em>' reference. <!-- + * begin-user-doc --> + * <p> + * If the meaning of the '<em>Reference</em>' reference isn't clear, there + * really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * + * @return the value of the '<em>Reference</em>' reference. + * @see #setReference(Component) + * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#getComponent_Reference() + * @model + * @generated + */ + Component getReference(); + + /** + * Sets the value of the ' + * {@link org.eclipse.sirius.tests.sample.component.Component#getReference + * <em>Reference</em>}' reference. <!-- begin-user-doc --> <!-- end-user-doc + * --> + * + * @param value + * the new value of the '<em>Reference</em>' reference. + * @see #getReference() + * @generated + */ + void setReference(Component value); + } // Component diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentFactory.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentFactory.java index e4d4f587b7..3c3002f47d 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentFactory.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentFactory.java @@ -13,38 +13,37 @@ package org.eclipse.sirius.tests.sample.component; import org.eclipse.emf.ecore.EFactory; /** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <!-- end-user-doc --> + * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a + * create method for each non-abstract class of the model. <!-- end-user-doc --> + * * @see org.eclipse.sirius.tests.sample.component.ComponentPackage * @generated */ public interface ComponentFactory extends EFactory { /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The singleton instance of the factory. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * * @generated */ ComponentFactory eINSTANCE = org.eclipse.sirius.tests.sample.component.impl.ComponentFactoryImpl.init(); /** - * Returns a new object of class '<em>Component</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Returns a new object of class '<em>Component</em>'. <!-- begin-user-doc + * --> <!-- end-user-doc --> + * * @return a new object of class '<em>Component</em>'. * @generated */ Component createComponent(); /** - * Returns the package supported by this factory. - * <!-- begin-user-doc --> + * Returns the package supported by this factory. <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @return the package supported by this factory. * @generated */ ComponentPackage getComponentPackage(); -} //ComponentFactory +} // ComponentFactory diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentPackage.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentPackage.java index 0474ff7bbb..f3f5530a81 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentPackage.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/ComponentPackage.java @@ -16,58 +16,56 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; /** - * <!-- begin-user-doc --> - * The <b>Package</b> for the model. - * It contains accessors for the meta objects to represent + * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains + * accessors for the meta objects to represent * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each operation of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> * </ul> * <!-- end-user-doc --> + * * @see org.eclipse.sirius.tests.sample.component.ComponentFactory * @model kind="package" * @generated */ public interface ComponentPackage extends EPackage { /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ String eNAME = "component"; /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ String eNS_URI = "http://www.eclipse.org/sirius/sample/component"; /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ String eNS_PREFIX = "component"; /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The singleton instance of the package. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * * @generated */ ComponentPackage eINSTANCE = org.eclipse.sirius.tests.sample.component.impl.ComponentPackageImpl.init(); /** - * The meta object id for the '{@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl <em>Component</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The meta object id for the ' + * {@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl + * <em>Component</em>}' class. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @see org.eclipse.sirius.tests.sample.component.impl.ComponentImpl * @see org.eclipse.sirius.tests.sample.component.impl.ComponentPackageImpl#getComponent() * @generated @@ -75,64 +73,73 @@ public interface ComponentPackage extends EPackage { int COMPONENT = 0; /** - * The feature id for the '<em><b>Name</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The feature id for the '<em><b>Name</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * * @generated * @ordered */ int COMPONENT__NAME = 0; /** - * The feature id for the '<em><b>Payload</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The feature id for the '<em><b>Payload</b></em>' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * * @generated * @ordered */ int COMPONENT__PAYLOAD = 1; /** - * The feature id for the '<em><b>Children</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The feature id for the '<em><b>Children</b></em>' containment reference + * list. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated * @ordered */ int COMPONENT__CHILDREN = 2; /** - * The feature id for the '<em><b>References</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The feature id for the '<em><b>References</b></em>' reference list. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * * @generated * @ordered */ int COMPONENT__REFERENCES = 3; /** - * The number of structural features of the '<em>Component</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The feature id for the '<em><b>Reference</b></em>' reference. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * * @generated * @ordered */ - int COMPONENT_FEATURE_COUNT = 4; + int COMPONENT__REFERENCE = 4; /** - * The number of operations of the '<em>Component</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The number of structural features of the '<em>Component</em>' class. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * * @generated * @ordered */ - int COMPONENT_OPERATION_COUNT = 0; + int COMPONENT_FEATURE_COUNT = 5; + /** + * The number of operations of the '<em>Component</em>' class. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @generated + * @ordered + */ + int COMPONENT_OPERATION_COUNT = 0; /** - * Returns the meta object for class '{@link org.eclipse.sirius.tests.sample.component.Component <em>Component</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Returns the meta object for class ' + * {@link org.eclipse.sirius.tests.sample.component.Component + * <em>Component</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @return the meta object for class '<em>Component</em>'. * @see org.eclipse.sirius.tests.sample.component.Component * @generated @@ -140,9 +147,10 @@ public interface ComponentPackage extends EPackage { EClass getComponent(); /** - * Returns the meta object for the attribute '{@link org.eclipse.sirius.tests.sample.component.Component#getName <em>Name</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Returns the meta object for the attribute ' + * {@link org.eclipse.sirius.tests.sample.component.Component#getName + * <em>Name</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @return the meta object for the attribute '<em>Name</em>'. * @see org.eclipse.sirius.tests.sample.component.Component#getName() * @see #getComponent() @@ -151,9 +159,10 @@ public interface ComponentPackage extends EPackage { EAttribute getComponent_Name(); /** - * Returns the meta object for the attribute '{@link org.eclipse.sirius.tests.sample.component.Component#isPayload <em>Payload</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Returns the meta object for the attribute ' + * {@link org.eclipse.sirius.tests.sample.component.Component#isPayload + * <em>Payload</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @return the meta object for the attribute '<em>Payload</em>'. * @see org.eclipse.sirius.tests.sample.component.Component#isPayload() * @see #getComponent() @@ -162,10 +171,12 @@ public interface ComponentPackage extends EPackage { EAttribute getComponent_Payload(); /** - * Returns the meta object for the containment reference list '{@link org.eclipse.sirius.tests.sample.component.Component#getChildren <em>Children</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Children</em>'. + * Returns the meta object for the containment reference list ' + * {@link org.eclipse.sirius.tests.sample.component.Component#getChildren + * <em>Children</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the containment reference list ' + * <em>Children</em>'. * @see org.eclipse.sirius.tests.sample.component.Component#getChildren() * @see #getComponent() * @generated @@ -173,9 +184,10 @@ public interface ComponentPackage extends EPackage { EReference getComponent_Children(); /** - * Returns the meta object for the reference list '{@link org.eclipse.sirius.tests.sample.component.Component#getReferences <em>References</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Returns the meta object for the reference list ' + * {@link org.eclipse.sirius.tests.sample.component.Component#getReferences + * <em>References</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @return the meta object for the reference list '<em>References</em>'. * @see org.eclipse.sirius.tests.sample.component.Component#getReferences() * @see #getComponent() @@ -184,32 +196,47 @@ public interface ComponentPackage extends EPackage { EReference getComponent_References(); /** - * Returns the factory that creates the instances of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Returns the meta object for the reference ' + * {@link org.eclipse.sirius.tests.sample.component.Component#getReference + * <em>Reference</em>}'. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @return the meta object for the reference '<em>Reference</em>'. + * @see org.eclipse.sirius.tests.sample.component.Component#getReference() + * @see #getComponent() + * @generated + */ + EReference getComponent_Reference(); + + /** + * Returns the factory that creates the instances of the model. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * * @return the factory that creates the instances of the model. * @generated */ ComponentFactory getComponentFactory(); /** - * <!-- begin-user-doc --> - * Defines literals for the meta objects that represent + * <!-- begin-user-doc --> Defines literals for the meta objects that + * represent * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each operation of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each operation of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> * </ul> * <!-- end-user-doc --> + * * @generated */ interface Literals { /** - * The meta object literal for the '{@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl <em>Component</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The meta object literal for the ' + * {@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl + * <em>Component</em>}' class. <!-- begin-user-doc --> <!-- end-user-doc + * --> + * * @see org.eclipse.sirius.tests.sample.component.impl.ComponentImpl * @see org.eclipse.sirius.tests.sample.component.impl.ComponentPackageImpl#getComponent() * @generated @@ -217,37 +244,46 @@ public interface ComponentPackage extends EPackage { EClass COMPONENT = eINSTANCE.getComponent(); /** - * The meta object literal for the '<em><b>Name</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The meta object literal for the '<em><b>Name</b></em>' attribute + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ EAttribute COMPONENT__NAME = eINSTANCE.getComponent_Name(); /** - * The meta object literal for the '<em><b>Payload</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The meta object literal for the '<em><b>Payload</b></em>' attribute + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ EAttribute COMPONENT__PAYLOAD = eINSTANCE.getComponent_Payload(); /** - * The meta object literal for the '<em><b>Children</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The meta object literal for the '<em><b>Children</b></em>' + * containment reference list feature. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * * @generated */ EReference COMPONENT__CHILDREN = eINSTANCE.getComponent_Children(); /** - * The meta object literal for the '<em><b>References</b></em>' reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * The meta object literal for the '<em><b>References</b></em>' + * reference list feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ EReference COMPONENT__REFERENCES = eINSTANCE.getComponent_References(); + /** + * The meta object literal for the '<em><b>Reference</b></em>' reference + * feature. <!-- begin-user-doc --> <!-- end-user-doc --> + * + * @generated + */ + EReference COMPONENT__REFERENCE = eINSTANCE.getComponent_Reference(); + } -} //ComponentPackage +} // ComponentPackage diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentFactoryImpl.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentFactoryImpl.java index 4512d858f7..79e379041c 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentFactoryImpl.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentFactoryImpl.java @@ -15,7 +15,9 @@ 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.sirius.tests.sample.component.*; +import org.eclipse.sirius.tests.sample.component.Component; +import org.eclipse.sirius.tests.sample.component.ComponentFactory; +import org.eclipse.sirius.tests.sample.component.ComponentPackage; /** * <!-- begin-user-doc --> @@ -25,28 +27,27 @@ import org.eclipse.sirius.tests.sample.component.*; */ public class ComponentFactoryImpl extends EFactoryImpl implements ComponentFactory { /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Creates the default factory implementation. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * * @generated */ public static ComponentFactory init() { try { - ComponentFactory theComponentFactory = (ComponentFactory)EPackage.Registry.INSTANCE.getEFactory(ComponentPackage.eNS_URI); + ComponentFactory theComponentFactory = (ComponentFactory) EPackage.Registry.INSTANCE.getEFactory(ComponentPackage.eNS_URI); if (theComponentFactory != null) { return theComponentFactory; } - } - catch (Exception exception) { + } catch (Exception exception) { EcorePlugin.INSTANCE.log(exception); } return new ComponentFactoryImpl(); } /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * Creates an instance of the factory. <!-- begin-user-doc --> <!-- + * end-user-doc --> + * * @generated */ public ComponentFactoryImpl() { @@ -54,41 +55,44 @@ public class ComponentFactoryImpl extends EFactoryImpl implements ComponentFacto } /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ @Override public EObject create(EClass eClass) { switch (eClass.getClassifierID()) { - case ComponentPackage.COMPONENT: return createComponent(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + case ComponentPackage.COMPONENT: + return createComponent(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } } /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ + @Override public Component createComponent() { ComponentImpl component = new ComponentImpl(); return component; } /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * <!-- begin-user-doc --> <!-- end-user-doc --> + * * @generated */ + @Override public ComponentPackage getComponentPackage() { - return (ComponentPackage)getEPackage(); + return (ComponentPackage) getEPackage(); } /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> + * <!-- begin-user-doc --> <!-- end-user-doc --> + * * @deprecated * @generated */ diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentImpl.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentImpl.java index 29883ef59f..d30ae15d48 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentImpl.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentImpl.java @@ -38,6 +38,7 @@ import org.eclipse.sirius.tests.sample.component.util.PayloadMarkerAdapter; * <li>{@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl#isPayload <em>Payload</em>}</li> * <li>{@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl#getChildren <em>Children</em>}</li> * <li>{@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl#getReferences <em>References</em>}</li> + * <li>{@link org.eclipse.sirius.tests.sample.component.impl.ComponentImpl#getReference <em>Reference</em>}</li> * </ul> * </p> * @@ -45,113 +46,123 @@ import org.eclipse.sirius.tests.sample.component.util.PayloadMarkerAdapter; */ public class ComponentImpl extends MinimalEObjectImpl.Container implements Component { /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ + * @see #getName() + * @generated + * @ordered + */ protected static final String NAME_EDEFAULT = null; /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #getName() - * @generated - * @ordered - */ + * @see #getName() + * @generated + * @ordered + */ protected String name = NAME_EDEFAULT; /** - * The default value of the '{@link #isPayload() <em>Payload</em>}' attribute. - * <!-- begin-user-doc --> + * The default value of the '{@link #isPayload() <em>Payload</em>}' attribute. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #isPayload() - * @generated - * @ordered - */ + * @see #isPayload() + * @generated + * @ordered + */ protected static final boolean PAYLOAD_EDEFAULT = false; /** - * The cached value of the '{@link #isPayload() <em>Payload</em>}' attribute. - * <!-- begin-user-doc --> + * The cached value of the '{@link #isPayload() <em>Payload</em>}' attribute. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #isPayload() - * @generated - * @ordered - */ + * @see #isPayload() + * @generated + * @ordered + */ protected boolean payload = PAYLOAD_EDEFAULT; /** - * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list. - * <!-- begin-user-doc --> + * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #getChildren() - * @generated - * @ordered - */ + * @see #getChildren() + * @generated + * @ordered + */ protected EList<Component> children; /** - * The cached value of the '{@link #getReferences() <em>References</em>}' reference list. - * <!-- begin-user-doc --> + * The cached value of the '{@link #getReferences() <em>References</em>}' reference list. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #getReferences() - * @generated - * @ordered - */ + * @see #getReferences() + * @generated + * @ordered + */ protected EList<Component> references; /** - * <!-- begin-user-doc --> + * The cached value of the '{@link #getReference() <em>Reference</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getReference() + * @generated + * @ordered + */ + protected Component reference; + + /** + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ protected ComponentImpl() { - super(); - } + super(); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @Override protected EClass eStaticClass() { - return ComponentPackage.Literals.COMPONENT; - } + return ComponentPackage.Literals.COMPONENT; + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public String getName() { - return name; - } + return name; + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, ComponentPackage.COMPONENT__NAME, oldName, name)); - } + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ComponentPackage.COMPONENT__NAME, oldName, name)); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public boolean isPayload() { - return payload; - } + return payload; + } /** * <!-- begin-user-doc --> @@ -201,126 +212,175 @@ public class ComponentImpl extends MinimalEObjectImpl.Container implements Compo } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Component getReference() { + if (reference != null && reference.eIsProxy()) { + InternalEObject oldReference = (InternalEObject)reference; + reference = (Component)eResolveProxy(oldReference); + if (reference != oldReference) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComponentPackage.COMPONENT__REFERENCE, oldReference, reference)); + } + } + return reference; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Component basicGetReference() { + return reference; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setReference(Component newReference) { + Component oldReference = reference; + reference = newReference; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ComponentPackage.COMPONENT__REFERENCE, oldReference, reference)); + } + + /** + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case ComponentPackage.COMPONENT__CHILDREN: - return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); + switch (featureID) { + case ComponentPackage.COMPONENT__CHILDREN: + return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs); } + return super.eInverseRemove(otherEnd, featureID, msgs); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case ComponentPackage.COMPONENT__NAME: - return getName(); - case ComponentPackage.COMPONENT__PAYLOAD: - return isPayload(); - case ComponentPackage.COMPONENT__CHILDREN: - return getChildren(); - case ComponentPackage.COMPONENT__REFERENCES: - return getReferences(); - } - return super.eGet(featureID, resolve, coreType); + switch (featureID) { + case ComponentPackage.COMPONENT__NAME: + return getName(); + case ComponentPackage.COMPONENT__PAYLOAD: + return isPayload(); + case ComponentPackage.COMPONENT__CHILDREN: + return getChildren(); + case ComponentPackage.COMPONENT__REFERENCES: + return getReferences(); + case ComponentPackage.COMPONENT__REFERENCE: + if (resolve) return getReference(); + return basicGetReference(); } + return super.eGet(featureID, resolve, coreType); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { - switch (featureID) { - case ComponentPackage.COMPONENT__NAME: - setName((String)newValue); - return; - case ComponentPackage.COMPONENT__PAYLOAD: - setPayload((Boolean)newValue); - return; - case ComponentPackage.COMPONENT__CHILDREN: - getChildren().clear(); - getChildren().addAll((Collection<? extends Component>)newValue); - return; - case ComponentPackage.COMPONENT__REFERENCES: - getReferences().clear(); - getReferences().addAll((Collection<? extends Component>)newValue); - return; - } - super.eSet(featureID, newValue); + switch (featureID) { + case ComponentPackage.COMPONENT__NAME: + setName((String)newValue); + return; + case ComponentPackage.COMPONENT__PAYLOAD: + setPayload((Boolean)newValue); + return; + case ComponentPackage.COMPONENT__CHILDREN: + getChildren().clear(); + getChildren().addAll((Collection<? extends Component>)newValue); + return; + case ComponentPackage.COMPONENT__REFERENCES: + getReferences().clear(); + getReferences().addAll((Collection<? extends Component>)newValue); + return; + case ComponentPackage.COMPONENT__REFERENCE: + setReference((Component)newValue); + return; } + super.eSet(featureID, newValue); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @Override public void eUnset(int featureID) { - switch (featureID) { - case ComponentPackage.COMPONENT__NAME: - setName(NAME_EDEFAULT); - return; - case ComponentPackage.COMPONENT__PAYLOAD: - setPayload(PAYLOAD_EDEFAULT); - return; - case ComponentPackage.COMPONENT__CHILDREN: - getChildren().clear(); - return; - case ComponentPackage.COMPONENT__REFERENCES: - getReferences().clear(); - return; - } - super.eUnset(featureID); + switch (featureID) { + case ComponentPackage.COMPONENT__NAME: + setName(NAME_EDEFAULT); + return; + case ComponentPackage.COMPONENT__PAYLOAD: + setPayload(PAYLOAD_EDEFAULT); + return; + case ComponentPackage.COMPONENT__CHILDREN: + getChildren().clear(); + return; + case ComponentPackage.COMPONENT__REFERENCES: + getReferences().clear(); + return; + case ComponentPackage.COMPONENT__REFERENCE: + setReference((Component)null); + return; } + super.eUnset(featureID); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @Override public boolean eIsSet(int featureID) { - switch (featureID) { - case ComponentPackage.COMPONENT__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); - case ComponentPackage.COMPONENT__PAYLOAD: - return payload != PAYLOAD_EDEFAULT; - case ComponentPackage.COMPONENT__CHILDREN: - return children != null && !children.isEmpty(); - case ComponentPackage.COMPONENT__REFERENCES: - return references != null && !references.isEmpty(); - } - return super.eIsSet(featureID); + switch (featureID) { + case ComponentPackage.COMPONENT__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case ComponentPackage.COMPONENT__PAYLOAD: + return payload != PAYLOAD_EDEFAULT; + case ComponentPackage.COMPONENT__CHILDREN: + return children != null && !children.isEmpty(); + case ComponentPackage.COMPONENT__REFERENCES: + return references != null && !references.isEmpty(); + case ComponentPackage.COMPONENT__REFERENCE: + return reference != null; } + return super.eIsSet(featureID); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ @Override public String toString() { - if (eIsProxy()) return super.toString(); + if (eIsProxy()) return super.toString(); - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (name: "); - result.append(name); - result.append(", payload: "); - result.append(payload); - result.append(')'); - return result.toString(); - } + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(", payload: "); + result.append(payload); + result.append(')'); + return result.toString(); + } } //ComponentImpl diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentPackageImpl.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentPackageImpl.java index 1adbfc2da1..46525830d3 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentPackageImpl.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/impl/ComponentPackageImpl.java @@ -27,191 +27,202 @@ import org.eclipse.sirius.tests.sample.component.ComponentPackage; */ public class ComponentPackageImpl extends EPackageImpl implements ComponentPackage { /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ private EClass componentEClass = 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 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 --> + * 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 --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#eNS_URI - * @see #init() - * @generated - */ + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.sirius.tests.sample.component.ComponentPackage#eNS_URI + * @see #init() + * @generated + */ private ComponentPackageImpl() { - super(eNS_URI, ComponentFactory.eINSTANCE); - } + super(eNS_URI, ComponentFactory.eINSTANCE); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ private static boolean isInited = false; /** - * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. - * - * <p>This method is used to initialize {@link ComponentPackage#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 --> + * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. + * + * <p>This method is used to initialize {@link ComponentPackage#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() - * @see #initializePackageContents() - * @generated - */ + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ public static ComponentPackage init() { - if (isInited) return (ComponentPackage)EPackage.Registry.INSTANCE.getEPackage(ComponentPackage.eNS_URI); + if (isInited) return (ComponentPackage)EPackage.Registry.INSTANCE.getEPackage(ComponentPackage.eNS_URI); - // Obtain or create and register package - ComponentPackageImpl theComponentPackage = (ComponentPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ComponentPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ComponentPackageImpl()); + // Obtain or create and register package + ComponentPackageImpl theComponentPackage = (ComponentPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ComponentPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ComponentPackageImpl()); - isInited = true; + isInited = true; - // Create package meta-data objects - theComponentPackage.createPackageContents(); + // Create package meta-data objects + theComponentPackage.createPackageContents(); - // Initialize created meta-data - theComponentPackage.initializePackageContents(); + // Initialize created meta-data + theComponentPackage.initializePackageContents(); - // Mark meta-data to indicate it can't be changed - theComponentPackage.freeze(); + // Mark meta-data to indicate it can't be changed + theComponentPackage.freeze(); - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(ComponentPackage.eNS_URI, theComponentPackage); - return theComponentPackage; - } + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(ComponentPackage.eNS_URI, theComponentPackage); + return theComponentPackage; + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public EClass getComponent() { - return componentEClass; - } + return componentEClass; + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public EAttribute getComponent_Name() { - return (EAttribute)componentEClass.getEStructuralFeatures().get(0); - } + return (EAttribute)componentEClass.getEStructuralFeatures().get(0); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public EAttribute getComponent_Payload() { - return (EAttribute)componentEClass.getEStructuralFeatures().get(1); - } + return (EAttribute)componentEClass.getEStructuralFeatures().get(1); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public EReference getComponent_Children() { - return (EReference)componentEClass.getEStructuralFeatures().get(2); - } + return (EReference)componentEClass.getEStructuralFeatures().get(2); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public EReference getComponent_References() { - return (EReference)componentEClass.getEStructuralFeatures().get(3); - } + return (EReference)componentEClass.getEStructuralFeatures().get(3); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getComponent_Reference() { + return (EReference)componentEClass.getEStructuralFeatures().get(4); + } + + /** + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public ComponentFactory getComponentFactory() { - return (ComponentFactory)getEFactoryInstance(); - } + return (ComponentFactory)getEFactoryInstance(); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ private boolean isCreated = false; /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - componentEClass = createEClass(COMPONENT); - createEAttribute(componentEClass, COMPONENT__NAME); - createEAttribute(componentEClass, COMPONENT__PAYLOAD); - createEReference(componentEClass, COMPONENT__CHILDREN); - createEReference(componentEClass, COMPONENT__REFERENCES); - } + if (isCreated) return; + isCreated = true; + + // Create classes and their features + componentEClass = createEClass(COMPONENT); + createEAttribute(componentEClass, COMPONENT__NAME); + createEAttribute(componentEClass, COMPONENT__PAYLOAD); + createEReference(componentEClass, COMPONENT__CHILDREN); + createEReference(componentEClass, COMPONENT__REFERENCES); + createEReference(componentEClass, COMPONENT__REFERENCE); + } /** - * <!-- begin-user-doc --> + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ private boolean isInitialized = false; /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; + if (isInitialized) return; + isInitialized = true; - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); - // Create type parameters + // Create type parameters - // Set bounds for type parameters + // Set bounds for type parameters - // Add supertypes to classes + // Add supertypes to classes - // Initialize classes, features, and operations; add parameters - initEClass(componentEClass, Component.class, "Component", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getComponent_Name(), ecorePackage.getEString(), "name", null, 1, 1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getComponent_Payload(), ecorePackage.getEBoolean(), "payload", null, 1, 1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getComponent_Children(), this.getComponent(), null, "children", null, 0, -1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getComponent_References(), this.getComponent(), null, "references", null, 0, -1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + // Initialize classes, features, and operations; add parameters + initEClass(componentEClass, Component.class, "Component", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getComponent_Name(), ecorePackage.getEString(), "name", null, 1, 1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getComponent_Payload(), ecorePackage.getEBoolean(), "payload", null, 1, 1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getComponent_Children(), this.getComponent(), null, "children", null, 0, -1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getComponent_References(), this.getComponent(), null, "references", null, 0, -1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getComponent_Reference(), this.getComponent(), null, "reference", null, 0, 1, Component.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - // Create resource - createResource(eNS_URI); - } + // Create resource + createResource(eNS_URI); + } } //ComponentPackageImpl diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentAdapterFactory.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentAdapterFactory.java index 183a07fb81..861d1fc950 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentAdapterFactory.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentAdapterFactory.java @@ -26,100 +26,100 @@ import org.eclipse.sirius.tests.sample.component.*; */ public class ComponentAdapterFactory extends AdapterFactoryImpl { /** - * The cached model package. - * <!-- begin-user-doc --> + * The cached model package. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ protected static ComponentPackage modelPackage; /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> + * Creates an instance of the adapter factory. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public ComponentAdapterFactory() { - if (modelPackage == null) { - modelPackage = ComponentPackage.eINSTANCE; - } + if (modelPackage == null) { + modelPackage = ComponentPackage.eINSTANCE; } + } /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> + * Returns whether this factory is applicable for the type of the object. + * <!-- begin-user-doc --> * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ + * @return whether this factory is applicable for the type of the object. + * @generated + */ @Override public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; + if (object == modelPackage) { + return true; } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } /** - * The switch that delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> + * The switch that delegates to the <code>createXXX</code> methods. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ protected ComponentSwitch<Adapter> modelSwitch = new ComponentSwitch<Adapter>() { - @Override - public Adapter caseComponent(Component object) { - return createComponentAdapter(); - } - @Override - public Adapter defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; + @Override + public Adapter caseComponent(Component object) { + return createComponentAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> + * Creates an adapter for the <code>target</code>. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ + * @param target 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); + } /** - * Creates a new adapter for an object of class '{@link org.eclipse.sirius.tests.sample.component.Component <em>Component</em>}'. - * <!-- begin-user-doc --> + * Creates a new adapter for an object of class '{@link org.eclipse.sirius.tests.sample.component.Component <em>Component</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 --> - * @return the new adapter. - * @see org.eclipse.sirius.tests.sample.component.Component - * @generated - */ + * @return the new adapter. + * @see org.eclipse.sirius.tests.sample.component.Component + * @generated + */ public Adapter createComponentAdapter() { - return null; - } + return null; + } /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> + * Creates a new adapter for the default case. + * <!-- begin-user-doc --> * This default implementation returns null. * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ + * @return the new adapter. + * @generated + */ public Adapter createEObjectAdapter() { - return null; - } + return null; + } } //ComponentAdapterFactory diff --git a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentSwitch.java b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentSwitch.java index 30657c3a23..4d74a587c7 100644 --- a/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentSwitch.java +++ b/plugins/org.eclipse.sirius.tests.sample.component/src/org/eclipse/sirius/tests/sample/component/util/ComponentSwitch.java @@ -30,87 +30,87 @@ import org.eclipse.sirius.tests.sample.component.*; */ public class ComponentSwitch<T> extends Switch<T> { /** - * The cached model package - * <!-- begin-user-doc --> + * The cached model package + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ protected static ComponentPackage modelPackage; /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> + * Creates an instance of the switch. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated - */ + * @generated + */ public ComponentSwitch() { - if (modelPackage == null) { - modelPackage = ComponentPackage.eINSTANCE; - } + if (modelPackage == null) { + modelPackage = ComponentPackage.eINSTANCE; } + } /** - * Checks whether this is a switch for the given package. - * <!-- begin-user-doc --> + * Checks whether this is a switch for the given package. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @parameter ePackage the package in question. - * @return whether this is a switch for the given package. - * @generated - */ + * @parameter ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ @Override protected boolean isSwitchFor(EPackage ePackage) { - return ePackage == modelPackage; - } + return ePackage == modelPackage; + } /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> + * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ + * @return the first non-null result returned by a <code>caseXXX</code> call. + * @generated + */ @Override protected T doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case ComponentPackage.COMPONENT: { - Component component = (Component)theEObject; - T result = caseComponent(component); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } + switch (classifierID) { + case ComponentPackage.COMPONENT: { + Component component = (Component)theEObject; + T result = caseComponent(component); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); } + } /** - * Returns the result of interpreting the object as an instance of '<em>Component</em>'. - * <!-- begin-user-doc --> + * Returns the result of interpreting the object as an instance of '<em>Component</em>'. + * <!-- begin-user-doc --> * This implementation returns null; * returning a non-null result will terminate the switch. * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Component</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>Component</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ public T caseComponent(Component object) { - return null; - } + return null; + } /** - * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> + * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. + * <!-- begin-user-doc --> * This implementation returns null; * returning a non-null result will terminate the switch, but this is the last case anyway. * <!-- end-user-doc --> - * @param object 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 - */ + * @param object 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 + */ @Override public T defaultCase(EObject object) { - return null; - } + return null; + } } //ComponentSwitch diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/AirDCrossReferenceAdapter.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/AirDCrossReferenceAdapter.java index 35308cb2dd..a698978289 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/AirDCrossReferenceAdapter.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/AirDCrossReferenceAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 THALES GLOBAL SERVICES. + * Copyright (c) 2013, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,20 +12,9 @@ package org.eclipse.sirius.business.internal.resource; /** * This class overrides CrossReferenceAdapter to have it installed only on the - * AirDResource. + * AirDResource. It should be removed * * @author smonnier - * */ public interface AirDCrossReferenceAdapter { - - /** - * Disable the resolution of the proxy. - */ - void disableResolve(); - - /** - * Enable the resolution of the proxy. - */ - void enableResolve(); } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDCrossReferenceAdapterImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDCrossReferenceAdapterImpl.java index dedf80fd94..0579ac4459 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDCrossReferenceAdapterImpl.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDCrossReferenceAdapterImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 THALES GLOBAL SERVICES. + * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,7 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter; import org.eclipse.sirius.business.api.query.ResourceQuery; import org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter; +import org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter; /** * This class overrides CrossReferenceAdapter to have it installed only on the @@ -22,12 +23,12 @@ import org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter; * * @author smonnier */ -public class AirDCrossReferenceAdapterImpl extends CrossReferenceAdapter implements AirDCrossReferenceAdapter { - boolean resolve = true; +public class AirDCrossReferenceAdapterImpl extends CrossReferenceAdapter implements SiriusCrossReferenceAdapter, AirDCrossReferenceAdapter { + boolean resolveProxy = true; /** - * Overridden to have this {@link AirDCrossReferenceAdapter} installed only - * on aird resource. + * Overridden to have this {@link SiriusCrossReferenceAdapter} installed + * only on aird resource. * * @param notifier * a model element of the ResourceSet @@ -44,39 +45,20 @@ public class AirDCrossReferenceAdapterImpl extends CrossReferenceAdapter impleme } @Override - public boolean isAdapterForType(Object type) { - return type == AirDCrossReferenceAdapter.class; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter#resolve() - */ - @Override protected boolean resolve() { - if (resolve) { + if (resolveProxy) { return super.resolve(); } return false; } - /** - * {@inheritDoc} - * - * @see org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter#disableResolve() - */ - public void disableResolve() { - resolve = false; - + @Override + public void disableResolveProxy() { + resolveProxy = false; } - /** - * {@inheritDoc} - * - * @see org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter#enableResolve() - */ - public void enableResolve() { - resolve = true; + @Override + public void enableResolveProxy() { + resolveProxy = true; } } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDResourceImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDResourceImpl.java index 8c7adcabe7..3e0ab742a6 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDResourceImpl.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/resource/parser/AirDResourceImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 THALES GLOBAL SERVICES. + * Copyright (c) 2008, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,15 +13,14 @@ package org.eclipse.sirius.business.internal.resource.parser; import java.io.IOException; import java.util.Map; +import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.xmi.XMLHelper; import org.eclipse.gmf.runtime.emf.core.resources.GMFResource; -import org.eclipse.sirius.business.api.query.AirDResouceQuery; import org.eclipse.sirius.business.api.session.resource.AirdResource; import org.eclipse.sirius.business.api.session.resource.DResource; import org.eclipse.sirius.business.internal.migration.RepresentationsFileMigrationService; -import org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter; import org.eclipse.sirius.common.tools.DslCommonPlugin; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.tools.api.profiler.SiriusTasksKey; @@ -109,9 +108,11 @@ public class AirDResourceImpl extends GMFResource implements DResource, AirdReso @Override protected void doUnload() { - Option<AirDCrossReferenceAdapter> result = new AirDResouceQuery(this).getAirDCrossReferenceAdapter(); - if (result.some()) { - eAdapters().remove(result.get()); + for (Adapter adapter : eAdapters()) { + if (adapter instanceof AirDCrossReferenceAdapterImpl) { + eAdapters().remove(adapter); + break; + } } super.doUnload(); } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java index 6441852c7d..584f8d94dc 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java @@ -13,6 +13,7 @@ package org.eclipse.sirius.business.internal.session.danalysis; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -37,7 +38,6 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.transaction.RunnableWithResult; import org.eclipse.emf.transaction.Transaction; import org.eclipse.emf.transaction.TransactionalEditingDomain; @@ -47,7 +47,6 @@ import org.eclipse.emf.transaction.util.ValidateEditSupport; import org.eclipse.emf.workspace.IWorkspaceCommandStack; import org.eclipse.emf.workspace.ResourceUndoContext; import org.eclipse.sirius.business.api.componentization.ViewpointRegistry; -import org.eclipse.sirius.business.api.helper.SiriusUtil; import org.eclipse.sirius.business.api.query.DAnalysisQuery; import org.eclipse.sirius.business.api.query.FileQuery; import org.eclipse.sirius.business.api.query.ResourceQuery; @@ -66,9 +65,7 @@ import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSelectorServic import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSession; import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSessionHelper; import org.eclipse.sirius.business.api.session.danalysis.DAnalysisSessionService; -import org.eclipse.sirius.business.internal.migration.resource.ResourceFileExtensionPredicate; import org.eclipse.sirius.business.internal.query.DAnalysisesInternalQuery; -import org.eclipse.sirius.business.internal.resource.AirDCrossReferenceAdapter; import org.eclipse.sirius.business.internal.resource.ResourceModifiedFieldUpdater; import org.eclipse.sirius.business.internal.session.IsModifiedSavingPolicy; import org.eclipse.sirius.business.internal.session.ReloadingPolicyImpl; @@ -81,7 +78,7 @@ import org.eclipse.sirius.common.tools.api.resource.ResourceSetSync.ResourceStat import org.eclipse.sirius.common.tools.api.resource.ResourceSyncClient; import org.eclipse.sirius.common.tools.api.util.ECrossReferenceAdapterWithUnproxyCapability; import org.eclipse.sirius.common.tools.api.util.EqualityHelper; -import org.eclipse.sirius.common.tools.api.util.LazyCrossReferencer; +import org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapter; import org.eclipse.sirius.ecore.extender.business.api.accessor.EcoreMetamodelDescriptor; import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor; import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority; @@ -304,48 +301,22 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements */ protected void disableAndRemoveECrossReferenceAdapters() { ResourceSet resourceSet = getTransactionalEditingDomain().getResourceSet(); - // Disable resolution of proxy for AirDCrossReferenceAdapter of - // session and for semanticCrossReferencer during the closing - Adapter existingAirDCrossReferenceAdapter = EcoreUtil.getExistingAdapter(resourceSet, AirDCrossReferenceAdapter.class); - AirDCrossReferenceAdapter airDCrossReferenceAdapter = null; - if (existingAirDCrossReferenceAdapter instanceof AirDCrossReferenceAdapter) { - airDCrossReferenceAdapter = (AirDCrossReferenceAdapter) existingAirDCrossReferenceAdapter; - airDCrossReferenceAdapter.disableResolve(); - resourceSet.eAdapters().remove(airDCrossReferenceAdapter); - } - if (getSemanticCrossReferencer() instanceof LazyCrossReferencer) { - ((LazyCrossReferencer) getSemanticCrossReferencer()).disableResolve(); - } - // Let's clear the cross referencer if it's still there. - for (final Resource res : getSemanticResources()) { - unregisterResourceInCrossReferencer(res); + + // disable ResolveProxy capability + for (Resource resource : resourceSet.getResources()) { + disableCrossReferencerResolve(resource); + } + + // clear adapters on resourceSet and contained resources + resourceSet.eAdapters().clear(); + for (Resource resource : resourceSet.getResources()) { + resource.eAdapters().clear(); } + for (final DAnalysis analysis : Iterables.filter(allAnalyses(), Predicates.notNull())) { removeAdaptersOnAnalysis(analysis); - Resource analysisResource = analysis.eResource(); - if (analysisResource != null) { - unregisterResourceInCrossReferencer(analysisResource); } } - Iterable<Resource> resources = Lists.newArrayList(resourceSet.getResources()); - for (Resource resource : Iterables.filter(resources, new ResourceFileExtensionPredicate(SiriusUtil.DESCRIPTION_MODEL_EXTENSION, false))) { - unregisterResourceInCrossReferencer(resource); - } - } - - /** - * Enable all ECrossReferencerAdapter adapters before the end of closing. - */ - protected void reenableECrossReferenceAdaptersBeforeEndOfClosing() { - ResourceSet resourceSet = getTransactionalEditingDomain().getResourceSet(); - Adapter existingAirDCrossReferenceAdapter = EcoreUtil.getExistingAdapter(resourceSet, AirDCrossReferenceAdapter.class); - if (existingAirDCrossReferenceAdapter instanceof AirDCrossReferenceAdapter) { - ((AirDCrossReferenceAdapter) existingAirDCrossReferenceAdapter).enableResolve(); - } - if (getSemanticCrossReferencer() instanceof LazyCrossReferencer) { - ((LazyCrossReferencer) getSemanticCrossReferencer()).enableResolve(); - } - } // ******************* // Analyses @@ -684,7 +655,9 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements } unregisterResourceInCrossReferencer(res); if (!isFromPackageRegistry(set, res)) { + disableCrossReferencerResolve(res); res.unload(); + enableCrossReferencerResolve(res); } set.getResources().remove(res); } @@ -912,6 +885,7 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements * * @return the custom saving policy the session should use */ + @Override public SavingPolicy getSavingPolicy() { return savingPolicy != null ? savingPolicy : new IsModifiedSavingPolicy(transactionalEditingDomain); } @@ -1350,7 +1324,6 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements if (semanticResources != null) { semanticResources.clear(); } - reenableECrossReferenceAdaptersBeforeEndOfClosing(); crossReferencer = null; saver.dispose(); @@ -1365,6 +1338,44 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements mainDAnalysis = null; } + /** + * Disable {@link SiriusCrossReferenceAdapter} resolveProxy capability on + * resource and all its contents + * + * @param resource + * the resource + */ + void disableCrossReferencerResolve(Resource resource) { + // Disable resolveProxy for SiriusCrossreferencerAdapter. + // SiriusCrossreferencerAdapter on EObject are also on resource, + // consequently we manage only the resource itself. + for (Iterator<Adapter> iterator = resource.eAdapters().iterator(); iterator.hasNext(); ) { + Adapter next = iterator.next(); + if (next instanceof SiriusCrossReferenceAdapter) { + ((SiriusCrossReferenceAdapter) next).disableResolveProxy(); + } + } + } + + /** + * Enable {@link SiriusCrossReferenceAdapter} resolveProxy capability on + * resource and all its contents + * + * @param resource + * the resource + */ + void enableCrossReferencerResolve(Resource resource) { + // Enable resolveProxy for SiriusCrossreferencerAdapter. + // SiriusCrossreferencerAdapter on EObject are also on resource, + // consequently we manage only the resource itself. + for (Iterator<Adapter> iterator = resource.eAdapters().iterator(); iterator.hasNext(); ) { + Adapter next = iterator.next(); + if (next instanceof SiriusCrossReferenceAdapter) { + ((SiriusCrossReferenceAdapter) next).enableResolveProxy(); + } + } + } + private static void flushOperations(TransactionalEditingDomain ted) { CommandStack commandStack = ted.getCommandStack(); ResourceSet resourceSet = ted.getResourceSet(); diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DanglingRefRemovalTrigger.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DanglingRefRemovalTrigger.java index 98e363ee0e..86434b9cd1 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DanglingRefRemovalTrigger.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DanglingRefRemovalTrigger.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 Obeo. + * Copyright (c) 2014, 2015 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,6 +27,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.sirius.business.api.session.ModelChangeTrigger; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.common.tools.DslCommonPlugin; +import org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl; import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.base.Options; @@ -66,6 +67,7 @@ public class DanglingRefRemovalTrigger implements ModelChangeTrigger { /** * {@inheritDoc} */ + @Override public boolean apply(Notification input) { boolean potentialExplicitDetachment = input.getEventType() == Notification.REMOVE || input.getEventType() == Notification.REMOVE_MANY || input.getEventType() == Notification.UNSET; boolean potentialImplicitDetachment = input.getEventType() == Notification.SET && input.getNewValue() == null; @@ -86,6 +88,7 @@ public class DanglingRefRemovalTrigger implements ModelChangeTrigger { /** * {@inheritDoc} */ + @Override public boolean apply(Notification input) { if (input.getEventType() == Notification.ADD || input.getEventType() == Notification.ADD_MANY || input.getEventType() == Notification.SET) { // The input.getNewValue() check required to make IS_ATTACHMENT @@ -107,6 +110,7 @@ public class DanglingRefRemovalTrigger implements ModelChangeTrigger { /** * {@inheritDoc} */ + @Override public boolean apply(EReference reference) { // We should ignore any EReference which container is a // DSemanticDecorator (or any subclass) @@ -123,6 +127,7 @@ public class DanglingRefRemovalTrigger implements ModelChangeTrigger { /** * {@inheritDoc} */ + @Override public boolean apply(EReference eReference) { // We should ignore View.element reference because not doing // that have the effect to have the EditParts having @@ -147,6 +152,7 @@ public class DanglingRefRemovalTrigger implements ModelChangeTrigger { /** * {@inheritDoc} */ + @Override public boolean apply(EReference eReference) { // ignoring the EPackage.eFactoryInstance reference return EcorePackage.eINSTANCE.getEPackage_EFactoryInstance().equals(eReference); @@ -324,7 +330,7 @@ public class DanglingRefRemovalTrigger implements ModelChangeTrigger { // trigger a second refresh by the // RefreshEditorsPrecommitListener only when the command removed // some dangling reference. - ECrossReferenceAdapter filteredCrossReferencer = new ECrossReferenceAdapter() { + ECrossReferenceAdapter filteredCrossReferencer = new SiriusCrossReferenceAdapterImpl() { @Override public Collection<Setting> getInverseReferences(EObject eObject, boolean resolve) { Collection<Setting> settings = xReferencer.getInverseReferences(eObject, resolve); diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/LocalResourceCollector.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/LocalResourceCollector.java index 93a60e1f4f..34c79b54f7 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/LocalResourceCollector.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/LocalResourceCollector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 THALES GLOBAL SERVICES. + * Copyright (c) 2013, 2015 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,15 +25,15 @@ import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.ECrossReferenceAdapter; import org.eclipse.sirius.business.api.query.ResourceQuery; +import org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl; /** * A {@link IResourceCollector} for local {@link Resource}. * * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a> */ -public class LocalResourceCollector extends ECrossReferenceAdapter implements IResourceCollector { +public class LocalResourceCollector extends SiriusCrossReferenceAdapterImpl implements IResourceCollector { private ResourceSet resourceSet; @@ -106,6 +106,7 @@ public class LocalResourceCollector extends ECrossReferenceAdapter implements IR /** * {@inheritDoc} */ + @Override public Collection<Resource> getAllReferencedResources(Resource resource) { if (!initialized) { resourceSet.eAdapters().add(this); @@ -118,6 +119,7 @@ public class LocalResourceCollector extends ECrossReferenceAdapter implements IR /** * {@inheritDoc} */ + @Override public Collection<Resource> getAllReferencingResources(Resource resource) { if (!initialized) { resourceSet.eAdapters().add(this); @@ -144,6 +146,7 @@ public class LocalResourceCollector extends ECrossReferenceAdapter implements IR /** * {@inheritDoc} */ + @Override public void dispose() { if (initialized) { resourceSet.eAdapters().remove(this); diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesSynchronizer.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesSynchronizer.java index a0be802f98..8a3b4c94c6 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesSynchronizer.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/SessionResourcesSynchronizer.java @@ -192,7 +192,9 @@ public class SessionResourcesSynchronizer implements ResourceSyncClient { RunnableWithResult<?> reload = new RunnableWithResult.Impl<Object>() { @Override public void run() { + session.disableCrossReferencerResolve(resource); resource.unload(); + session.enableCrossReferencerResolve(resource); try { resource.load(Collections.EMPTY_MAP); EcoreUtil.resolveAll(resource); |
