]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Support VirtualGraph in GraphToDiagramSynchronizer and DiagramSGProvider 09/4609/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 9 Nov 2020 16:59:18 +0000 (18:59 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 9 Nov 2020 16:59:18 +0000 (18:59 +0200)
gitlab #640

Change-Id: I6763bb7d27a1dc430d1823fff97dba56b7ef1c91

bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/GraphToDiagramSynchronizer.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/ModificationProcessRequest.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/ModificationQueue.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sg/DiagramSceneGraphProvider.java

index 37471eb3a1186fa8dc1c993e7d0f267f178a5f91..981047f7c735af6d284a94420d19279594fb59f9 100644 (file)
@@ -40,6 +40,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.RequestProcessor;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
+import org.simantics.db.VirtualGraph;
 import org.simantics.db.common.ResourceArray;
 import org.simantics.db.common.exception.DebugException;
 import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
@@ -1041,6 +1042,7 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
     // Internal state machine handling END
     // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
+    
     /**
      * @param processor
      * @param canvas
@@ -1048,6 +1050,9 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
      * @throws DatabaseException
      */
     public GraphToDiagramSynchronizer(RequestProcessor processor, ICanvasContext canvas, IElementClassProvider elementClassProvider) throws DatabaseException {
+       this(processor,canvas,elementClassProvider, null);
+    }
+    public GraphToDiagramSynchronizer(RequestProcessor processor, ICanvasContext canvas, IElementClassProvider elementClassProvider, VirtualGraph virtualGraph) throws DatabaseException {
         if (processor == null)
             throw new IllegalArgumentException("null processor");
         if (canvas == null)
@@ -1057,7 +1062,7 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
 
         this.session = processor.getSession();
         this.canvas = canvas;
-        this.modificationQueue = new ModificationQueue(session, errorHandler);
+        this.modificationQueue = new ModificationQueue(session, errorHandler, virtualGraph);
 
         processor.syncRequest(new ReadRequest() {
             @Override
index 22059cc21a0b493e97cb230144792687b44611f6..fc0b8a5d254bd8176aa6416e17b3b4d8acdd92ca 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/
 package org.simantics.diagram.synchronization.graph;
 
+import org.simantics.db.VirtualGraph;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.exception.DatabaseException;
@@ -20,7 +21,6 @@ import org.simantics.diagram.internal.timing.GTask;
 import org.simantics.diagram.internal.timing.Timing;
 import org.simantics.diagram.synchronization.ErrorHandler;
 import org.simantics.diagram.synchronization.IModification;
-import org.simantics.utils.logging.TimeLogger;
 
 /**
  * A graph database write request that composes several {@link IModification}
@@ -39,6 +39,13 @@ public class ModificationProcessRequest extends WriteRequest {
         this.errorHandler = errorHandler;
         this.modifications = modifications;
     }
+    
+    public ModificationProcessRequest(ErrorHandler errorHandler, IModification[] modifications, VirtualGraph provider) {
+       super(provider);
+        this.errorHandler = errorHandler;
+        this.modifications = modifications;
+    }
+
 
     @Override
     public void perform(final WriteGraph g) throws DatabaseException {
index 0e74431bd5d2d34ab676181d67eb6e7580b17d86..27b40c79d36c0de07e82670968efe8f1798a16ff 100644 (file)
@@ -15,6 +15,7 @@ import java.util.ArrayDeque;
 import java.util.Deque;
 
 import org.simantics.db.RequestProcessor;
+import org.simantics.db.VirtualGraph;
 import org.simantics.diagram.internal.DebugPolicy;
 import org.simantics.diagram.synchronization.ErrorHandler;
 import org.simantics.diagram.synchronization.IModification;
@@ -31,14 +32,23 @@ public class ModificationQueue implements IModificationQueue {
     private final RequestProcessor     writebackProcessor;
     private final ErrorHandler         errorHandler;
     private final Deque<IModification> writebackQueue = new ArrayDeque<IModification>();
-
+    private final VirtualGraph virtualGraph;
+    
     public ModificationQueue(RequestProcessor writebackProcessor, ErrorHandler errorHandler) {
         this.writebackProcessor = writebackProcessor;
         this.errorHandler = errorHandler;
+        this.virtualGraph = null;
+    }
+    
+    public ModificationQueue(RequestProcessor writebackProcessor, ErrorHandler errorHandler, VirtualGraph virtualGraph) {
+        this.writebackProcessor = writebackProcessor;
+        this.errorHandler = errorHandler;
+        this.virtualGraph = virtualGraph;
     }
 
     public void dispose() {
     }
+    
 
     ModificationProcessRequest createModificationRequest() {
         IModification[] mods = IModification.NONE;
@@ -46,7 +56,7 @@ public class ModificationQueue implements IModificationQueue {
             mods = writebackQueue.toArray(IModification.NONE);
             writebackQueue.clear();
         }
-        return new ModificationProcessRequest(errorHandler, mods);
+        return new ModificationProcessRequest(errorHandler, mods, virtualGraph);
     }
 
     void dispatchModifications() {
index 302e074fce35fe9a202c743119e15afd397eb23f..e08984e7f2baa7490c3ec58a56266317519bb314 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.Simantics;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
+import org.simantics.db.VirtualGraph;
 import org.simantics.db.common.ResourceArray;
 import org.simantics.db.common.primitiverequest.PossibleAdapter;
 import org.simantics.db.exception.DatabaseException;
@@ -28,6 +29,7 @@ import org.simantics.db.exception.ServiceException;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.db.procedure.Listener;
 import org.simantics.db.request.Read;
+import org.simantics.db.service.VirtualGraphSupport;
 import org.simantics.diagram.adapter.DefaultConnectionClassFactory;
 import org.simantics.diagram.adapter.FlagClassFactory;
 import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;
@@ -379,6 +381,7 @@ public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDi
                fillInitialDiagramHints(initialHints);
             
             final RuntimeDiagramManager runtimeDiagramManager = RuntimeDiagramManager.create(Simantics.getSession(), resource, modelURI, RVI);
+            VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
             
             synchronizer = Simantics.getSession().syncRequest(new Read<GraphToDiagramSynchronizer>() {
                 @Override
@@ -388,7 +391,13 @@ 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,createElementClassProvider(graph));
+                    VirtualGraph virtualGraph = support.getGraph(graph, resource);
+                    GraphToDiagramSynchronizer sync;
+                    if (virtualGraph != null) {
+                       sync = new GraphToDiagramSynchronizer(graph, ctx,createElementClassProvider(graph), virtualGraph);
+                    } else {
+                       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