auto-sync
This commit is contained in:
parent
547f96cac0
commit
8aa0a1adda
|
@ -21,8 +21,13 @@ import com.rusefi.ui.util.UiUtils;
|
||||||
import jssc.SerialPortList;
|
import jssc.SerialPortList;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
@ -39,7 +44,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
* @see EngineSnifferPanel
|
* @see EngineSnifferPanel
|
||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static final int CONSOLE_VERSION = 20170120;
|
public static final int CONSOLE_VERSION = 20170129;
|
||||||
public static final boolean SHOW_STIMULATOR = false;
|
public static final boolean SHOW_STIMULATOR = false;
|
||||||
private static final String TAB_INDEX = "main_tab";
|
private static final String TAB_INDEX = "main_tab";
|
||||||
protected static final String PORT_KEY = "port";
|
protected static final String PORT_KEY = "port";
|
||||||
|
@ -111,6 +116,7 @@ public class Launcher {
|
||||||
super.onWindowClosed();
|
super.onWindowClosed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private final Map<JComponent, ActionListener> tabSelectedListeners = new HashMap<JComponent, ActionListener>();
|
||||||
|
|
||||||
public Launcher(String port) {
|
public Launcher(String port) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
@ -148,11 +154,12 @@ public class Launcher {
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Formulas", new FormulasPane().getContent());
|
tabbedPane.addTab("Formulas", new FormulasPane().getContent());
|
||||||
|
|
||||||
tabbedPane.addTab("Engine Sniffer", engineSnifferPanel.getPanel());
|
tabbedPaneAdd("Engine Sniffer", engineSnifferPanel.getPanel(), engineSnifferPanel.getTabSelectedListener());
|
||||||
|
|
||||||
if (!LinkManager.isLogViewer())
|
|
||||||
tabbedPane.addTab("Sensor Sniffer", new SensorSnifferPane(getConfig().getRoot().getChild("sensor_sniffer")).getPanel());
|
|
||||||
|
|
||||||
|
if (!LinkManager.isLogViewer()) {
|
||||||
|
SensorSnifferPane sensorSniffer = new SensorSnifferPane(getConfig().getRoot().getChild("sensor_sniffer"));
|
||||||
|
tabbedPaneAdd("Sensor Sniffer", sensorSniffer.getPanel(), sensorSniffer.getTabSelectedListener());
|
||||||
|
}
|
||||||
|
|
||||||
// tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());
|
// tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());
|
||||||
|
|
||||||
|
@ -163,8 +170,10 @@ public class Launcher {
|
||||||
tabbedPane.add("ECU stimulation", stimulator.getPanel());
|
tabbedPane.add("ECU stimulation", stimulator.getPanel());
|
||||||
}
|
}
|
||||||
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl());
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer()) {
|
||||||
tabbedPane.add("Messages", new MessagesPane(getConfig().getRoot().getChild("messages")).getContent());
|
MessagesPane messagesPane = new MessagesPane(getConfig().getRoot().getChild("messages"));
|
||||||
|
tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener());
|
||||||
|
}
|
||||||
if (!LinkManager.isLogViewer())
|
if (!LinkManager.isLogViewer())
|
||||||
tabbedPane.addTab("Table Editor", tableEditor);
|
tabbedPane.addTab("Table Editor", tableEditor);
|
||||||
// tabbedPane.add("Wizards", new Wizard().createPane());
|
// tabbedPane.add("Wizards", new Wizard().createPane());
|
||||||
|
@ -185,10 +194,29 @@ public class Launcher {
|
||||||
tabbedPane.setSelectedIndex(selectedIndex);
|
tabbedPane.setSelectedIndex(selectedIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tabbedPane.addChangeListener(new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
if (e.getSource() instanceof JTabbedPane) {
|
||||||
|
JTabbedPane pane = (JTabbedPane) e.getSource();
|
||||||
|
int selectedIndex = pane.getSelectedIndex();
|
||||||
|
System.out.println("Selected paneNo: " + selectedIndex);
|
||||||
|
ActionListener actionListener = tabSelectedListeners.get(pane.getComponentAt(selectedIndex));
|
||||||
|
if (actionListener != null)
|
||||||
|
actionListener.actionPerformed(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
StartupFrame.setAppIcon(mainFrame.getFrame());
|
StartupFrame.setAppIcon(mainFrame.getFrame());
|
||||||
mainFrame.showFrame(tabbedPane);
|
mainFrame.showFrame(tabbedPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tabbedPaneAdd(String title, JComponent component, ActionListener tabSelectedListener) {
|
||||||
|
tabSelectedListeners.put(component, tabSelectedListener);
|
||||||
|
tabbedPane.add(title, component);
|
||||||
|
}
|
||||||
|
|
||||||
private void windowOpenedHandler() {
|
private void windowOpenedHandler() {
|
||||||
setTitle();
|
setTitle();
|
||||||
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
|
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class SensorSnifferPane {
|
||||||
private double maxY;
|
private double maxY;
|
||||||
|
|
||||||
private final JPanel content = new JPanel(new BorderLayout());
|
private final JPanel content = new JPanel(new BorderLayout());
|
||||||
|
private final AnyCommand command;
|
||||||
|
|
||||||
private boolean paused = false;
|
private boolean paused = false;
|
||||||
|
|
||||||
|
@ -85,7 +86,8 @@ public class SensorSnifferPane {
|
||||||
upperPanel.add(pauseButton);
|
upperPanel.add(pauseButton);
|
||||||
upperPanel.add(new RpmLabel(2).getContent());
|
upperPanel.add(new RpmLabel(2).getContent());
|
||||||
|
|
||||||
upperPanel.add(AnyCommand.createField(config, true, false).getContent());
|
command = AnyCommand.createField(config, true, false);
|
||||||
|
upperPanel.add(command.getContent());
|
||||||
|
|
||||||
upperPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL));
|
upperPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL));
|
||||||
pauseButton.addActionListener(new
|
pauseButton.addActionListener(new
|
||||||
|
@ -138,6 +140,15 @@ public class SensorSnifferPane {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionListener getTabSelectedListener() {
|
||||||
|
return new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
command.requestFocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private class SensorSnifferCanvas extends JComponent {
|
private class SensorSnifferCanvas extends JComponent {
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
|
|
@ -24,11 +24,12 @@ public class MessagesPane {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final JButton fontButton = new JButton("Font");
|
private final JButton fontButton = new JButton("Font");
|
||||||
|
private final AnyCommand command;
|
||||||
|
|
||||||
public MessagesPane(final Node config) {
|
public MessagesPane(final Node config) {
|
||||||
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
|
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
|
||||||
|
|
||||||
AnyCommand command = AnyCommand.createArea(config, config.getProperty(AnyCommand.KEY), true, false);
|
command = AnyCommand.createArea(config, config.getProperty(AnyCommand.KEY), true, false);
|
||||||
final MessagesPanel upperPanel = new MessagesPanel(command.getContent());
|
final MessagesPanel upperPanel = new MessagesPanel(command.getContent());
|
||||||
upperPanel.loadFont(config);
|
upperPanel.loadFont(config);
|
||||||
|
|
||||||
|
@ -67,4 +68,13 @@ public class MessagesPane {
|
||||||
public JComponent getContent() {
|
public JComponent getContent() {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionListener getTabSelectedListener() {
|
||||||
|
return new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
command.requestFocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -72,6 +72,7 @@ public class EngineSnifferPanel {
|
||||||
private final ChartScrollControl scrollControl;
|
private final ChartScrollControl scrollControl;
|
||||||
// todo: move it some sort of a singleton?
|
// todo: move it some sort of a singleton?
|
||||||
public final HashMap<String, String> channelName2PhysicalPin = new HashMap<>();
|
public final HashMap<String, String> channelName2PhysicalPin = new HashMap<>();
|
||||||
|
private AnyCommand command;
|
||||||
|
|
||||||
private boolean isPaused;
|
private boolean isPaused;
|
||||||
|
|
||||||
|
@ -112,8 +113,8 @@ public class EngineSnifferPanel {
|
||||||
upperPanel.add(new RpmLabel(2).getContent());
|
upperPanel.add(new RpmLabel(2).getContent());
|
||||||
|
|
||||||
if (!LinkManager.isLogViewer()) {
|
if (!LinkManager.isLogViewer()) {
|
||||||
JComponent command = AnyCommand.createField(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true, true).getContent();
|
command = AnyCommand.createField(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true, true);
|
||||||
upperPanel.add(command);
|
upperPanel.add(command.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
upperPanel.add(zoomControl);
|
upperPanel.add(zoomControl);
|
||||||
|
@ -320,6 +321,16 @@ public class EngineSnifferPanel {
|
||||||
scrollControl.reset();
|
scrollControl.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionListener getTabSelectedListener() {
|
||||||
|
return new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (command != null)
|
||||||
|
command.requestFocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The job of this comparator is to place Spark charts before Injection charts
|
* The job of this comparator is to place Spark charts before Injection charts
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class AnyCommand {
|
||||||
|
|
||||||
private AnyCommand(final JTextComponent text, final Node config, String defaultCommand, final boolean listenToCommands, boolean withCommandCaption) {
|
private AnyCommand(final JTextComponent text, final Node config, String defaultCommand, final boolean listenToCommands, boolean withCommandCaption) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
installCtrlEnterAction();
|
||||||
text.setText(defaultCommand);
|
text.setText(defaultCommand);
|
||||||
content.setBorder(BorderFactory.createLineBorder(Color.PINK));
|
content.setBorder(BorderFactory.createLineBorder(Color.PINK));
|
||||||
if (withCommandCaption) {
|
if (withCommandCaption) {
|
||||||
|
@ -61,7 +62,6 @@ public class AnyCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,6 +83,19 @@ public class AnyCommand {
|
||||||
// todo: limit the length of text in the text field
|
// todo: limit the length of text in the text field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void installCtrlEnterAction() {
|
||||||
|
text.setToolTipText("Ctrl-Enter to send");
|
||||||
|
text.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
|
||||||
|
java.awt.event.InputEvent.CTRL_DOWN_MASK),
|
||||||
|
"sendKey");
|
||||||
|
text.getActionMap().put("sendKey", new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
send();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void send() {
|
private void send() {
|
||||||
String cmd = text.getText();
|
String cmd = text.getText();
|
||||||
for (String s : cmd.split("\n"))
|
for (String s : cmd.split("\n"))
|
||||||
|
@ -123,6 +136,10 @@ public class AnyCommand {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void requestFocus() {
|
||||||
|
text.requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
void onSend();
|
void onSend();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue