From: lehtonen Date: Fri, 9 Mar 2012 09:27:24 +0000 (+0000) Subject: Fixes for connection ElementFactory implementations after change r24388 X-Git-Tag: simantics-1.6~26 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=e877a3a211d2909120c8c25c86f17277d3a6822b;p=simantics%2Fsysdyn.git Fixes for connection ElementFactory implementations after change r24388 which fixed the way ConnectionRequest invokes ElementFactory create/getClass methods. The problem was caused by invalidly implemented create method which assumed that it receives an element instance, not an element type as it should receive. fixes #3276 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24392 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java index e7bb25f4..4baa6824 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java @@ -31,7 +31,6 @@ import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; -import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.editor.routing.DependencyRouter; import org.simantics.utils.datastructures.Pair; @@ -47,17 +46,12 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter { @Override public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure procedure) { - DiagramResource dr = graph.getService(DiagramResource.class); - graph.forSingleType(elementType, dr.Connection, new AsyncProcedure() { - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); - } - @Override - public void execute(AsyncReadGraph graph, Resource connectionType) { - procedure.execute(graph, SysdynConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(connectionType))); - } - }); + procedure.execute(graph, SysdynConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementType))); + } + + @Override + protected Resource getElementClassBaseType(AsyncReadGraph graph) { + return graph.getService(DiagramResource.class).Connection; } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowConnectionFactoryOld.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowConnectionFactoryOld.java index 40d3e080..5041b6cb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowConnectionFactoryOld.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowConnectionFactoryOld.java @@ -37,17 +37,12 @@ public class FlowConnectionFactoryOld extends ElementFactoryAdapter { @Override public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure procedure) { - DiagramResource dr = graph.getService(DiagramResource.class); - graph.forSingleType(elementType, dr.Connection, new AsyncProcedure() { - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); - } - @Override - public void execute(AsyncReadGraph graph, Resource connectionType) { - procedure.execute(graph, ConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(connectionType))); - } - }); + procedure.execute(graph, ConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementType))); + } + + @Override + protected Resource getElementClassBaseType(AsyncReadGraph graph) { + return graph.getService(DiagramResource.class).Connection; } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/RouteFlowConnectionFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/RouteFlowConnectionFactory.java index 70d1ad55..682b2cf9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/RouteFlowConnectionFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/RouteFlowConnectionFactory.java @@ -105,19 +105,14 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { @Override public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure procedure) { - SysdynResource sr = graph.getService(SysdynResource.class); - graph.forSingleType(elementType, sr.FlowConnection, new AsyncProcedure() { - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); - } - @Override - public void execute(AsyncReadGraph graph, Resource connectionType) { - procedure.execute(graph, CLASS.newClassWith(false, new StaticObjectAdapter(connectionType))); - } - }); + procedure.execute(graph, CLASS.newClassWith(false, new StaticObjectAdapter(elementType))); } - + + @Override + protected Resource getElementClassBaseType(AsyncReadGraph graph) { + return graph.getService(SysdynResource.class).FlowConnection; + } + @Override public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource connection, IElement element) throws DatabaseException {