Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2019-01-16 12:34:10 +0000
committervincent lorenzo2019-01-27 10:06:46 +0000
commit17cb516fffb57b2968860900469d4987f5936500 (patch)
treef5d85fb5f96fd476a3cd02c92a834b210ec9f78f /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse
parent84f851475dbcae5030c99bd3c762157551c37d62 (diff)
downloadorg.eclipse.papyrus-17cb516fffb57b2968860900469d4987f5936500.tar.gz
org.eclipse.papyrus-17cb516fffb57b2968860900469d4987f5936500.tar.xz
org.eclipse.papyrus-17cb516fffb57b2968860900469d4987f5936500.zip
Bug 541686 - Multiple clients and suppliers in edges after copy-paste
- Remove copy-references from DiagramPasteStrategy (duplicate, since already in defaultPasteStrategy) - Fix typo in DefaultPasteCommand - Add new test UMLCopyTestME. Similar to existing copy test, but based on copier command in model explorer (including additional strategies and not only the copier itself) Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr> Change-Id: Ia786713a069fb69fd24e520466e4021cc6ea0c20
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/commands/DefaultPasteCommand.java2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java12
2 files changed, 8 insertions, 6 deletions
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 7cac4ac1b5d..726ebe64899 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
@@ -79,7 +79,7 @@ public class DefaultPasteCommand extends AbstractCommand {
Map<EObject, EObject> duplicatedObjects = new HashMap<EObject, EObject>();
duplicatedObjects.putAll(copier);
- // Inform the clipboard of the elment created (used by strategies)
+ // Inform the clipboard of the element created (used by strategies)
papyrusClipboard.addAllInternalToTargetCopy(duplicatedObjects);
// Prepare the move command to move UML element to their new owner
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java
index e78efeb1ede..203f9ae7afe 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/DiagramPasteStrategy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 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
@@ -10,6 +10,8 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - bug 541686 (duplicated replationships)
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste;
@@ -152,7 +154,7 @@ public class DiagramPasteStrategy extends AbstractPasteStrategy implements IPast
*/
@Override
public void prepare(PapyrusClipboard<Object> papyrusClipboard, Collection<EObject> selection) {
- Map<Object, IClipboardAdditionalData> mapCopyToClipboardAdditionalData = new HashMap<Object, IClipboardAdditionalData>();
+ Map<Object, IClipboardAdditionalData> mapCopyToClipboardAdditionalData = new HashMap<>();
Map sourceToInternalClipboard = papyrusClipboard.getSourceToInternalClipboard();
List<Diagram> extractSelectedWithoutOwner = extractDiagramWithoutOwner(selection);
if (extractSelectedWithoutOwner != null && !extractSelectedWithoutOwner.isEmpty()) {
@@ -182,7 +184,7 @@ public class DiagramPasteStrategy extends AbstractPasteStrategy implements IPast
* @return
*/
protected List<Diagram> extractDiagramWithoutOwner(Collection<EObject> selection) {
- List<Diagram> diagramWithoutOwnerInSelection = new ArrayList<Diagram>();
+ List<Diagram> diagramWithoutOwnerInSelection = new ArrayList<>();
if (selection != null) {
for (EObject eObject : selection) {
if (eObject instanceof Diagram) {
@@ -225,12 +227,12 @@ public class DiagramPasteStrategy extends AbstractPasteStrategy implements IPast
* @return duplicated diagrams
*/
protected Collection<Diagram> duplicateDiagrams(Collection<Diagram> diagrams, Map<? extends EObject, ? extends EObject> alreadyCopied) {
- Collection<Diagram> duplicatedDiagrams = new ArrayList<Diagram>();
+ Collection<Diagram> duplicatedDiagrams = new ArrayList<>();
EcoreUtil.Copier copier = new EcoreUtil.Copier();
copier.putAll(alreadyCopied);
for (Diagram diagram : diagrams) {
copier.copy(diagram);
- copier.copyReferences();
+ // do not copy references (already done in default strategy), avoid duplicates
EObject copy = copier.get(diagram);
if (copy instanceof Diagram) {
duplicatedDiagrams.add((Diagram) copy);

Back to the top