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=465db5e934d7efe01fe5e5bae3778c9187a8f7c3;hb=HEAD;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..465db5e93 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; @@ -257,8 +258,10 @@ public class ElementUtils { public static Collection getTerminals(IElement e, Collection result, boolean clearResult) { if (clearResult) result.clear(); - TerminalTopology tt = e.getElementClass().getSingleItem(TerminalTopology.class); - tt.getTerminals(e, result); + TerminalTopology tt = e.getElementClass().getAtMostOneItemOfClass(TerminalTopology.class); + if (tt != null) { + tt.getTerminals(e, result); + } return result; } @@ -350,6 +353,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 +1177,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)