]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Fixed connection creation 22/3722/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 18 Dec 2019 18:48:11 +0000 (20:48 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 18 Dec 2019 18:48:11 +0000 (20:48 +0200)
gitlab #7

Change-Id: Ie10154d941b44f0ef48143535711798e84305989

org.simantics.interop.diagram/src/org/simantics/interop/diagram/Diagram.java
org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java

index 15174e65378d43565cd7692dda0a58adba966486..d7f0631e034c53fdf81d5087ffcf604b67461d68 100644 (file)
@@ -198,6 +198,7 @@ public abstract class Diagram<T extends Symbol> {
                Layer0 l0 = Layer0.getInstance(g);
                Layer0X l0x = Layer0X.getInstance(g);
                ModelingResources m = ModelingResources.getInstance(g);
+               DiagramResource dia = DiagramResource.getInstance(g);
                
                // create composite
                Resource composite = g.newResource();
@@ -232,7 +233,7 @@ public abstract class Diagram<T extends Symbol> {
         // This would cause problems because a diagram is a structural composite/component also.
         g.claimLiteral(diagram, l0.HasName, name, Bindings.STRING);
         Resource container = g.newResource();
-        g.claim(container, l0.InstanceOf, null, l0.Library);
+        g.claim(container, l0.InstanceOf, null, dia.DiagramContainer);
         g.addLiteral(container, l0.HasName, l0.NameOf, l0.String, "__CONTAINER__", Bindings.STRING);
         g.claim(container, l0.ConsistsOf, diagram);
         g.claim(composite, l0.ConsistsOf, container);
index 22160aa916d422684cabaea578aa55959296d687..c52bfa451df4b5dd869718c2538b213e4372f0ab 100644 (file)
@@ -207,21 +207,26 @@ public abstract class Symbol {
                
                // Relation from element1 to connector1
                Resource isConnected1 = getDiagramConnectionRelation(g, element, componentConRel1);
-               
+               Resource connectorRel1 = g.getPossibleObject(componentConRel1, s.HasAttachmentRelation);
+               if (connectorRel1 == null)
+                       connectorRel1 = d.HasPlainConnector;
+                               
                // connector1
                Resource connector1 = g.newResource();
                g.claim(connector1, b.InstanceOf, d.Connector);
                g.claim(element, isConnected1, connector1);
-               g.claim(diagramConnection, d.HasPlainConnector, connector1);
+               g.claim(diagramConnection, connectorRel1, connector1);
                
                // Relation from element2 to connector2
                Resource isConnected2 = getDiagramConnectionRelation(g, symbolConf2.element, componentConRel2);
-               
+               Resource connectorRel2 = g.getPossibleObject(componentConRel2, s.HasAttachmentRelation);
+               if (connectorRel2 == null)
+                       connectorRel2 = d.HasArrowConnector;
                // connector2
                Resource connector2 = g.newResource();
                g.claim(connector2, b.InstanceOf, d.Connector);
                g.claim(symbolConf2.element, isConnected2, connector2);
-               g.claim(diagramConnection, d.HasArrowConnector, connector2);
+               g.claim(diagramConnection, connectorRel2, connector2);
                
                // connect connectors
                g.claim(connector1, d.AreConnected, connector2);