]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Add possibility to substitute ElementClass instance in NodeRequest 11/311/1
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 1 Feb 2017 09:58:21 +0000 (11:58 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Wed, 1 Feb 2017 10:03:21 +0000 (12:03 +0200)
refs #6958

Change-Id: Ifab1b37b35c13a441b2fc6d3270d7d4706b481c3

bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/NodeRequest.java

index fba5de5065705053179ab50d695027d331369210..696ba52a25557a0c298059599a762dd18bd6081f 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.diagram.adapter;
 
+import java.util.List;
+
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.primitiverequest.Adapter;
@@ -20,6 +22,7 @@ import org.simantics.db.procedure.Listener;
 import org.simantics.diagram.synchronization.ErrorHandler;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.diagram.handler.SubstituteElementClass;
 import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.IElement;
 
@@ -106,8 +109,12 @@ public class NodeRequest extends BaseRequest2<Resource, IElement> {
                             }
 
                             @Override
-                            public void execute(AsyncReadGraph graph, final ElementClass clazz) {
-
+                            public void execute(AsyncReadGraph graph, ElementClass mutableClazz) {
+                                List<SubstituteElementClass> substitutes = diagram.getDiagramClass().getItemsByClass(SubstituteElementClass.class);
+                                for (SubstituteElementClass subs : substitutes) {
+                                    mutableClazz = subs.substitute(diagram, mutableClazz);
+                                }
+                                final ElementClass clazz = mutableClazz;
                                 graph.asyncRequest(new SpawnRequest(canvas, clazz, data), new TransientCacheAsyncListener<IElement>() {
 
                                     @Override