From 5a77734182bada2463020567b7e4be5bb0331dcc Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Wed, 16 Jan 2019 17:42:37 +0200 Subject: [PATCH] Better support for customisation of scene graph provider Change-Id: I565d1c7a1c74fe67d567c5802c3d873c027c3304 --- .../ui/sg/DiagramSceneGraphProvider.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java index 52c024f6b..30dd1ba13 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java @@ -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; -- 2.47.1