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 14e6168bc85d8a738897fde457a216b4c3aca452..1f334d9c274a07c0c1bf8ef8ec4507aedd5d0ab4 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; + } }