]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Support selection of experiment run for scene graph provider
authorAntti Villberg <antti.villberg@semantum.fi>
Mon, 28 Jan 2019 08:39:27 +0000 (10:39 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Mon, 28 Jan 2019 08:39:27 +0000 (10:39 +0200)
Change-Id: I1507d0088942c9d2d05d0ba66d7854458302a89a

bundles/org.simantics.diagram/src/org/simantics/diagram/elements/DiagramNodeUtil.java
bundles/org.simantics.diagram/src/org/simantics/diagram/runtime/RuntimeDiagramManager.java
bundles/org.simantics.g2d/src/org/simantics/g2d/scenegraph/ICanvasSceneGraphProvider2.java [new file with mode: 0644]
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java

index 467e4e349d5f494bf428ae2f1c1e3601c714e83f..671c317ec4a6624f13f86d48b89e242278efc72c 100644 (file)
@@ -13,6 +13,7 @@ import org.simantics.db.common.request.Queries;
 import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.request.Read;
 import org.simantics.db.service.TransactionSupport;
 import org.simantics.db.service.VirtualGraphSupport;
@@ -26,6 +27,7 @@ import org.simantics.g2d.diagram.handler.DataElementMap;
 import org.simantics.g2d.element.ElementHints;
 import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider;
+import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider2;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.scenegraph.INode;
 import org.simantics.scenegraph.adapters.ISceneGraphProvider;
@@ -180,10 +182,19 @@ public class DiagramNodeUtil {
     }
 
     public static ICanvasSceneGraphProvider loadSceneGraphProviderForDiagram(ICanvasContext context, Resource model, Resource diagram, String diagramRVI) throws DatabaseException, InterruptedException {
+        return loadSceneGraphProviderForDiagram(context, model, diagram, diagramRVI, null);
+    }
+
+    public static ICanvasSceneGraphProvider loadSceneGraphProviderForDiagram(ICanvasContext context, Resource model, Resource diagram, String diagramRVI, Variable run) throws DatabaseException, InterruptedException {
         String modelURI = Simantics.getSession().syncRequest(Queries.uri(model));
         ISceneGraphProvider provider = Simantics.getSession().syncRequest( Queries.adapt( diagram, ISceneGraphProvider.class ) );
         ICanvasSceneGraphProvider cp = (ICanvasSceneGraphProvider) provider;
-        cp.initializeSceneGraph(context, modelURI, diagramRVI);
+        if(cp instanceof ICanvasSceneGraphProvider2) {
+            ((ICanvasSceneGraphProvider2)cp).initializeSceneGraph(context, modelURI, diagramRVI, run);
+            
+        } else {
+            cp.initializeSceneGraph(context, modelURI, diagramRVI);
+        }
         NodeUtil.waitPending(cp.getCanvasContext().getThreadAccess(), context.getSceneGraph());
         Simantics.getSession().getService(TransactionSupport.class).waitCompletion();
         return cp;
index 04e30f70d44621e0c9b7e025ff5aba228e09631b..b0ba03c58b5ee2ea50f72944c0c0b7e993d3f5e0 100644 (file)
@@ -314,7 +314,7 @@ public class RuntimeDiagramManager {
         });
     }
 
