More helpful error message if no component is selected in LogicUICanvas
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 30 Jun 2019 13:17:25 +0000 (15:17 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 30 Jun 2019 13:17:25 +0000 (15:17 +0200)
net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUICanvas.java

index 8e01a16..73c1f06 100644 (file)
@@ -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())