From ae28c4cc8162bc7b9cf9169492a55a2fde65f245 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 11 Nov 2021 19:15:36 -0500 Subject: [PATCH] Lua: send to ECU to resume output --- .../ui/src/main/java/com/rusefi/ui/MessagesPanel.java | 8 ++++---- .../src/main/java/com/rusefi/ui/lua/LuaScriptPanel.java | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/java_console/ui/src/main/java/com/rusefi/ui/MessagesPanel.java b/java_console/ui/src/main/java/com/rusefi/ui/MessagesPanel.java index 9ff2fd4405..08e9841426 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/MessagesPanel.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/MessagesPanel.java @@ -24,6 +24,7 @@ public class MessagesPanel { private final MessagesView messagesView; private final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); + private final JButton pauseButton = UiUtils.createPauseButton(); public MessagesPanel(JComponent extraButton, Node config) { JPanel middlePanel = new JPanel(new BorderLayout()); @@ -31,13 +32,12 @@ public class MessagesPanel { middlePanel.add(messagesView.messagesScroll, BorderLayout.CENTER); // buttonPanel.setBorder(BorderFactory.createLineBorder(Color.cyan)); - final JButton pauseButton = UiUtils.createPauseButton(); - pauseButton.addActionListener(event -> setPaused(pauseButton, !messagesView.isPaused())); + pauseButton.addActionListener(event -> setPaused(!messagesView.isPaused())); JButton clearButton = UiUtils.createClearButton(); clearButton.addActionListener(event -> { messagesView.clear(); - setPaused(pauseButton, false); + setPaused(false); }); buttonPanel.add(clearButton); @@ -46,7 +46,7 @@ public class MessagesPanel { buttonPanel.add(extraButton); } - private void setPaused(JButton pauseButton, boolean isPaused) { + public void setPaused(boolean isPaused) { messagesView.setPaused(isPaused); UiUtils.setPauseButtonText(pauseButton, messagesView.isPaused()); } diff --git a/java_console/ui/src/main/java/com/rusefi/ui/lua/LuaScriptPanel.java b/java_console/ui/src/main/java/com/rusefi/ui/lua/LuaScriptPanel.java index 05e7deca8c..a6768cbdf1 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/lua/LuaScriptPanel.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/lua/LuaScriptPanel.java @@ -36,8 +36,14 @@ public class LuaScriptPanel { JButton writeButton = new JButton("Write to ECU"); JButton resetButton = new JButton("Reset/Reload Lua"); + MessagesPanel mp = new MessagesPanel(null, config); + readButton.addActionListener(e -> readFromECU()); - writeButton.addActionListener(e -> write()); + writeButton.addActionListener(e -> { + write(); + // resume messages on 'write new script to ECU' + mp.setPaused(false); + }); resetButton.addActionListener(e -> resetLua()); upperPanel.add(readButton); @@ -52,7 +58,6 @@ public class LuaScriptPanel { //centerPanel.add(, BorderLayout.WEST); JPanel messagesPanel = new JPanel(new BorderLayout()); - MessagesPanel mp = new MessagesPanel(null, config); messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel()); messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());