From 4dc9d3a7472053613a6a969ae60b57d43d61576a Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 1 Feb 2017 11:58:21 +0200 Subject: [PATCH] Add possibility to substitute ElementClass instance in NodeRequest refs #6958 Change-Id: Ifab1b37b35c13a441b2fc6d3270d7d4706b481c3 --- .../org/simantics/diagram/adapter/NodeRequest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 -- 2.47.1