From 0b9e76b538d2bd09828858895b86ffbc66750e2a Mon Sep 17 00:00:00 2001
From: Sergey Zverlov <zverlov@fortiss.org>
Date: Mon, 17 Jul 2017 15:04:17 +0000
Subject: [PATCH] partial fix of the issue (cf. issue description) during the
 gui sprint refs 2347

---
 .../tooling/kernel/ui/util/CopyPasteUtils.java | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/CopyPasteUtils.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/CopyPasteUtils.java
index 14e6168bc..1f334d9c2 100644
--- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/CopyPasteUtils.java
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/CopyPasteUtils.java
@@ -200,7 +200,8 @@ public class CopyPasteUtils {
 		if(copy instanceof INamedElement) {
 			String copyName = ((INamedElement)copy).getName();
 			int iterator = 0;
-			for(EObject o : target.eContents()) {
+			EList<EObject> contentsAtTwoLevels = getContentsAtTwoLevels(target);
+			for(EObject o : contentsAtTwoLevels) {
 				// check class types
 				if(o.getClass().isInstance(copy) && o instanceof INamedElement) {
 					INamedElement contained = (INamedElement)o;
@@ -238,4 +239,19 @@ public class CopyPasteUtils {
 			((INamedElement)copy).setName(newName);
 		}
 	}
+
+	/**
+	 * Creates a @{link {@link EList} of the eContents of the current {@link EObject} and the
+	 * eConents of its container.
+	 */
+	private static EList<EObject> getContentsAtTwoLevels(EObject target) {
+
+		EList<EObject> containtsOfContainer = target.eContainer().eContents();
+		EList<EObject> contents = target.eContents();
+		EList<EObject> allContents = new BasicEList<EObject>();
+		allContents.addAll(containtsOfContainer);
+		allContents.addAll(contents);
+
+		return allContents;
+	}
 }
-- 
GitLab