From: Marko Luukkainen Date: Tue, 18 Feb 2020 16:04:26 +0000 (+0200) Subject: Added createElementClassProvider method for override purposes X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=d2fa2fcfc15f056eaa5468601e886529abc4ae18;p=simantics%2Fplatform.git Added createElementClassProvider method for override purposes gitlab #467 Change-Id: Ia66b5833ff22cfa583b134470053e365d0c2547f --- 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 61305ade0..d3170b950 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 @@ -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() {