]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/GraphToDiagramSynchronizer.java
Working towards multiple readers.
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / adapter / GraphToDiagramSynchronizer.java
index 3e404cf565b96163ad27d1c3532169e14b243bd8..55754f370e647222013bcbcca664e3edcf4e8b97 100644 (file)
@@ -51,6 +51,7 @@ import org.simantics.db.common.procedure.adapter.ListenerSupport;
 import org.simantics.db.common.procedure.adapter.ProcedureAdapter;
 import org.simantics.db.common.request.AsyncReadRequest;
 import org.simantics.db.common.request.ReadRequest;
+import org.simantics.db.common.request.UniqueAsyncRead;
 import org.simantics.db.common.session.SessionEventListenerAdapter;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.CancelTransactionException;
@@ -1339,7 +1340,13 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
                             ArrayMap.keys(ProfileKeys.DIAGRAM, ProfileKeys.CANVAS, ProfileKeys.NODE_MAP).values(GraphToDiagramSynchronizer.this.diagram, canvas, dn),
                             new CanvasNotification(canvas));
 
-                    profileObserver.listen(g, GraphToDiagramSynchronizer.this);
+                    g.getSession().asyncRequest(new AsyncReadRequest() {
+                                               
+                                               @Override
+                                               public void run(AsyncReadGraph graph) {
+                                   profileObserver.listen(graph, GraphToDiagramSynchronizer.this);
+                                               }
+                                       });
 
                     return d;
 
@@ -2475,15 +2482,20 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
                     return;
                 }
 
-                // NOTICE: Layer information is loaded from the connection entity resource
-                // that is shared by all segments of the same connection.
-                ElementFactoryUtil.loadLayersForElement(graph, layerManager, diagram, edge, info.connection,
-                        new AsyncProcedureAdapter<IElement>() {
-                    @Override
-                    public void exception(AsyncReadGraph graph, Throwable t) {
-                        error("failed to load layers for connection segment", t);
-                    }
-                });
+                graph.syncRequest(new AsyncReadRequest() {
+                                       @Override
+                                       public void run(AsyncReadGraph graph) {
+                               // NOTICE: Layer information is loaded from the connection entity resource
+                               // that is shared by all segments of the same connection.
+                               ElementFactoryUtil.loadLayersForElement(graph, layerManager, diagram, edge, info.connection,
+                                       new AsyncProcedureAdapter<IElement>() {
+                                   @Override
+                                   public void exception(AsyncReadGraph graph, Throwable t) {
+                                       error("failed to load layers for connection segment", t);
+                                   }
+                               });
+                                       }
+                               });
 
                 edge.setHintWithoutNotification(KEY_CONNECTION_BEGIN_PLACEHOLDER, new PlaceholderConnection(
                         EdgeEnd.Begin,