]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network.ui/src/org/simantics/district/network/ui/adapters/DistrictDiagramClassAdapter.java
Optimization of district scene graph node rendering
[simantics/district.git] / org.simantics.district.network.ui / src / org / simantics / district / network / ui / adapters / DistrictDiagramClassAdapter.java
index 171d31e671c81640ff84ddb1c4364a820f827666..e83f467d11fef0a43ffaa2848b8156528a58aeba 100644 (file)
@@ -17,19 +17,27 @@ import org.simantics.diagram.synchronization.graph.layer.GraphLayerManager;
 import org.simantics.g2d.diagram.DiagramClass;
 import org.simantics.g2d.diagram.IDiagram;
 import org.simantics.g2d.diagram.handler.SubstituteElementClass;
+import org.simantics.g2d.diagram.handler.impl.LockingTransactionContext;
+import org.simantics.g2d.diagram.handler.impl.PickContextImpl;
 import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.ElementHints;
 import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.element.handler.ElementLayerListener;
+import org.simantics.g2d.elementclass.connection.ConnectionValidator;
 import org.simantics.g2d.layers.ILayer;
 
 public class DistrictDiagramClassAdapter extends DiagramClassAdapter {
 
-    static final SubstituteElementClass DINSTANCE = new DistrictDiagramSubstituteElementClass();
+    static final DiagramClass INSTANCE = DiagramClass.compile(
+            new PickContextImpl(true),
+            LockingTransactionContext.INSTANCE,
+            ConnectionValidator.INSTANCE,
+            DistrictDiagramSubstituteElementClass.INSTANCE
+    );
 
     @Override
     public void adapt(AsyncReadGraph g, Resource source, Resource r, AsyncProcedure<DiagramClass> procedure) {
-        procedure.execute(g, INSTANCE.newClassWith(DINSTANCE));
+        procedure.execute(g, INSTANCE);
     }
 
     static class DistrictDiagramElementLayerListenerImpl implements ElementLayerListener {
@@ -78,7 +86,9 @@ public class DistrictDiagramClassAdapter extends DiagramClassAdapter {
 
     static class DistrictDiagramSubstituteElementClass implements SubstituteElementClass {
 
-        static final ElementLayerListener LAYER_LISTENER = new DistrictDiagramElementLayerListenerImpl();
+        static final SubstituteElementClass INSTANCE = new DistrictDiagramSubstituteElementClass();
+
+        final ElementLayerListener LAYER_LISTENER = new DistrictDiagramElementLayerListenerImpl();
 
         @Override
         public ElementClass substitute(IDiagram d, ElementClass ec) {