]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Better support for customisation of scene graph provider
authorAntti Villberg <antti.villberg@semantum.fi>
Wed, 16 Jan 2019 15:42:37 +0000 (17:42 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Wed, 16 Jan 2019 15:42:37 +0000 (17:42 +0200)
Change-Id: I565d1c7a1c74fe67d567c5802c3d873c027c3304

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java

index 52c024f6baddfe9baadce6d7acfe76e39fed27d8..30dd1ba1344e8d36d3828200669f858458440b97 100644 (file)
@@ -332,6 +332,16 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
         ctx = new CanvasContext(thread, sg); // By giving the scene graph instance as parameter, we can use external serializer
         return initializeSceneGraph(ctx, sg, modelURI, RVI, view);
     }
+    
+    protected GraphToDiagramSynchronizer createSynchronizer(ReadGraph graph) throws DatabaseException {
+        DiagramResource DIA = DiagramResource.getInstance(graph);
+        return new GraphToDiagramSynchronizer(graph, ctx,
+                ElementClassProviders.mappedProvider(
+                        ElementClasses.CONNECTION, DefaultConnectionClassFactory.CLASS.newClassWith(new StaticObjectAdapter(DIA.RouteGraphConnection)),
+                        ElementClasses.FLAG, FlagClassFactory.createFlagClass(DIA.Flag, DIA.Flag_Terminal)
+                )
+        );
+    }
 
     /**
      * @param sg
@@ -366,12 +376,7 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
                     if(val != null && navigation == null) { // Set only if navigation has not been set manually
                         navigation = val;
                     }
-                    GraphToDiagramSynchronizer sync = new GraphToDiagramSynchronizer(graph, ctx,
-                            ElementClassProviders.mappedProvider(
-                                    ElementClasses.CONNECTION, DefaultConnectionClassFactory.CLASS.newClassWith(new StaticObjectAdapter(dr.RouteGraphConnection)),
-                                    ElementClasses.FLAG, FlagClassFactory.createFlagClass(dr.Flag, dr.Flag_Terminal)
-                            )
-                    );
+                    GraphToDiagramSynchronizer sync = createSynchronizer(graph);
                     sync.set(ModelingSynchronizationHints.MODELING_RESOURCE, ModelingResources.getInstance(graph));
                     diagram = sync.loadDiagram(new NullProgressMonitor(), graph, null, resource, runtimeDiagramManager.getRuntimeDiagram(), structuralPath, initialHints); // FIXME
                     return sync;