]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Disable command based synchronization from RouteGraph Connections 06/4406/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 27 Aug 2020 10:04:48 +0000 (13:04 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 27 Aug 2020 10:04:48 +0000 (13:04 +0300)
In cases, where command based synchronization is required, use
DIA.CommandBasedSynchronization tag in connection type or instance.

gitlab #591

Change-Id: I52450c64a68bd669e4ea9eed0baf5734098a8768

bundles/org.simantics.diagram.ontology/graph/DiagramRouteGraphConnection.pgraph
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/RouteGraphConnection.java

index acdc27a8d35429186eab8bc0a150dfc5a1a7f5a7..a38c67db789f266ce1b0eeb35043a581baf9a842 100644 (file)
@@ -8,6 +8,7 @@ DIA = <http://www.simantics.org/Diagram-2.2>
 // NOTE: we inherit the old connection to break as little old code as possible
 DIA.RouteGraphConnection <T DIA.Connection
     @L0.property DIA.HasInteriorRouteNode
+    @L0.property DIA.CommandBasedSynchronization
 
 DIA.HasInteriorRouteNode <R L0.IsComposedOf
     L0.HasDomain DIA.Connection
@@ -22,6 +23,9 @@ DIA.HasPosition <R L0.HasProperty : L0.FunctionalRelation
 DIA.IsHorizontal <R L0.HasProperty : L0.FunctionalRelation
     L0.HasRange L0.Boolean
 
+DIA.CommandBasedSynchronization
+    @L0.defTag
+
 DIA.RouteNode <T L0.Entity
     @L0.property DIA.AreConnected
 DIA.InteriorRouteNode <T DIA.RouteNode
index 933e28ba47ceb727b24ae1680c4d9f3698568844..d18aa5f8e393f5645561f0c08c91c458efd634e0 100644 (file)
@@ -67,8 +67,7 @@ import org.simantics.utils.datastructures.Pair;
 public class RouteGraphConnection {
 
     private static final boolean DEBUG_SYNC = false;
-    private static final boolean USE_COMMAND_BASED_SYNCHRONIZATION = true;
-
+    
     public static Write synchronizer(final Resource connection, final RouteGraphChangeEvent event) {
         return new WriteRequest() {
             @Override
@@ -86,12 +85,14 @@ public class RouteGraphConnection {
     private DiagramResource DIA;
     private ConnectionUtil cu;
     private Resource connection;
+    private boolean commandBasedSynchronization;
 
-    public RouteGraphConnection(WriteGraph graph, Resource connection) {
+    public RouteGraphConnection(WriteGraph graph, Resource connection) throws DatabaseException {
         this.L0 = Layer0.getInstance(graph);
         this.DIA = DiagramResource.getInstance(graph);
         this.cu = new ConnectionUtil(graph);
         this.connection = connection;
+        this.commandBasedSynchronization = graph.hasStatement(connection, DIA.CommandBasedSynchronization);  
     }
     
     private static Function ConnectionPoint;
@@ -160,7 +161,7 @@ public class RouteGraphConnection {
         if (DEBUG_SYNC)
             delta.print();
         
-        if(USE_COMMAND_BASED_SYNCHRONIZATION) {
+        if(commandBasedSynchronization) {
             initialize(graph);        
         
                 Layer0 L0 = Layer0.getInstance(graph);