X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FLogicUICanvas.java;h=08a40a452e1762edd8ec7829f3321a821f133349;hb=74bced7a3a38f65c65f3395cc422eb98e34da0b8;hp=4bc4f67268c619c1faf1d716ec992487ff2a0241;hpb=05e36ce451a394259e3ed21ea21ac3a1fd7d4e40;p=Mograsim.git 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 4bc4f672..08a40a45 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 @@ -104,9 +104,11 @@ public class LogicUICanvas extends ZoomableCanvas Text valueText = new Text(debugShell, SWT.SINGLE | SWT.LEAD | SWT.BORDER); valueText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Button send = new Button(debugShell, SWT.PUSH); - Text lastError = new Text(debugShell, SWT.READ_ONLY); - lastError.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); send.setText("Send!"); + Button get = new Button(debugShell, SWT.PUSH); + get.setText("Get!"); + Text output = new Text(debugShell, SWT.READ_ONLY); + output.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); Listener sendAction = e -> { try @@ -123,16 +125,30 @@ public class LogicUICanvas extends ZoomableCanvas else throw new RuntimeException("No value type selected"); target.setHighLevelState(stateIDText.getText(), value); - lastError.setText("Success!"); + output.setText("Success!"); } catch (Exception x) { - lastError.setText(x.getMessage()); + output.setText(x.getClass().getSimpleName() + (x.getMessage() == null ? "" : ": " + x.getMessage())); + } + }; + Listener getAction = e -> + { + try + { + if (componentSelector.getSelectionIndex() >= componentsByItemIndex.size()) + throw new RuntimeException("No valid component selected"); + output.setText("Success! Value: \r\n" + componentsByItemIndex.get(componentSelector.getSelectionIndex()).getHighLevelState(stateIDText.getText())); + } + catch (Exception x) + { + output.setText(x.getClass().getSimpleName() + (x.getMessage() == null ? "" : ": " + x.getMessage())); } }; - stateIDText.addListener(SWT.DefaultSelection, sendAction); - valueText.addListener(SWT.DefaultSelection, sendAction); send.addListener(SWT.Selection, sendAction); + valueText.addListener(SWT.DefaultSelection, sendAction); + get.addListener(SWT.Selection, getAction); + stateIDText.addListener(SWT.DefaultSelection, getAction); debugShell.open(); }