From: Tuukka Lehtonen Date: Sat, 7 Oct 2017 20:59:13 +0000 (+0300) Subject: More robustness fixes for editing of texts inside SVG elements. X-Git-Tag: v1.31.0~139 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=19fa38f6cd07e0917e5f25e009a90617ce431488;p=simantics%2Fplatform.git More robustness fixes for editing of texts inside SVG elements. refs #7458 Change-Id: I5cd30ed29229147b2dd1adf3862f1cd2cea99f60 --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/SVGNode.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/SVGNode.java index 4d6547919..0b1ee8b0d 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/SVGNode.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/SVGNode.java @@ -129,7 +129,7 @@ public class SVGNode extends org.simantics.scenegraph.g2d.nodes.SVGNode { } SingleElementNode getSingleElementNode() { - return (SingleElementNode)NodeUtil.getNearestParentOfType(this, SingleElementNode.class); + return (SingleElementNode)NodeUtil.getPossibleNearestParentOfType(this, SingleElementNode.class); } @Override diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java index 615899a59..9439369a5 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java @@ -97,6 +97,18 @@ public final class NodeUtil { } } + public static INode getPossibleNearestParentOfType(INode node, Class clazz) { + ParentNode parent = null; + while (true) { + parent = node.getParent(); + if (parent == null) + return null; + node = parent; + if (clazz.isInstance(node)) + return node; + } + } + public static INode getRootNode(INode node) { ParentNode parent = null; while (true) {