From: Marko Luukkainen Date: Wed, 18 Dec 2019 18:48:11 +0000 (+0200) Subject: Fixed connection creation X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=95f5fb2f87e913fc781d0e4bcd2f193ccb138d28;p=simantics%2Finterop.git Fixed connection creation gitlab #7 Change-Id: Ie10154d941b44f0ef48143535711798e84305989 --- diff --git a/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Diagram.java b/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Diagram.java index 15174e6..d7f0631 100644 --- a/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Diagram.java +++ b/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Diagram.java @@ -198,6 +198,7 @@ public abstract class Diagram { 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 { // 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); diff --git a/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java b/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java index 22160aa..c52bfa4 100644 --- a/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java +++ b/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java @@ -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);