Scrollable stable message list in the rusefi_Console fix #3303
hopefully good enough for progress
This commit is contained in:
parent
d73740d55b
commit
e5464fb6bb
|
@ -6,7 +6,7 @@ import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20210930;
|
public static final int CONSOLE_VERSION = 20211003;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
public static long classBuildTimeMillis() {
|
public static long classBuildTimeMillis() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.ui.MessagesView;
|
import com.rusefi.ui.MessagesView;
|
||||||
import com.rusefi.ui.UIContext;
|
import com.rusefi.ui.UIContext;
|
||||||
|
import com.rusefi.ui.storage.PersistentConfiguration;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ public class BenchTestPane {
|
||||||
private final JPanel content = new JPanel(new GridLayout(2, 5));
|
private final JPanel content = new JPanel(new GridLayout(2, 5));
|
||||||
private final UIContext uiContext;
|
private final UIContext uiContext;
|
||||||
|
|
||||||
public BenchTestPane(UIContext uiContext) {
|
public BenchTestPane(UIContext uiContext, PersistentConfiguration config) {
|
||||||
this.uiContext = uiContext;
|
this.uiContext = uiContext;
|
||||||
content.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
content.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ public class BenchTestPane {
|
||||||
return Fields.CMD_REBOOT_DFU;
|
return Fields.CMD_REBOOT_DFU;
|
||||||
}
|
}
|
||||||
}.getContent());
|
}.getContent());
|
||||||
content.add(new MessagesView().messagesScroll);
|
content.add(new MessagesView(config.getRoot()).messagesScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component grabPerformanceTrace() {
|
private Component grabPerformanceTrace() {
|
||||||
|
|
|
@ -96,14 +96,14 @@ public class ConsoleUI {
|
||||||
uiContext.DetachedRepositoryINSTANCE.init(getConfig().getRoot().getChild("detached"));
|
uiContext.DetachedRepositoryINSTANCE.init(getConfig().getRoot().getChild("detached"));
|
||||||
uiContext.DetachedRepositoryINSTANCE.load();
|
uiContext.DetachedRepositoryINSTANCE.load();
|
||||||
if (!linkManager.isLogViewer())
|
if (!linkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Gauges", new GaugesPanel(uiContext, getConfig().getRoot().getChild("gauges"), tabbedPane.paneSettings).getContent());
|
tabbedPane.addTab("Gauges", new GaugesPanel(uiContext, getConfig().getRoot().getChild("gauges")).getContent());
|
||||||
|
|
||||||
if (!linkManager.isLogViewer()) {
|
if (!linkManager.isLogViewer()) {
|
||||||
MessagesPane messagesPane = new MessagesPane(uiContext, getConfig().getRoot().getChild("messages"));
|
MessagesPane messagesPane = new MessagesPane(uiContext, getConfig().getRoot().getChild("messages"));
|
||||||
tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener());
|
tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener());
|
||||||
}
|
}
|
||||||
if (!linkManager.isLogViewer()) {
|
if (!linkManager.isLogViewer()) {
|
||||||
tabbedPane.addTab("Bench Test", new BenchTestPane(uiContext).getContent());
|
tabbedPane.addTab("Bench Test", new BenchTestPane(uiContext, getConfig()).getContent());
|
||||||
if (tabbedPane.paneSettings.showEtbPane)
|
if (tabbedPane.paneSettings.showEtbPane)
|
||||||
tabbedPane.addTab("ETB", new ETBPane(uiContext).getContent());
|
tabbedPane.addTab("ETB", new ETBPane(uiContext).getContent());
|
||||||
tabbedPane.addTab("Presets", new PresetsPane(uiContext).getContent());
|
tabbedPane.addTab("Presets", new PresetsPane(uiContext).getContent());
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class GaugesPanel {
|
||||||
private final JPanel messagesPanel = new JPanel(new BorderLayout());
|
private final JPanel messagesPanel = new JPanel(new BorderLayout());
|
||||||
private final JSplitPane middleSplitPanel;
|
private final JSplitPane middleSplitPanel;
|
||||||
|
|
||||||
public GaugesPanel(UIContext uiContext, final Node config, PaneSettings paneSettings) {
|
public GaugesPanel(UIContext uiContext, final Node config) {
|
||||||
this.uiContext = uiContext;
|
this.uiContext = uiContext;
|
||||||
gauges = new GaugesGrid(DEFAULT_ROWS, DEFAULT_COLUMNS);
|
gauges = new GaugesGrid(DEFAULT_ROWS, DEFAULT_COLUMNS);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -101,7 +101,7 @@ public class GaugesPanel {
|
||||||
|
|
||||||
content.add(middleSplitPanel, BorderLayout.CENTER);
|
content.add(middleSplitPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
content.add(new WarningPanel().getPanel(), BorderLayout.SOUTH);
|
content.add(new WarningPanel(config).getPanel(config), BorderLayout.SOUTH);
|
||||||
|
|
||||||
applyShowFlags();
|
applyShowFlags();
|
||||||
final int splitLocation = config.getIntProperty(SPLIT_LOCATION, -1);
|
final int splitLocation = config.getIntProperty(SPLIT_LOCATION, -1);
|
||||||
|
@ -203,7 +203,7 @@ public class GaugesPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareMessagesPanel() {
|
private void prepareMessagesPanel() {
|
||||||
MessagesPanel mp = new MessagesPanel(null);
|
MessagesPanel mp = new MessagesPanel(null, config);
|
||||||
messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
||||||
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.rusefi.ui;
|
||||||
|
|
||||||
|
import com.rusefi.ui.storage.Node;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
public class LogSizeControl {
|
||||||
|
private static final String LINES = "SCREEN_LOG_LINES";
|
||||||
|
|
||||||
|
private final JPanel content = new JPanel(new FlowLayout());
|
||||||
|
|
||||||
|
public LogSizeControl(Node config) {
|
||||||
|
content.add(new JLabel("On screen lines: "));
|
||||||
|
JTextField lines = new JTextField(8);
|
||||||
|
content.add(lines);
|
||||||
|
lines.setText(Integer.toString(getValue(config)));
|
||||||
|
lines.addActionListener(new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent ev) {
|
||||||
|
int value;
|
||||||
|
try {
|
||||||
|
value = Integer.parseInt(lines.getText());
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
config.setProperty(LINES, Integer.toString(value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getValue(Node config) {
|
||||||
|
return config.getIntProperty(LINES, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,10 @@ import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One of console top level tabs
|
||||||
|
* @see MessagesPanel
|
||||||
|
*/
|
||||||
public class MessagesPane {
|
public class MessagesPane {
|
||||||
private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:Software:dev_console_commands";
|
private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:Software:dev_console_commands";
|
||||||
|
|
||||||
|
@ -30,7 +34,7 @@ public class MessagesPane {
|
||||||
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
|
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
|
||||||
|
|
||||||
command = AnyCommand.createArea(uiContext, config, config.getProperty(AnyCommand.KEY), true, false);
|
command = AnyCommand.createArea(uiContext, config, config.getProperty(AnyCommand.KEY), true, false);
|
||||||
final MessagesPanel upperPanel = new MessagesPanel(command.getContent());
|
final MessagesPanel upperPanel = new MessagesPanel(command.getContent(), config);
|
||||||
upperPanel.loadFont(config);
|
upperPanel.loadFont(config);
|
||||||
|
|
||||||
JPanel middlePanel = new JPanel(new BorderLayout());
|
JPanel middlePanel = new JPanel(new BorderLayout());
|
||||||
|
@ -49,7 +53,7 @@ public class MessagesPane {
|
||||||
|
|
||||||
statsPanel.add(new RpmLabel(uiContext).getContent());
|
statsPanel.add(new RpmLabel(uiContext).getContent());
|
||||||
statsPanel.add(new IdleLabel());
|
statsPanel.add(new IdleLabel());
|
||||||
statsPanel.add(new WarningPanel().getPanel());
|
statsPanel.add(new WarningPanel(config).getPanel(config));
|
||||||
|
|
||||||
content.add(statsPanel, BorderLayout.SOUTH);
|
content.add(statsPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
@ -70,11 +74,6 @@ public class MessagesPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionListener getTabSelectedListener() {
|
public ActionListener getTabSelectedListener() {
|
||||||
return new ActionListener() {
|
return e -> command.requestFocus();
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
command.requestFocus();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,17 +15,19 @@ import java.awt.*;
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
*
|
*
|
||||||
* @see AnyCommand
|
* @see AnyCommand
|
||||||
|
* @see MessagesView
|
||||||
*/
|
*/
|
||||||
public class MessagesPanel {
|
public class MessagesPanel {
|
||||||
private static final String FONT_SIZE = "font_size";
|
private static final String FONT_SIZE = "font_size";
|
||||||
private static final String FONT_NAME = "font_name";
|
private static final String FONT_NAME = "font_name";
|
||||||
|
|
||||||
private final MessagesView messagesView = new MessagesView();
|
private final MessagesView messagesView;
|
||||||
|
|
||||||
private final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
|
private final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
|
||||||
|
|
||||||
public MessagesPanel(JComponent extraButton) {
|
public MessagesPanel(JComponent extraButton, Node config) {
|
||||||
JPanel middlePanel = new JPanel(new BorderLayout());
|
JPanel middlePanel = new JPanel(new BorderLayout());
|
||||||
|
messagesView = new MessagesView(config);
|
||||||
middlePanel.add(messagesView.messagesScroll, BorderLayout.CENTER);
|
middlePanel.add(messagesView.messagesScroll, BorderLayout.CENTER);
|
||||||
// buttonPanel.setBorder(BorderFactory.createLineBorder(Color.cyan));
|
// buttonPanel.setBorder(BorderFactory.createLineBorder(Color.cyan));
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.opensr5.Logger;
|
||||||
import com.rusefi.core.EngineState;
|
import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.CommandQueue;
|
import com.rusefi.io.CommandQueue;
|
||||||
|
import com.rusefi.ui.storage.Node;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -21,13 +22,15 @@ public class MessagesView {
|
||||||
|
|
||||||
private final Style bold;
|
private final Style bold;
|
||||||
private final Style italic;
|
private final Style italic;
|
||||||
|
private final Node config;
|
||||||
|
|
||||||
private boolean isPaused;
|
private boolean isPaused;
|
||||||
|
|
||||||
protected final JTextPane messages = new JTextPane();
|
protected final JTextPane messages = new JTextPane();
|
||||||
public final JScrollPane messagesScroll = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
public final JScrollPane messagesScroll = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||||
|
|
||||||
public MessagesView() {
|
public MessagesView(Node config) {
|
||||||
|
this.config = config;
|
||||||
messages.setEditable(false);
|
messages.setEditable(false);
|
||||||
|
|
||||||
JPopupMenu menu = createPopupMenu();
|
JPopupMenu menu = createPopupMenu();
|
||||||
|
@ -105,8 +108,9 @@ does not work? maybe wrong UI colors since control is not editable?
|
||||||
|
|
||||||
private void append(String line, Class clazz) {
|
private void append(String line, Class clazz) {
|
||||||
Document d = messages.getDocument();
|
Document d = messages.getDocument();
|
||||||
if (d.getLength() > MAX_SIZE)
|
int logSizeControl = LogSizeControl.getValue(config);
|
||||||
clearMessages(d);
|
if (d.getLength() > logSizeControl)
|
||||||
|
clearMessages(d, logSizeControl);
|
||||||
try {
|
try {
|
||||||
d.insertString(d.getLength(), line + "\r\n", getStyle(clazz));
|
d.insertString(d.getLength(), line + "\r\n", getStyle(clazz));
|
||||||
messages.select(d.getLength(), d.getLength());
|
messages.select(d.getLength(), d.getLength());
|
||||||
|
@ -129,9 +133,9 @@ does not work? maybe wrong UI colors since control is not editable?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void clearMessages(Document d) {
|
private void clearMessages(Document d, int logSizeControl) {
|
||||||
try {
|
try {
|
||||||
d.remove(0, d.getLength());
|
d.remove(0, d.getLength() - logSizeControl / 2);
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +143,7 @@ does not work? maybe wrong UI colors since control is not editable?
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
Document d = messages.getDocument();
|
Document d = messages.getDocument();
|
||||||
clearMessages(d);
|
clearMessages(d, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPaused(boolean isPaused) {
|
public void setPaused(boolean isPaused) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.rusefi.ui;
|
||||||
import com.rusefi.FileLog;
|
import com.rusefi.FileLog;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
|
import com.rusefi.ui.storage.Node;
|
||||||
import com.rusefi.ui.util.UiUtils;
|
import com.rusefi.ui.util.UiUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -26,7 +27,7 @@ public class WarningPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public WarningPanel() {
|
public WarningPanel(Node config) {
|
||||||
label.setForeground(Color.red);
|
label.setForeground(Color.red);
|
||||||
panel.add(label);
|
panel.add(label);
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ public class WarningPanel {
|
||||||
panel.add(reset);
|
panel.add(reset);
|
||||||
// todo: only display label if logs are being recorded
|
// todo: only display label if logs are being recorded
|
||||||
panel.add(new JLabel(FileLog.LOG_INFO_TEXT));
|
panel.add(new JLabel(FileLog.LOG_INFO_TEXT));
|
||||||
|
panel.add(new LogSizeControl(config).getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear() {
|
private void clear() {
|
||||||
|
@ -72,7 +74,7 @@ public class WarningPanel {
|
||||||
reset.setEnabled(false);
|
reset.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getPanel() {
|
public JPanel getPanel(Node config) {
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class EngineSnifferPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
mainPanel.add(chartPanel, BorderLayout.CENTER);
|
mainPanel.add(chartPanel, BorderLayout.CENTER);
|
||||||
mainPanel.add(new WarningPanel().getPanel(), BorderLayout.SOUTH);
|
mainPanel.add(new WarningPanel(config).getPanel(config), BorderLayout.SOUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPaused(JButton pauseButton, boolean isPaused) {
|
private void setPaused(JButton pauseButton, boolean isPaused) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class LuaScriptPanel {
|
||||||
|
|
||||||
//centerPanel.add(, BorderLayout.WEST);
|
//centerPanel.add(, BorderLayout.WEST);
|
||||||
JPanel messagesPanel = new JPanel(new BorderLayout());
|
JPanel messagesPanel = new JPanel(new BorderLayout());
|
||||||
MessagesPanel mp = new MessagesPanel(null);
|
MessagesPanel mp = new MessagesPanel(null, config);
|
||||||
messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
messagesPanel.add(BorderLayout.NORTH, mp.getButtonPanel());
|
||||||
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue