X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felement%2FElementUtils.java;h=300e74d31e75e04ee7ecf750ab0b2e58ba513951;hb=059e997dd3e02030c3981f1a35e1d2848965109f;hp=1a12210f0912c23ccc2fbd1ea01fcdcb246a4e4a;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java index 1a12210f0..300e74d31 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java @@ -49,6 +49,7 @@ import org.simantics.g2d.element.handler.Hover; import org.simantics.g2d.element.handler.InternalSize; import org.simantics.g2d.element.handler.Move; import org.simantics.g2d.element.handler.Outline; +import org.simantics.g2d.element.handler.Parameters; import org.simantics.g2d.element.handler.Parent; import org.simantics.g2d.element.handler.Pick; import org.simantics.g2d.element.handler.Resize; @@ -350,6 +351,18 @@ public class ElementUtils { e.getElementClass().getSingleItem(Transform.class).setTransform(e, at); } + public static void setParameters(IElement e, Map parameters) + { + Parameters ps = e.getElementClass().getSingleItem(Parameters.class); + if(ps != null) ps.setParameters(e, parameters); + } + + public static Map getParameters(IElement e) + { + Parameters ps = e.getElementClass().getAtMostOneItemOfClass(Parameters.class); + return ps != null ? ps.getParameters(e) : null; + } + public static AffineTransform getInvTransform(IElement e) { try { @@ -1162,7 +1175,7 @@ public class ElementUtils { // If the previously available node is not a parent of the specified // node create a new node under the specified parent and set that // as the node of the specified element. - if (!node.getParent().equals(withParentNode)) { + if (!withParentNode.equals(node.getParent())) { node = nodeId != null ? withParentNode.getOrCreateNode(nodeId, nodeClass) : withParentNode.addNode(nodeClass); forElement.setHint(withNodeKey, node); if (nodeCreationCallback != null)