]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/SyncTypicalTemplatesToInstances.java
Don't abort typical sync on blocked template to instance connections
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / typicals / SyncTypicalTemplatesToInstances.java
index 7c1fe461a5e14218991f87224c8ec1d47e42a16e..09545ada8b473a45c49a2a54a1d5fc4a13b0cb6c 100644 (file)
@@ -459,6 +459,8 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
     private boolean isSynchronizedConnector(ReadGraph graph, Resource templateConnection, Resource instanceConnector) throws DatabaseException {
        DiagramResource DIA = DiagramResource.getInstance(graph);
        Resource instanceConnection = graph.getPossibleObject(instanceConnector, DIA.IsConnectorOf);
+       if (instanceConnection == null)
+               return false;
        return graph.hasStatement(instanceConnection, MOD.HasElementSource, templateConnection)
                        // If the master connection has been removed, this is all that's left
                        // to identify a connection that at least was originally synchronized
@@ -552,8 +554,9 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
                                        if(stm != null) {
                                                if(graph.isInstanceOf(connectionPoint, L0.FunctionalRelation)) {
                                                        if(!isSynchronizedConnector(graph, templateElement, stm.getObject())) {
-                                                               messageLog.add("\t\tABORTED: tried to connect to an already connected terminal " + NameUtils.getSafeName(graph, counterPartElement) + " " + NameUtils.getSafeName(graph, connectionPoint));
-                                                               return;
+                                                               messageLog.add("\t\tWARNING: skipping addition of template connection " + NameUtils.getSafeName(graph, templateElement, true) + " into instance.");
+                                                               messageLog.add("\t\t\ttried to connect to an already connected terminal " + NameUtils.getSafeName(graph, counterPartElement, true) + " " + NameUtils.getSafeName(graph, connectionPoint));
+                                                               templateElementsAddedToTemplate.remove(templateElement);
                                                        }
                                                }
                                                }
@@ -823,7 +826,7 @@ public class SyncTypicalTemplatesToInstances extends WriteRequest {
             Resource instanceElement = typicalInfo.bean.templateToInstance.get(changedTemplateElement);
             if (instanceElement == null) {
                 // There's an earlier problem in the sync process if this happens.
-               typicalInfo.messageLog.add("SKIPPING SYNC OF CHANGED TEMPLATE ELEMENT DUE TO MISSING INSTANCE: " + safeNameAndType(graph, getElementNameResource(graph, changedTemplateElement)));
+               typicalInfo.messageLog.add("\t\tSKIPPING SYNC OF CHANGED TEMPLATE ELEMENT DUE TO MISSING INSTANCE: " + safeNameAndType(graph, getElementNameResource(graph, changedTemplateElement)));
                 continue;
             }