Added createElementClassProvider method for override purposes 44/3844/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 18 Feb 2020 16:04:26 +0000 (18:04 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 18 Feb 2020 16:14:21 +0000 (16:14 +0000)
gitlab #467

Change-Id: Ia66b5833ff22cfa583b134470053e365d0c2547f
(cherry picked from commit d2fa2fcfc15f056eaa5468601e886529abc4ae18)

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

index 61305ade0c58e8bc8162ff5308e34b3e1dbf3ffe..d3170b9506270350f5dde298d7e1285bee0f2d1a 100644 (file)
@@ -54,6 +54,7 @@ import org.simantics.g2d.diagram.participant.ZOrderHandler;
 import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;
 import org.simantics.g2d.element.ElementClassProviders;
 import org.simantics.g2d.element.ElementClasses;
+import org.simantics.g2d.element.IElementClassProvider;
 import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;
 import org.simantics.g2d.multileveldiagram.TransitionFunction;
 import org.simantics.g2d.multileveldiagram.ZoomTransitionParticipant;
@@ -90,7 +91,6 @@ import org.simantics.scenegraph.g2d.events.adapter.AWTRemoteEventAdapter;
 import org.simantics.scenegraph.g2d.events.command.CommandKeyBinding;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.structural2.modelingRules.IModelingRules;
-import org.simantics.ui.SimanticsUI;
 import org.simantics.utils.datastructures.hints.HintContext;
 import org.simantics.utils.datastructures.hints.IHintContext;
 import org.simantics.utils.page.PageDesc;
@@ -366,12 +366,8 @@ 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.Connection)),
-                                    ElementClasses.FLAG, FlagClassFactory.createFlagClass(dr.Flag, dr.Flag_Terminal)
-                            )
-                    );
+                    GraphToDiagramSynchronizer sync = new GraphToDiagramSynchronizer(graph, ctx,createElementClassProvider(graph));
+                    
                     sync.set(ModelingSynchronizationHints.MODELING_RESOURCE, ModelingResources.getInstance(graph));
                     diagram = sync.loadDiagram(new NullProgressMonitor(), graph, null, resource, runtimeDiagramManager.getRuntimeDiagram(), structuralPath, initialHints); // FIXME
                     return sync;
@@ -388,6 +384,15 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
 
         return ctx.getSceneGraph();
     }
+    
+    protected IElementClassProvider createElementClassProvider(ReadGraph graph) throws DatabaseException {
+        DiagramResource dr = DiagramResource.getInstance(graph);
+        return ElementClassProviders.mappedProvider(
+                  ElementClasses.CONNECTION, DefaultConnectionClassFactory.CLASS.newClassWith(new StaticObjectAdapter(dr.Connection)),
+                  ElementClasses.FLAG, FlagClassFactory.createFlagClass(dr.Flag, dr.Flag_Terminal)
+        );
+        
+    }
 
     @Override
     public void dispose() {