]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Don't assume that Element provides TerminalTopology
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 7 Nov 2018 13:52:57 +0000 (15:52 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Tue, 13 Nov 2018 04:51:57 +0000 (06:51 +0200)
bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java

index 300e74d31e75e04ee7ecf750ab0b2e58ba513951..465db5e934d7efe01fe5e5bae3778c9187a8f7c3 100644 (file)
@@ -258,8 +258,10 @@ public class ElementUtils {
     public static Collection<Terminal> getTerminals(IElement e, Collection<Terminal> 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;
     }