]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java
Fixed ComponentCopyAdvisor to account for L0.TypeWithIdentifier properly
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / mapping / ComponentCopyAdvisor.java
index 6b4e59d176860bdeb53387818a00a8d1d696e6db..3e6e9c1b9527096cfa1835a50e43f6b2dfb97c7f 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.modeling.mapping;
 
-import gnu.trove.map.hash.THashMap;
-
 import java.util.Map;
 
 import org.simantics.Simantics;
@@ -30,11 +28,14 @@ import org.simantics.diagram.synchronization.graph.GraphCopyAdvisor;
 import org.simantics.diagram.synchronization.graph.GraphSynchronizationHints;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.ComponentUtils;
+import org.simantics.modeling.ModelingUtils;
 import org.simantics.modeling.services.ComponentNamingUtil;
 import org.simantics.modeling.services.NamingException;
 import org.simantics.project.IProject;
 import org.simantics.structural.stubs.StructuralResource2;
 
+import gnu.trove.map.hash.THashMap;
+
 /**
  * @author Tuukka Lehtonen
  */
@@ -58,22 +59,14 @@ public class ComponentCopyAdvisor extends GraphCopyAdvisor {
     public Object copy(ISynchronizationContext context, WriteGraph graph, Resource source, Resource sourceContainer,
             Resource targetContainer, Map<Object, Object> map) throws DatabaseException {
         StructuralResource2 STR = StructuralResource2.getInstance(graph);
-        Resource copy = null;
-        if (graph.isInstanceOf(source, STR.Connection)) {
-            // Configuration connections are not named, can't use TG copy for
-            // them at the moment.
-            copy = CopyAdvisorUtil.copy2(graph, source, null, map);
-        } else {
-//            Resource model = graph.syncRequest(new PossibleModel(targetContainer));
-//            copy = CopyAdvisorUtil.copy4(graph, source, model);
-            copy = CopyAdvisorUtil.copy2(graph, source, null, map);
-        }
+        Resource copy = CopyAdvisorUtil.copy2(graph, source, null, map);
 
         Layer0 L0 = Layer0.getInstance(graph);
         if (graph.hasStatement(sourceContainer, L0.ConsistsOf, source))
             graph.claim(targetContainer, L0.ConsistsOf, copy);
 
-        Layer0Utils.claimNewIdentifier(graph, copy, false);
+        if (ModelingUtils.needsIdentifier(graph, source))
+            Layer0Utils.claimNewIdentifier(graph, copy, false);
         if (context.get(SynchronizationHints.NO_RENAME) == null)
             renameComponent(context, graph, source, copy, sourceContainer, targetContainer);
         return copy;