From: jsimomaa Date: Wed, 1 Feb 2017 09:58:21 +0000 (+0200) Subject: Add possibility to substitute ElementClass instance in NodeRequest X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F311%2F1;p=simantics%2Fplatform.git Add possibility to substitute ElementClass instance in NodeRequest refs #6958 Change-Id: Ifab1b37b35c13a441b2fc6d3270d7d4706b481c3 --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/NodeRequest.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/NodeRequest.java index fba5de506..696ba52a2 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/NodeRequest.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/NodeRequest.java @@ -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 { } @Override - public void execute(AsyncReadGraph graph, final ElementClass clazz) { - + public void execute(AsyncReadGraph graph, ElementClass mutableClazz) { + List 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() { @Override