Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-09-28 15:40:12 +0000
committerChristian W. Damus2016-10-28 21:16:38 +0000
commit0d128b68b25bf9c06d7c474bd91445871c21486b (patch)
treebfb946d4fe6aa43024c1d1ce91e6d690dd805b21
parentd074f58115cca11630b8534836fbef3fc9a8d972 (diff)
downloadorg.eclipse.papyrus-0d128b68b25bf9c06d7c474bd91445871c21486b.tar.gz
org.eclipse.papyrus-0d128b68b25bf9c06d7c474bd91445871c21486b.tar.xz
org.eclipse.papyrus-0d128b68b25bf9c06d7c474bd91445871c21486b.zip
Bug 502461: [Copy/Paste] Pasting UML-RT protocol container corrupts the model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=502461 Never copy the Dependency::client reference property of an InterfaceRealization in copy/paste operations. Use the Element Types Framework to set the name of a pasted element when resolving name clashes, to allow for extensible editing behaviour of DSMLs such as UML-RT (for protocol containers). Change-Id: Iddfc4f7f4d5a9a412317f7fbe5db6a6ac7563be7
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml1
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/schema/copier.exsd124
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/ICopierFactory.java122
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierConfiguratorRegistry.java155
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierFactory.java98
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfiguration.java73
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfigurator.java100
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java6
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml13
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/RenameElementCommand.java46
-rwxr-xr-xtests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.classpath2
-rwxr-xr-xtests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.settings/org.eclipse.jdt.core.prefs6
-rwxr-xr-xtests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/ClipboardTests.launch86
-rwxr-xr-xtests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/META-INF/MANIFEST.MF10
-rw-r--r--[-rwxr-xr-x]tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/build.properties15
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/plugin.xml23
-rwxr-xr-xtests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/pom.xml2
-rw-r--r--[-rwxr-xr-x]tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java10
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/CopierFactoryTest.java185
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.classpath2
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF6
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/org.eclipse.papyrus.uml.tools.tests.launch2
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/pom.xml2
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml7
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/AllTests.java3
-rw-r--r--tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java93
31 files changed, 1136 insertions, 77 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
index c8635206ed3..be0b3be7e36 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF
@@ -3,6 +3,7 @@ Export-Package: org.eclipse.papyrus.infra.core,
org.eclipse.papyrus.infra.core.clipboard,
org.eclipse.papyrus.infra.core.editor,
org.eclipse.papyrus.infra.core.extension,
+ org.eclipse.papyrus.infra.core.internal.clipboard;x-internal:=true,
org.eclipse.papyrus.infra.core.internal.expressions;x-internal:=true,
org.eclipse.papyrus.infra.core.internal.language;x-friends:="org.eclipse.papyrus.infra.emf",
org.eclipse.papyrus.infra.core.internal.sashmodel;x-internal:=true,
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
index 5002ac0231a..91659babdf6 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
@@ -7,6 +7,7 @@
<extension-point id="transactionalEditingDomainProvider" name="transactionalEditingDomainProvider" schema="schema/transactionalEditingDomainProvider.exsd"/>
<extension-point id="sashModelProvider" name="Sash Model Providers" schema="schema/sashModelProvider.exsd"/>
<extension-point id="language" name="Modeling Language" schema="schema/language.exsd"/>
+ <extension-point id="copier" name="Clipboard Copier Configuration" schema="schema/copier.exsd"/>
<extension
point="org.eclipse.papyrus.infra.core.model">
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/copier.exsd b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/copier.exsd
new file mode 100644
index 00000000000..4077183f11e
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/schema/copier.exsd
@@ -0,0 +1,124 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.core" id="copier" name="Clipboard Copier Configuration"/>
+ </appInfo>
+ <documentation>
+ Registers configuration parameters for the EMF copiers use by the clipboard
+infrastructure in Papyrus for copy/paste operations.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="factoryConfiguration" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="factoryConfiguration">
+ <annotation>
+ <documentation>
+ Configuration parameters for the copier factory.
+ </documentation>
+ </annotation>
+ <complexType>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="referenceFilter"/>
+ </choice>
+ <attribute name="configurator" type="string">
+ <annotation>
+ <documentation>
+ Identifies a class implementing the &lt;tt&gt;ICopierFactory.Configurator&lt;/tt&gt; protocol for copier factory configuration. If omitted, then a default configurator is used that reads configuration parameters from nested elements. In that case, at least some nested content is required.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.core.clipboard.ICopierFactory$Configurator"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="referenceFilter">
+ <annotation>
+ <documentation>
+ Declares a reference filter configuration rule. Used with the implicit configurator.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="referenceURI" type="string" use="required">
+ <annotation>
+ <documentation>
+ Ecore URI of the reference to filter in copy operations.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="ownerTypeURI" type="string">
+ <annotation>
+ <documentation>
+ Ecore URI of the EClass of reference owner (object) to which to apply the reference filter. If omitted, then the reference is filtered for all instance of its defining EClass.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ Papyrus Oxygen
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2016 Christian W. Damus 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
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/ICopierFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/ICopierFactory.java
new file mode 100644
index 00000000000..40b8a40e22f
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/ICopierFactory.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.clipboard;
+
+import java.util.function.BiPredicate;
+import java.util.function.Supplier;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
+import org.eclipse.papyrus.infra.core.internal.clipboard.CopierFactory;
+
+/**
+ * An extensible factory for EMF {@link Copier}s used for copy/paste
+ * operations in Papyrus. Extensions are registered on the
+ * {@code org.eclipse.papyrus.infra.core.copier} extension point.
+ *
+ * @since 2.2
+ *
+ * @see EcoreUtil.Copier
+ */
+@FunctionalInterface
+public interface ICopierFactory extends Supplier<EcoreUtil.Copier> {
+
+ /**
+ * Obtains a copier factory suitable for most copy/paste operations.
+ * The result is configured from the extension point.
+ *
+ * @return a copier factory
+ */
+ static ICopierFactory getInstance() {
+ return CopierFactory.DEFAULT;
+ }
+
+ /**
+ * Obtains a copier factory with the option of not using original references.
+ * The result is configured from the extension point.
+ *
+ * @param useOriginalReferences
+ * whether non-copied references should be used while copying
+ *
+ * @return a copier factory
+ */
+ static ICopierFactory getInstance(boolean useOriginalReferences) {
+ return new CopierFactory(useOriginalReferences);
+ }
+
+ //
+ // Nested types
+ //
+
+ /**
+ * Configuration protocol for the {@linkplain ICopierFactory copier factory}
+ * that {@link Configurator} extensions use to tweak the behaviour of
+ * the copiers that it creates.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ *
+ * @since 2.2
+ */
+ interface Configuration {
+ /**
+ * Queries whether the copier to be configured resolves references
+ * in its copying. {@link Configurator}s may need to know this to determine
+ * how to configure it.
+ *
+ * @return whether the copier resolves references
+ */
+ boolean isResolveReferences();
+
+ /**
+ * Queries whether the copier to be configured uses original references
+ * in its copying. {@link Configurator}s may need to know this to determine
+ * how to configure it.
+ *
+ * @return whether the copier uses original references
+ */
+ boolean isUseOriginalReferences();
+
+ /**
+ * Adds a filter matching references that should not be copied for
+ * select objects.
+ *
+ * @param filter
+ * a filter that matches some reference for some object
+ * that should not have that reference copied
+ */
+ void filterReferences(BiPredicate<? super EReference, ? super EObject> filter);
+ }
+
+ /**
+ * Extension protocol for the {@linkplain ICopierFactory copier factory}
+ * that allows plug-ins to customize the behaviour of the copiers that it creates.
+ * Instances are registered on the {@code org.eclipse.papyrus.infra.core.copier}
+ * extension point.
+ *
+ * @since 2.2
+ */
+ @FunctionalInterface
+ interface Configurator {
+ /**
+ * Installs configurations for the copier factory.
+ *
+ * @param copierConfiguration
+ * the configuration to update
+ */
+ void configureCopier(Configuration copierConfiguration);
+ }
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierConfiguratorRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierConfiguratorRegistry.java
new file mode 100644
index 00000000000..4c73988f4cd
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierConfiguratorRegistry.java
@@ -0,0 +1,155 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.internal.clipboard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.function.Predicate;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.emf.ecore.plugin.RegistryReader;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory.Configuration;
+
+/**
+ * Registry of configurator extensions on the
+ * {@code org.eclipse.papyrus.infra.core.copier} point.
+ */
+class CopierConfiguratorRegistry implements ICopierFactory.Configurator {
+
+ private static final String EXT_PT = "copier"; //$NON-NLS-1$
+
+ static CopierConfiguratorRegistry INSTANCE = new CopierConfiguratorRegistry();
+
+ private final Collection<ICopierFactory.Configurator> configurators;
+
+ private CopierConfiguratorRegistry() {
+ super();
+
+ configurators = new Reader(Platform.getExtensionRegistry(), Activator.PLUGIN_ID, EXT_PT).load();
+ }
+
+ @Override
+ public void configureCopier(ICopierFactory.Configuration copierConfiguration) {
+ configurators.forEach(c -> c.configureCopier(copierConfiguration));
+ }
+
+ //
+ // Nested types
+ //
+
+ private static class Reader extends RegistryReader {
+
+ private static final String FACTORY_CONFIGURATION = "factoryConfiguration"; //$NON-NLS-1$
+ private static final String CONFIGURATOR = "configurator"; //$NON-NLS-1$
+
+ private Collection<ICopierFactory.Configurator> configurators;
+ private ICopierFactory.Configurator currentConfigurator;
+
+ // Not really a predicate, but it is a boolean-valued function
+ private Predicate<IConfigurationElement> configurationReader;
+
+ Reader(IExtensionRegistry pluginRegistry, String pluginID, String extensionPointID) {
+ super(pluginRegistry, pluginID, extensionPointID);
+ }
+
+ Collection<ICopierFactory.Configurator> load() {
+ Collection<ICopierFactory.Configurator> result = new ArrayList<>();
+ configurators = result;
+
+ try {
+ readRegistry();
+ } finally {
+ configurators = null;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected boolean readElement(IConfigurationElement element) {
+ boolean result = false;
+
+ if (FACTORY_CONFIGURATION.equals(element.getName())) {
+ result = true;
+
+ if (element.getAttribute(CONFIGURATOR) != null) {
+ // Custom configurator
+ currentConfigurator = new ConfiguratorDescriptor(element);
+ configurationReader = null;
+ } else {
+ // Default configurator
+ DefaultConfigurator configurator = new DefaultConfigurator();
+ currentConfigurator = configurator;
+ configurationReader = configurator::readElement;
+ }
+
+ configurators.add(currentConfigurator);
+ } else if (currentConfigurator != null) {
+ if (configurationReader != null) {
+ result = configurationReader.test(element);
+ } else {
+ // Accept anything (who knows what a custom configurator may need?)
+ result = true;
+ }
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ private class ConfiguratorDescriptor extends PluginClassDescriptor implements ICopierFactory.Configurator {
+
+ private Optional<ICopierFactory.Configurator> resolved;
+
+ ConfiguratorDescriptor(IConfigurationElement element) {
+ super(element, CONFIGURATOR);
+ }
+
+ @Override
+ public void configureCopier(Configuration copierConfiguration) {
+ resolve().ifPresent(c -> c.configureCopier(copierConfiguration));
+ }
+
+ Optional<ICopierFactory.Configurator> resolve() {
+ if (resolved == null) {
+ ICopierFactory.Configurator delegate = null;
+
+ try {
+ delegate = (ICopierFactory.Configurator) createInstance();
+ } catch (ClassCastException e) {
+ Activator.log.warn("Not an ICopierFactory.Configurator extension in " + element.getContributor().getName()); //$NON-NLS-1$
+ } catch (WrappedException e) {
+ Activator.log.log(((CoreException) e.exception()).getStatus());
+ } catch (Exception e) {
+ Activator.log.error("Unhandled exception creating copier factory configurator extension in " + element.getContributor().getName(), e); //$NON-NLS-1$
+ }
+
+ resolved = Optional.ofNullable(delegate);
+ }
+
+ return resolved;
+ }
+ }
+ }
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierFactory.java
new file mode 100644
index 00000000000..6921d99520e
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/CopierFactory.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.internal.clipboard;
+
+import java.util.function.BiPredicate;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
+
+/**
+ * A factory that creates copiers for the Papyrus Clipboard.
+ */
+public class CopierFactory implements ICopierFactory {
+
+ private final boolean useOriginalReferences;
+
+ /**
+ * The default copier factory that provides the usual EMF
+ * copying semantics, except with filtering of references
+ * as directed by {@linkplain #registerReferenceFilter(BiPredicate) registered filters}.
+ */
+ public static CopierFactory DEFAULT = new CopierFactory(true);
+
+ /**
+ * Initializes me.
+ *
+ * @param useOriginalReferences
+ * whether non-copied references should be used while copying
+ */
+ public CopierFactory(boolean useOriginalReferences) {
+ super();
+
+ this.useOriginalReferences = useOriginalReferences;
+ }
+
+ /**
+ * Queries whether non-copied references should be used while copying.
+ *
+ * @return whether to use non-copied references
+ */
+ public boolean isUseOriginalReferences() {
+ return useOriginalReferences;
+ }
+
+ @Override
+ public Copier get() {
+ DefaultConfiguration configuration = new DefaultConfiguration(true, isUseOriginalReferences());
+ CopierConfiguratorRegistry.INSTANCE.configureCopier(configuration);
+
+ return createCopier(configuration);
+ }
+
+ private Copier createCopier(DefaultConfiguration configuration) {
+ return configuration.isEmpty()
+ ? createBasicCopier()
+ : new ConfiguredCopier(configuration);
+ }
+
+ private Copier createBasicCopier() {
+ return new Copier(true, isUseOriginalReferences());
+ }
+
+ //
+ // Nested types
+ //
+
+ private static class ConfiguredCopier extends Copier {
+ private static final long serialVersionUID = 1L;
+
+ private final DefaultConfiguration configuration;
+
+ ConfiguredCopier(DefaultConfiguration configuration) {
+ super(configuration.isResolveReferences(), configuration.isUseOriginalReferences());
+
+ this.configuration = configuration;
+ }
+
+ @Override
+ protected void copyReference(EReference eReference, EObject eObject, EObject copyEObject) {
+ if (configuration.shouldCopyReference(eReference, eObject)) {
+ super.copyReference(eReference, eObject, copyEObject);
+ }
+ }
+ }
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfiguration.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfiguration.java
new file mode 100644
index 00000000000..1a1e49b4d35
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfiguration.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.internal.clipboard;
+
+import java.util.function.BiPredicate;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
+
+/**
+ * Default implementation of the copier configuration protocol.
+ */
+class DefaultConfiguration implements ICopierFactory.Configuration {
+
+ private final boolean resolveReferences;
+ private final boolean useOriginalReferences;
+
+ private BiPredicate<EReference, EObject> referenceFilter;
+
+ DefaultConfiguration(boolean resolveReferences, boolean useOriginalReferences) {
+ super();
+
+ this.resolveReferences = resolveReferences;
+ this.useOriginalReferences = useOriginalReferences;
+ }
+
+ @Override
+ public boolean isResolveReferences() {
+ return resolveReferences;
+ }
+
+ @Override
+ public boolean isUseOriginalReferences() {
+ return useOriginalReferences;
+ }
+
+ /**
+ * Queries whether I am an empty configuration.
+ *
+ * @return whether I have no copier configuration rules
+ */
+ boolean isEmpty() {
+ return referenceFilter == null;
+ }
+
+ @Override
+ public void filterReferences(BiPredicate<? super EReference, ? super EObject> filter) {
+ if (referenceFilter == null) {
+ // We will only use it for these specific inputs
+ @SuppressWarnings("unchecked")
+ BiPredicate<EReference, EObject> filter_ = (BiPredicate<EReference, EObject>) filter;
+ referenceFilter = filter_;
+ } else {
+ referenceFilter = referenceFilter.or(filter);
+ }
+ }
+
+ boolean shouldCopyReference(EReference reference, EObject owner) {
+ return (referenceFilter == null) || !referenceFilter.test(reference, owner);
+ }
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfigurator.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfigurator.java
new file mode 100644
index 00000000000..4dae675ce24
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/internal/clipboard/DefaultConfigurator.java
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.internal.clipboard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory.Configuration;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory.Configurator;
+
+import com.google.common.base.Strings;
+
+/**
+ * Default configurator that reads configuration rules from the extension point.
+ */
+class DefaultConfigurator implements Configurator {
+
+ private static final String REFERENCE_FILTER = "referenceFilter"; //$NON-NLS-1$
+ private static final String REFERENCE_URI = "referenceURI"; //$NON-NLS-1$
+ private static final String OWNER_TYPE_URI = "ownerTypeURI"; //$NON-NLS-1$
+
+ private final Collection<ICopierFactory.Configurator> configurationRules = new ArrayList<>();
+
+ /**
+ * Initializes me.
+ */
+ public DefaultConfigurator() {
+ super();
+ }
+
+ @Override
+ public void configureCopier(Configuration copierConfiguration) {
+ configurationRules.forEach(rule -> rule.configureCopier(copierConfiguration));
+ }
+
+ boolean readElement(IConfigurationElement element) {
+ boolean result = false;
+
+ if (REFERENCE_FILTER.equals(element.getName())) {
+ String referenceURI = element.getAttribute(REFERENCE_URI);
+ if (!Strings.isNullOrEmpty(referenceURI)) {
+ result = true;
+ String ownerTypeURI = element.getAttribute(OWNER_TYPE_URI);
+
+ try {
+ configurationRules.add(referenceFilter(referenceURI, ownerTypeURI));
+ } catch (Exception e) {
+ Activator.log.warn(String.format("Invalid fopier reference filter extension in %s: %s", //$NON-NLS-1$
+ element.getContributor().getName(), e.getMessage()));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private <T extends EModelElement> Optional<T> getEcoreElement(String uriString, Class<T> metaclass) {
+ EObject result = null;
+ URI uri = URI.createURI(uriString, true);
+
+ EPackage epackage = EPackage.Registry.INSTANCE.getEPackage(uri.trimFragment().toString());
+ if (epackage != null) {
+ result = epackage.eResource().getEObject(uri.fragment());
+ }
+
+ return Optional.ofNullable(result).map(metaclass::cast);
+ }
+
+ private ICopierFactory.Configurator referenceFilter(String referenceURI, String ownerTypeURI) {
+ EReference reference = getEcoreElement(referenceURI, EReference.class).orElseThrow(
+ () -> new IllegalArgumentException("missing or invalid reference URI")); //$NON-NLS-1$
+
+ EClass ownerType = getEcoreElement(ownerTypeURI, EClass.class)
+ .orElse(reference.getEContainingClass());
+
+ return config -> config.filterReferences(
+ (ref, owner) -> (ref == reference) && ownerType.isInstance(owner));
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index 3d174ab26b1..ddf6a8377e7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -67,7 +67,8 @@ Require-Bundle: org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)",
org.eclipse.papyrus.infra.sync;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.services.edit.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf.gmf,
- org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java
index 6703095a1a1..bf233a978e0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultCopyCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 502461
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.commands;
@@ -19,6 +20,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AbstractOverrideableCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PastePreferencesPage;
@@ -47,8 +49,8 @@ public class DefaultCopyCommand extends AbstractOverrideableCommand implements N
public DefaultCopyCommand(EditingDomain domain, PapyrusClipboard papyrusClipboard, Collection<EObject> pObjectsToPutInClipboard) {
super(domain);
objectsToPutInClipboard = new ArrayList<Object>();
- Boolean keepReferences = Activator.getInstance().getPreferenceStore().getBoolean(PastePreferencesPage.KEEP_EXTERNAL_REFERENCES);
- EcoreUtil.Copier copier = new EcoreUtil.Copier(Boolean.TRUE, keepReferences);
+ boolean keepReferences = Activator.getInstance().getPreferenceStore().getBoolean(PastePreferencesPage.KEEP_EXTERNAL_REFERENCES);
+ EcoreUtil.Copier copier = ICopierFactory.getInstance(keepReferences).get();
copier.copyAll(pObjectsToPutInClipboard);
copier.copyReferences();
papyrusClipboard.addAllInternalCopyInClipboard(copier);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
index d07f91911f3..81f10822c27 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 502461
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.commands;
@@ -27,6 +28,7 @@ import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
@@ -69,7 +71,7 @@ public class DefaultPasteCommand extends AbstractCommand {
List<EObject> rootElementToPaste = EcoreUtil.filterDescendants(eobjectsTopaste);
// Copy all eObjects (inspired from PasteFromClipboardCommand)
- EcoreUtil.Copier copier = new EcoreUtil.Copier();
+ EcoreUtil.Copier copier = ICopierFactory.getInstance().get();
copier.copyAll(rootElementToPaste);
copier.copyReferences();
Map<EObject, EObject> duplicatedObjects = new HashMap<EObject, EObject>();
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF
index 837f193fc46..87c71939cfd 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)";visibility:=
org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)";visibility:=reexport,
org.eclipse.papyrus.uml.extensionpoints;bundle-version="[1.2.0,2.0.0)",
org.eclipse.uml2.uml.validation;bundle-version="[5.0.0,6.0.0)",
- org.eclipse.papyrus.infra.services.edit.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport
+ org.eclipse.papyrus.infra.services.edit.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)"
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
Bundle-Version: 3.0.0.qualifier
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml
index 81b8241c2a1..df932881279 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/plugin.xml
@@ -99,4 +99,17 @@
</language>
</provider>
</extension>
+
+ <extension
+ point="org.eclipse.papyrus.infra.core.copier">
+
+ <factoryConfiguration>
+ <!-- In InterfaceRealizations, the client is a derived subset of the owner.
+ cf. http://eclip.se/502461 -->
+ <referenceFilter
+ referenceURI="http://www.eclipse.org/uml2/5.0.0/UML#//Dependency/client"
+ ownerTypeURI="http://www.eclipse.org/uml2/5.0.0/UML#//InterfaceRealization">
+ </referenceFilter>
+ </factoryConfiguration>
+ </extension>
</plugin>
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/RenameElementCommand.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/RenameElementCommand.java
index ee760f9c3e5..968479a39d1 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/RenameElementCommand.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/RenameElementCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,21 +8,32 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 502461
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.commands;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.tools.Activator;
import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* A Command to apply a rename on a UML Element
*/
public class RenameElementCommand extends RecordingCommand {
- private NamedElement element;
+ private final TransactionalEditingDomain domain;
- private String name;
+ private final NamedElement element;
+
+ private final String name;
/**
*
@@ -35,6 +46,8 @@ public class RenameElementCommand extends RecordingCommand {
*/
public RenameElementCommand(TransactionalEditingDomain domain, NamedElement namedElement, String name) {
super(domain);
+
+ this.domain = domain;
this.element = namedElement;
this.name = name;
}
@@ -42,7 +55,32 @@ public class RenameElementCommand extends RecordingCommand {
@Override
protected void doExecute() {
- element.setName(name);
+ ICommand rename = null;
+
+ // Try first to use the element edit service
+ IElementEditService edit = ElementEditServiceUtils.getCommandProvider(element);
+ if (edit != null) {
+ rename = edit.getEditCommand(new SetRequest(domain, element, UMLPackage.Literals.NAMED_ELEMENT__NAME, name));
+ }
+
+ try {
+ if ((rename != null) && rename.canExecute()) {
+ try {
+ rename.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ // Plan B
+ element.setName(name);
+ Activator.log.error(e);
+ }
+ } else {
+ // Plan B
+ element.setName(name);
+ }
+ } finally {
+ if (rename != null) {
+ rename.dispose();
+ }
+ }
}
}
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.classpath b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.classpath
index 098194ca4b7..eca7bdba8f0 100755
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.classpath
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.settings/org.eclipse.jdt.core.prefs
index f08be2b06c4..b3aa6d60f94 100755
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/ClipboardTests.launch b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/ClipboardTests.launch
index 249fc785cf3..a2ba00d6405 100755
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/ClipboardTests.launch
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/ClipboardTests.launch
@@ -1,43 +1,43 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="askclear" value="false"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="true"/>
-<booleanAttribute key="clearws" value="true"/>
-<booleanAttribute key="clearwslog" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
-<booleanAttribute key="default" value="true"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
-<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.infra.core.clipboard.tests.AllTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.infra.core.clipboard.tests"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.7 -Xms1024m -Xmx4096m"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<stringAttribute key="product" value="org.eclipse.platform.ide"/>
-<booleanAttribute key="run_in_ui_thread" value="true"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useCustomFeatures" value="false"/>
-<booleanAttribute key="useDefaultConfig" value="true"/>
-<booleanAttribute key="useDefaultConfigArea" value="false"/>
-<booleanAttribute key="useProduct" value="true"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.infra.core.clipboard.tests.AllTests"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.infra.core.clipboard.tests"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.7 -Xms1024m -Xmx4096m"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.platform.ide"/>
+<booleanAttribute key="run_in_ui_thread" value="true"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="true"/>
+</launchConfiguration>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/META-INF/MANIFEST.MF
index 38cd134d1a5..fa829adba86 100755
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/META-INF/MANIFEST.MF
@@ -2,14 +2,16 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui;bundle-version="3.107.0",
org.eclipse.core.runtime;bundle-version="3.11.0",
org.junit,
- org.eclipse.papyrus.junit.framework;bundle-version="1.2.0"
+ org.eclipse.papyrus.junit.framework;bundle-version="1.2.0",
+ org.eclipse.papyrus.junit.utils;bundle-version="2.0.100",
+ org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)"
Export-Package: org.eclipse.papyrus.infra.core.clipboard.tests
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Localization: plugin
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.core.clipboard.tests.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.infra.core.clipboard.tests
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-SymbolicName: org.eclipse.papyrus.infra.core.clipboard.tests;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/build.properties b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/build.properties
index cdd2db7f1f5..f4bd95dd18e 100755..100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/build.properties
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/build.properties
@@ -1,7 +1,20 @@
+#
+# Copyright (c) 2015, 2016 CEA LIST, Christian W. Damus, 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:
+# CEA List - Initial API and implementation
+# Christian W. Damus - bug 502461
+#
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
- plugin.properties
+ plugin.properties,\
+ plugin.xml
src.includes = about.html
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/plugin.xml b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/plugin.xml
new file mode 100644
index 00000000000..499607a6c58
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/plugin.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2016 Christian W. Damus 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:
+ Christian W. Damus - Initial API and implementation
+
+-->
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.core.copier">
+ <factoryConfiguration
+ configurator="org.eclipse.papyrus.infra.core.clipboard.tests.CopierFactoryTest$TestConfigurator">
+ </factoryConfiguration>
+ </extension>
+
+</plugin>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/pom.xml b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/pom.xml
index fa5e4f1c7dd..e8fadb2e6c4 100755
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/pom.xml
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/pom.xml
@@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse.papyrus</groupId>
<artifactId>org.eclipse.papyrus.infra.core.clipboard.tests</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java
index b5fe031d9b6..1a6091a0012 100755..100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/AllTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
+ * Copyright (c) 2015, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,16 +8,20 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 502461
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.clipboard.tests;
-import org.junit.runner.RunWith;
+
import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite;
+import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(ClassificationSuite.class)
@SuiteClasses({
- ClipboardTests.class })
+ ClipboardTests.class,
+ CopierFactoryTest.class,
+})
public class AllTests {
// JUnit 4 test suite
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/CopierFactoryTest.java b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/CopierFactoryTest.java
new file mode 100644
index 00000000000..f0ff2164a9b
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.infra.core.clipboard.tests/src/org/eclipse/papyrus/infra/core/clipboard/tests/CopierFactoryTest.java
@@ -0,0 +1,185 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.clipboard.tests;
+
+import static org.eclipse.papyrus.junit.matchers.MoreMatchers.greaterThan;
+import static org.eclipse.papyrus.junit.matchers.MoreMatchers.isEmpty;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory.Configuration;
+import org.eclipse.papyrus.infra.core.internal.clipboard.CopierFactory;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/**
+ * Test cases for the {@link CopierFactory} class.
+ */
+@SuppressWarnings("restriction")
+public class CopierFactoryTest {
+
+ @Rule
+ public final TestRule configRule = TestConfigurator.rule();
+
+ /**
+ * Initializes me.
+ */
+ public CopierFactoryTest() {
+ super();
+ }
+
+ /**
+ * Tests the factory with the default copy behaviour.
+ */
+ @Test
+ public void defaultCopierFactory() {
+ EClass original = createTestModel();
+
+ EcoreUtil.Copier copier = ICopierFactory.getInstance().get();
+ EClass copy = copy(original, copier);
+
+ // Check that we have the copy we expect
+ assertThat(copy, not(sameInstance(original)));
+ assertThat(copy.getName(), is(original.getName()));
+ assertThat(copy.getEReferences().size(), is(2));
+
+ // And that the correct filtering was applied
+ copy.getEReferences().forEach(ref -> assertThat(ref.getEOpposite(), nullValue()));
+
+ // Not this
+ assertThat(copy.getEReferences().stream().flatMap(ref -> ref.getEAnnotations().stream())
+ .peek(a -> assertThat(a.getReferences(), not(isEmpty())))
+ .count(), greaterThan(0L)); // In fact we have tested at least one
+ }
+
+ /**
+ * Tests the factory with non-default copy behaviour to verify that
+ * configurators see the correct options in in the configuration.
+ */
+ @Test
+ public void oneOffCopierFactory() {
+ EClass original = createTestModel();
+
+ EcoreUtil.Copier copier = ICopierFactory.getInstance(false).get();
+ EClass copy = copy(original, copier);
+
+ // Check that we have the copy we expect
+ assertThat(copy, not(sameInstance(original)));
+ assertThat(copy.getName(), is(original.getName()));
+ assertThat(copy.getEReferences().size(), is(2));
+
+ // And that the correct filtering was applied
+ assertThat(copy.getEReferences().stream().flatMap(ref -> ref.getEAnnotations().stream())
+ .peek(a -> assertThat(a.getReferences(), isEmpty()))
+ .count(), greaterThan(0L)); // In fact we have tested at least one
+
+ // Not this
+ copy.getEReferences().forEach(ref -> assertThat(ref.getEOpposite(), notNullValue()));
+ }
+
+ //
+ // Test framework
+ //
+
+ EClass createTestModel() {
+ EClass result = EcoreFactory.eINSTANCE.createEClass();
+ result.setName("Test");
+
+ EReference r1 = EcoreFactory.eINSTANCE.createEReference();
+ r1.setName("r1");
+ result.getEStructuralFeatures().add(r1);
+
+ EReference r2 = EcoreFactory.eINSTANCE.createEReference();
+ r2.setName("r2");
+ result.getEStructuralFeatures().add(r2);
+
+ r2.setEOpposite(r1);
+ r1.setEOpposite(r2);
+
+ EOperation o1 = EcoreFactory.eINSTANCE.createEOperation();
+ o1.setName("o1");
+ result.getEOperations().add(o1);
+
+ EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ annotation.setSource("test");
+ r1.getEAnnotations().add(annotation);
+ annotation.getReferences().add(o1);
+
+ return result;
+ }
+
+ <T extends EObject> T copy(T original, EcoreUtil.Copier copier) {
+ @SuppressWarnings("unchecked")
+ T result = (T) copier.copy(original);
+ copier.copyReferences();
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ public static final class TestConfigurator implements ICopierFactory.Configurator {
+ static boolean isEnabled;
+
+ @Override
+ public void configureCopier(Configuration copierConfiguration) {
+ if (isEnabled) {
+ if (copierConfiguration.isUseOriginalReferences()) {
+ filter(copierConfiguration, EcorePackage.Literals.EREFERENCE__EOPPOSITE);
+ } else {
+ filter(copierConfiguration, EcorePackage.Literals.EANNOTATION__REFERENCES);
+ }
+ }
+ }
+
+ void filter(Configuration copierConfig, EReference reference, EClass ownerType) {
+ copierConfig.filterReferences((ref, owner) -> (ref == reference) && ownerType.isInstance(owner));
+ }
+
+ void filter(Configuration copierConfig, EReference reference) {
+ filter(copierConfig, reference, reference.getEContainingClass());
+ }
+
+ static TestRule rule() {
+ return new TestWatcher() {
+ @Override
+ protected void starting(Description description) {
+ isEnabled = true;
+ }
+
+ @Override
+ protected void finished(Description description) {
+ isEnabled = false;
+ }
+ };
+ }
+ }
+}
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.classpath b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.classpath
index ad32c83a788..eca7bdba8f0 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.classpath
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.settings/org.eclipse.jdt.core.prefs
index 410244d65a6..62a08f4494d 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
index a2ae1b2b2d3..af8a757c063 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="3.0.0",
org.eclipse.emf.ecore;bundle-version="2.8.0",
org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
@@ -22,9 +22,9 @@ Export-Package: org.eclipse.papyrus.uml.tools.tests,
org.eclipse.papyrus.uml.tools.tests.tests
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Name: UML Tools Tests
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.uml.tools.tests.Activator
Bundle-SymbolicName: org.eclipse.papyrus.uml.tools.tests;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/org.eclipse.papyrus.uml.tools.tests.launch b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/org.eclipse.papyrus.uml.tools.tests.launch
index dbeb06cc93e..0da04582bf4 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/org.eclipse.papyrus.uml.tools.tests.launch
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/org.eclipse.papyrus.uml.tools.tests.launch
@@ -17,7 +17,7 @@
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../junit-umltools-workspace"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/AllTests.java"/>
</listAttribute>
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/pom.xml b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/pom.xml
index 2c06c60c384..1294be2f6f6 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/pom.xml
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/pom.xml
@@ -10,6 +10,6 @@
</parent>
<groupId>org.eclipse.papyrus</groupId>
<artifactId>org.eclipse.papyrus.uml.tools.tests</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml
new file mode 100644
index 00000000000..05188ff7ec1
--- /dev/null
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Package xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_Oo_lEJ1CEeaVooFvMLWt7w" name="copy" URI="http://www.eclipse.org/papyrus/test/copy">
+ <packagedElement xmi:type="uml:Interface" xmi:id="_X4LRcJ1CEeaVooFvMLWt7w" name="Foo"/>
+ <packagedElement xmi:type="uml:Class" xmi:id="_ayu-EJ1CEeaVooFvMLWt7w" name="Bar">
+ <interfaceRealization xmi:id="_cy_loJ1CEeaVooFvMLWt7w" client="_ayu-EJ1CEeaVooFvMLWt7w" supplier="_X4LRcJ1CEeaVooFvMLWt7w" contract="_X4LRcJ1CEeaVooFvMLWt7w"/>
+ </packagedElement>
+</uml:Package>
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/AllTests.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/AllTests.java
index 6ac24b9a344..faac57319cd 100644
--- a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/AllTests.java
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/AllTests.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 440108
- * Christian W. Damus - bugs 458197, 468030, 485220
+ * Christian W. Damus - bugs 458197, 468030, 485220, 502461
*
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.tests.tests;
@@ -34,6 +34,7 @@ import org.junit.runners.Suite.SuiteClasses;
UMLLanguageProvidersTest.class,
IconsStereotypesTest.class,
CustomizableDelegatingItemLabelProviderTest.class,
+ UMLCopyTest.class,
})
public class AllTests {
// Test suite
diff --git a/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java
new file mode 100644
index 00000000000..e9bc322c2f4
--- /dev/null
+++ b/tests/junit/plugins/uml/tools/org.eclipse.papyrus.uml.tools.tests/src/org/eclipse/papyrus/uml/tools/tests/tests/UMLCopyTest.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2016 Christian W. Damus 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:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.tools.tests.tests;
+
+import static org.hamcrest.CoreMatchers.both;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Arrays;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.core.clipboard.ICopierFactory;
+import org.eclipse.papyrus.junit.utils.rules.HouseKeeper;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.InterfaceRealization;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Test cases for the UML-specific tuning of the {@link EcoreUtil.Copier}
+ * used by the Papyrus copy/paste infrastructure.
+ */
+public class UMLCopyTest {
+
+ @Rule
+ public final HouseKeeper houseKeeper = new HouseKeeper();
+
+ private ResourceSet rset;
+
+ private Package model;
+ private Interface foo;
+ private Class bar;
+ private InterfaceRealization rlz;
+
+ /**
+ * Initializes me.
+ */
+ public UMLCopyTest() {
+ super();
+ }
+
+ @Test
+ public void copyingInterfaceRealizationDoesNotCorruptTheModel() {
+ EcoreUtil.Copier copier = ICopierFactory.getInstance().get();
+
+ copier.copyAll(Arrays.asList(foo, bar));
+ copier.copyReferences();
+
+ InterfaceRealization copy = (InterfaceRealization) copier.get(rlz);
+
+ // Verify the copy
+ assertThat(copy.getImplementingClassifier(), both(notNullValue()).and(is(copier.get(bar))));
+ assertThat(copy.getContract(), both(notNullValue()).and(is(copier.get(foo))));
+
+ // Verify the non-corruption
+ assertThat(copy.getClients().size(), is(1));
+ }
+
+ //
+ // Nested types
+ //
+
+ @Before
+ public void initFixture() {
+ rset = houseKeeper.createResourceSet();
+
+ model = UMLUtil.load(rset,
+ URI.createPlatformPluginURI("org.eclipse.papyrus.uml.tools.tests/resources/uml/copy.uml", true),
+ UMLPackage.Literals.PACKAGE);
+ foo = (Interface) model.getOwnedType("Foo");
+ bar = (Class) model.getOwnedType("Bar");
+ rlz = bar.getInterfaceRealization(null, foo);
+ }
+}

Back to the top