From: Daniel Kirschten Date: Sun, 30 Jun 2019 13:17:25 +0000 (+0200) Subject: More helpful error message if no component is selected in LogicUICanvas X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=8638004215f29625847ea345f1cfadb446417c1f;p=Mograsim.git More helpful error message if no component is selected in LogicUICanvas --- diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java index 8e01a162..73c1f06b 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java @@ -113,9 +113,10 @@ public class LogicUICanvas extends ZoomableCanvas { try { - if (componentSelector.getSelectionIndex() >= componentsByItemIndex.size()) - throw new RuntimeException("No valid component selected"); - GUIComponent target = componentsByItemIndex.get(componentSelector.getSelectionIndex()); + int componentIndex = componentSelector.getSelectionIndex(); + if (componentIndex < 0 || componentIndex >= componentsByItemIndex.size()) + throw new RuntimeException("No component selected"); + GUIComponent target = componentsByItemIndex.get(componentIndex); String valueString = valueText.getText(); Object value; if (radioBit.getSelection())