]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/profile/DNElementColorStyle.java
Disable throttling for now, as it doens't work.
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / profile / DNElementColorStyle.java
index b74a66198366ccff9b2b24f79c8909c549eb017c..f8f6ba5c5760d8ddd2c1e118382dc3b35269dfa4 100644 (file)
@@ -24,18 +24,25 @@ public class DNElementColorStyle extends ThrottledStyleBase<Color> {
        @Override
        public Color calculateThrottledStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource groupItem) throws DatabaseException {
                DiagramSettings ds = graph.syncRequest(new DiagramSettingsRequest(runtimeDiagram), TransientCacheAsyncListener.instance());
-               if (ds.elementColoringFunction.isPresent()) {
-                       if (DEBUG)
-                               System.out.print("elementColoringFunction: " + ds.elementColoringFunction + "(" + groupItem + "): ");
-                       Double t = Simantics.applySCLRead(graph, ds.elementColoringFunction.get(), groupItem);
-                       if (DEBUG)
-                               System.out.print(t);
-                       if (t != null) {
-                               Color result = ds.coloringGradient.get(t);
-                               //System.out.println("color(" + t + "): " + result);
-                               return result;
+               // Prevent PendingVariableExceptions from coming through
+               boolean wasSynchronous = graph.setSynchronous(true);
+               try {
+                       if (ds.elementColoringFunction.isPresent()) {
+                               if (DEBUG)
+                                       System.out.print("elementColoringFunction: " + ds.elementColoringFunction + "(" + groupItem + "): ");
+                               Double t = Simantics.applySCLRead(graph, ds.elementColoringFunction.get(), groupItem);
+                               if (DEBUG)
+                                       System.out.print(t);
+                               if (t != null) {
+                                       Color result = ds.coloringGradient.get(t);
+                                       //System.out.println("color(" + t + "): " + result);
+                                       return result;
+                               }
                        }
                }
+               finally {
+                       graph.setSynchronous(wasSynchronous);
+               }
                return null;
        }