]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fixes for connection ElementFactory implementations after change r24388
authorlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 9 Mar 2012 09:27:24 +0000 (09:27 +0000)
committerlehtonen <lehtonen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 9 Mar 2012 09:27:24 +0000 (09:27 +0000)
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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/FlowConnectionFactoryOld.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/RouteFlowConnectionFactory.java

index e7bb25f474435b1a19104de941f85af2e27a7292..4baa6824d339975eb05425807fb14ef9cee87603 100644 (file)
@@ -31,7 +31,6 @@ import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
-import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
@@ -47,17 +46,12 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter {
 \r
     @Override\r
     public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure<ElementClass> procedure) {\r
-        DiagramResource dr = graph.getService(DiagramResource.class);\r
-        graph.forSingleType(elementType, dr.Connection, new AsyncProcedure<Resource>() {\r
-            @Override\r
-            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                procedure.exception(graph, throwable);\r
-            }\r
-            @Override\r
-            public void execute(AsyncReadGraph graph, Resource connectionType) {\r
-                procedure.execute(graph, SysdynConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(connectionType)));\r
-            }\r
-        });\r
+        procedure.execute(graph, SysdynConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementType)));\r
+    }\r
+\r
+    @Override\r
+    protected Resource getElementClassBaseType(AsyncReadGraph graph) {\r
+        return graph.getService(DiagramResource.class).Connection;\r
     }\r
 \r
     @Override\r
index 40d3e080c10d7b0fb4fba2e1c030d7c7115ee7c7..5041b6cb74922f47aea68169d7f0106a6ab98de2 100644 (file)
@@ -37,17 +37,12 @@ public class FlowConnectionFactoryOld extends ElementFactoryAdapter {
 \r
     @Override\r
     public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure<ElementClass> procedure) {\r
-        DiagramResource dr = graph.getService(DiagramResource.class);\r
-        graph.forSingleType(elementType, dr.Connection, new AsyncProcedure<Resource>() {\r
-            @Override\r
-            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                procedure.exception(graph, throwable);\r
-            }\r
-            @Override\r
-            public void execute(AsyncReadGraph graph, Resource connectionType) {\r
-                procedure.execute(graph, ConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(connectionType)));\r
-            }\r
-        });\r
+        procedure.execute(graph, ConnectionClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementType)));\r
+    }\r
+\r
+    @Override\r
+    protected Resource getElementClassBaseType(AsyncReadGraph graph) {\r
+        return graph.getService(DiagramResource.class).Connection;\r
     }\r
 \r
     @Override\r
index 70d1ad55dfaea2eccf673bdbc528c08457e0c83e..682b2cf944c31337abf7c2dfa5937f2df7027b4c 100644 (file)
@@ -105,19 +105,14 @@ public class RouteFlowConnectionFactory extends SyncElementFactory {
 \r
     @Override\r
     public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, final AsyncProcedure<ElementClass> procedure) {\r
-        SysdynResource sr = graph.getService(SysdynResource.class);\r
-        graph.forSingleType(elementType, sr.FlowConnection, new AsyncProcedure<Resource>() {\r
-            @Override\r
-            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                procedure.exception(graph, throwable);\r
-            }\r
-            @Override\r
-            public void execute(AsyncReadGraph graph, Resource connectionType) {\r
-                procedure.execute(graph, CLASS.newClassWith(false, new StaticObjectAdapter(connectionType)));\r
-            }\r
-        });\r
+        procedure.execute(graph, CLASS.newClassWith(false, new StaticObjectAdapter(elementType)));\r
     }\r
-    \r
+\r
+    @Override\r
+    protected Resource getElementClassBaseType(AsyncReadGraph graph) {\r
+        return graph.getService(SysdynResource.class).FlowConnection;\r
+    }\r
+\r
     @Override\r
     public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource connection,\r
             IElement element) throws DatabaseException {\r