-    private Resource createRuntimeDiagram(WriteGraph graph, Resource diagram, RuntimeDiagramDesc desc) throws DatabaseException {
+    protected Resource createRuntimeDiagram(WriteGraph graph, Resource diagram, RuntimeDiagramDesc desc) throws DatabaseException {
 
         Layer0 L0 = Layer0.getInstance(graph);
         final DiagramResource DIA = DiagramResource.getInstance(graph);
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/scenegraph/ICanvasSceneGraphProvider2.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/scenegraph/ICanvasSceneGraphProvider2.java
new file mode 100644 (file)
index 0000000..c0af2f8
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.scenegraph;
+
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.scenegraph.g2d.G2DSceneGraph;
+
+/**
+ * @author Antti Villberg
+ */
+public interface ICanvasSceneGraphProvider2 extends ICanvasSceneGraphProvider {
+
+    public G2DSceneGraph initializeSceneGraph(ICanvasContext context, String modelURI, String RVI, Variable experiment);
+
+}
index 5c8f36791622f72e1364e2da46deda8e99906c83..8d308866753d6db5ff140a52c6909c657238c03f 100644 (file)
@@ -19,12 +19,14 @@ import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
+import org.simantics.db.Session;
 import org.simantics.db.common.ResourceArray;
 import org.simantics.db.common.primitiverequest.PossibleAdapter;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 import org.simantics.db.exception.NoSingleResultException;
 import org.simantics.db.exception.ServiceException;
+import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.db.request.Read;
 import org.simantics.diagram.adapter.DefaultConnectionClassFactory;
@@ -76,6 +78,7 @@ import org.simantics.g2d.participant.TimeParticipant;
 import org.simantics.g2d.participant.TransformUtil;
 import org.simantics.g2d.participant.ZoomToAreaHandler;
 import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider;
+import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider2;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.modeling.mapping.ComponentCopyAdvisor;
 import org.simantics.modeling.mapping.ElementCopyAdvisor;
@@ -107,7 +110,7 @@ import org.simantics.utils.ui.ErrorLogger;
  * @author J-P Laine
  *
  */
-public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDiagramUpdateSupport {
+public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider2, IDiagramUpdateSupport {
 
        protected boolean isSymbol = false;
     protected Resource resource;
@@ -318,8 +321,17 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
     @Override
     public G2DSceneGraph initializeSceneGraph(ICanvasContext context, String modelURI, String RVI) {
         G2DSceneGraph sg = context.getSceneGraph();
-        return initializeSceneGraph(context, sg, modelURI, RVI, "");
+        return initializeSceneGraph(context, sg, modelURI, RVI, "", null);
     }
+    
+    
+    @Override
+    public G2DSceneGraph initializeSceneGraph(ICanvasContext context, String modelURI, String RVI,
+            Variable experiment) {
+        G2DSceneGraph sg = context.getSceneGraph();
+        return initializeSceneGraph(context, sg, modelURI, RVI, "", experiment);
+    }
+
 
     /**
      * @param sg
@@ -330,7 +342,7 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
     private G2DSceneGraph initializeSceneGraph(G2DSceneGraph sg, String modelURI, String RVI, String view) {
         IThreadWorkQueue thread = AWTThread.getThreadAccess();
         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);
+        return initializeSceneGraph(ctx, sg, modelURI, RVI, view, null);
     }
     
     protected GraphToDiagramSynchronizer createSynchronizer(ReadGraph graph) throws DatabaseException {
@@ -342,6 +354,10 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
                 )
         );
     }
+    
+    protected RuntimeDiagramManager createRuntimeDiagramManager(Session session, Resource resource, String modelURI, String RVI, Variable experiment) throws DatabaseException {
+        return RuntimeDiagramManager.create(session, resource, modelURI, RVI);
+    }
 
     /**
      * @param sg
@@ -349,7 +365,7 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
      * @param initialHints
      * @return
      */
-    private G2DSceneGraph initializeSceneGraph(ICanvasContext context, G2DSceneGraph sg, String modelURI, String RVI, String view) {
+    private G2DSceneGraph initializeSceneGraph(ICanvasContext context, G2DSceneGraph sg, String modelURI, String RVI, String view, Variable run) {
         this.ctx = (CanvasContext) context;
         this.view = view;
         if(view != null) {
@@ -366,7 +382,7 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
             
             initialHints.setHint(SynchronizationHints.COPY_ADVISOR, getCopyAdvisor());
             
-            final RuntimeDiagramManager runtimeDiagramManager = RuntimeDiagramManager.create(Simantics.getSession(), resource, modelURI, RVI);
+            final RuntimeDiagramManager runtimeDiagramManager = createRuntimeDiagramManager(Simantics.getSession(), resource, modelURI, RVI, run);
             
             synchronizer = Simantics.getSession().syncRequest(new Read<GraphToDiagramSynchronizer>() {
                 @Override