Don't assume that Element provides TerminalTopology
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 7 Nov 2018 13:52:57 +0000 (15:52 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 14 Nov 2018 11:05:34 +0000 (13:05 +0200)
(cherry picked from commit c0940268d6e3551f5c700d677073bf754ce8eaad)

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;
     }