Skip to content
Snippets Groups Projects
Commit 3c6a9746 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

guard against null name

parent 8e193955
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ import java.util.Collection;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.swt.dnd.Clipboard;
......@@ -36,6 +37,7 @@ import org.eclipse.ui.PlatformUI;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.model.ISpeciallyCopyiable;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.dnd.CompositionServiceLocalCopyPasteTransfer;
import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
......@@ -46,10 +48,9 @@ import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
*
* @author hoelzl
* @author hummel
*
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 735070091AE0D79D9081019D71B4883D
* @ConQAT.Rating YELLOW Hash: EF3DD03F75141A7AA18905EB93378D3B
*/
public class CopyPasteUtils {
......@@ -67,6 +68,15 @@ public class CopyPasteUtils {
EcoreUtil.Copier copier = new EcoreUtil.Copier(true, true);
for(EObject obj : sel) {
content[i] = copier.copy(obj);
// Remove constraint instances: these are specific to their original elements and
// should not be copied.
TreeIterator<EObject> it = content[i].eAllContents();
while(it.hasNext()) {
EObject subObj = it.next();
if(subObj instanceof IConstrained) {
((IConstrained)subObj).getConstraintInstances().clear();
}
}
copier.copyReferences();
i++;
}
......@@ -184,19 +194,21 @@ public class CopyPasteUtils {
String containedName = contained.getName();
// check name and copy count
String pattern2 = "Copy of.*";
if(contained.getName().equals(copyName)) {
iterator++;
} else if(copyName.matches(pattern2) && containedName.matches(pattern2)) {
if(copyName.split(" ")[2].equals(containedName.split(" ")[2])) {
iterator++;
}
} else if(containedName.matches(pattern2)) {
if(copyName.equals(containedName.split(" ")[2])) {
iterator++;
}
} else if(copyName.matches(pattern2)) {
if(containedName.equals(copyName.split(" ")[2])) {
if(containedName != null) {
if(containedName.equals(copyName)) {
iterator++;
} else if(copyName.matches(pattern2) && containedName.matches(pattern2)) {
if(copyName.split(" ")[2].equals(containedName.split(" ")[2])) {
iterator++;
}
} else if(containedName.matches(pattern2)) {
if(copyName.equals(containedName.split(" ")[2])) {
iterator++;
}
} else if(copyName.matches(pattern2)) {
if(containedName.equals(copyName.split(" ")[2])) {
iterator++;
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment