Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2019-10-25 05:14:10 -0400
committervincent lorenzo2019-11-07 10:50:41 -0500
commit961efc930f4df0d5cae8eabc20272cfc663391a1 (patch)
tree0ffec7e1279cda701df9fa8fa3177ebac676c840 /plugins/uml
parente3a7ee056a7ab052aaa314cf2b62f789da4ae01f (diff)
downloadorg.eclipse.papyrus-961efc930f4df0d5cae8eabc20272cfc663391a1.tar.gz
org.eclipse.papyrus-961efc930f4df0d5cae8eabc20272cfc663391a1.tar.xz
org.eclipse.papyrus-961efc930f4df0d5cae8eabc20272cfc663391a1.zip
Bug 552410 - [Copy/Paste] If a stereotype has composite association the
copy paste of stereotyped element does not works correctly Change-Id: I08ee7083457527bd9028a64aab3b1bb0fb8520a1 Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml2
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DuplicateStereotypeCommand.java26
3 files changed, 25 insertions, 5 deletions
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 1bb3865acaf..973c9143ef5 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
@@ -33,7 +33,7 @@ Require-Bundle: org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)";visibility:=
org.eclipse.papyrus.infra.services.decoration;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 4.2.0.qualifier
+Bundle-Version: 4.2.100.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.uml.tools.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml
index 6d634f293e3..f4f6f0012e9 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml
@@ -9,7 +9,7 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.tools</artifactId>
- <version>4.2.0-SNAPSHOT</version>
+ <version>4.2.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<description>This plugin contributes a set of common tools for UML</description>
</project>
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DuplicateStereotypeCommand.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DuplicateStereotypeCommand.java
index 19b4bf58bb3..fe158f817f2 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DuplicateStereotypeCommand.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/DuplicateStereotypeCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2017 CEA LIST.
+ * Copyright (c) 2014, 2017, 2019 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -12,13 +12,18 @@
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
* Gaabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 438511
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - bug 511045
- * Ansgar Radermacher (CEA LIST), ansgar.radermacher@cea.fr - bug 521279 (copy/paste between models)
+ * Ansgar Radermacher (CEA LIST), ansgar.radermacher@cea.fr - bug 521279 (copy/paste between models)
+ * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - bug 552410
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.commands;
+import java.util.Collection;
+
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
@@ -98,7 +103,22 @@ public class DuplicateStereotypeCommand extends RecordingCommand {
for (EStructuralFeature eStructuralFeature : eStructuralFeatures) {
String name = eStructuralFeature.getName();
if (!name.startsWith(Extension.METACLASS_ROLE_PREFIX) && eStructuralFeature.isChangeable()) {
- applyStereotype.eSet(eStructuralFeature, stereotypeApplication.eGet(eStructuralFeature));
+ if (eStructuralFeature instanceof EReference && ((EReference) eStructuralFeature).isContainment()) {
+ // In case that the structural feature is containment then we should copy the value not only change the reference
+ Object value = stereotypeApplication.eGet(eStructuralFeature);
+ if (value instanceof EObject) {
+ EObject valueCopy = EcoreUtil.copy((EObject) value);
+ applyStereotype.eSet(eStructuralFeature, valueCopy);
+ } else if (value instanceof Collection<?>) {
+ Collection<?> listValue = (Collection<?>) value;
+ if (listValue.stream().allMatch(v -> v instanceof EObject)) {
+ Collection<?> valueCopy = EcoreUtil.copyAll(listValue);
+ applyStereotype.eSet(eStructuralFeature, valueCopy);
+ }
+ }
+ } else {
+ applyStereotype.eSet(eStructuralFeature, stereotypeApplication.eGet(eStructuralFeature));
+ }
}
}
}

Back to the top