diff --git a/java_console/io/src/com/rusefi/io/LinkManager.java b/java_console/io/src/com/rusefi/io/LinkManager.java index f2db611925..82bc5b889c 100644 --- a/java_console/io/src/com/rusefi/io/LinkManager.java +++ b/java_console/io/src/com/rusefi/io/LinkManager.java @@ -9,6 +9,7 @@ import com.rusefi.io.tcp.TcpConnector; import org.jetbrains.annotations.NotNull; import java.util.Arrays; +import java.util.Objects; import java.util.concurrent.*; /** @@ -142,11 +143,13 @@ public class LinkManager { public static boolean isSimulationMode; public static void startAndConnect(String port, ConnectionStateListener stateListener) { + Objects.requireNonNull(port, "port"); start(port); connector.connectAndReadConfiguration(stateListener); } public static void start(String port) { + Objects.requireNonNull(port, "port"); FileLog.MAIN.logLine("LinkManager: Starting " + port); if (isLogViewerMode(port)) { connector = LinkConnector.VOID; @@ -159,6 +162,7 @@ public class LinkManager { } public static boolean isLogViewerMode(String port) { + Objects.requireNonNull(port, "port"); return port.equals(LOG_VIEWER); } diff --git a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java index b769b58aa3..e85125ab47 100644 --- a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java +++ b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java @@ -65,7 +65,7 @@ import javax.swing.JTextArea; import javax.swing.SwingWorker; import javax.swing.tree.TreePath; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -73,7 +73,6 @@ import org.xml.sax.SAXParseException; import com.romraider.Settings; import com.romraider.maps.Rom; -import com.romraider.swing.AbstractFrame; import com.romraider.swing.CustomToolbarLayout; import com.romraider.swing.ECUEditorMenuBar; import com.romraider.swing.ECUEditorToolBar; @@ -164,7 +163,7 @@ public class ECUEditor { // frame.setIconImage(editorIcon.getImage()); // frame.setDefaultCloseOperation(AbstractFrame.EXIT_ON_CLOSE); - Launcher.getFrame().addWindowListener(wListenr); + ConsoleUI.getFrame().addWindowListener(wListenr); // frame.setTitle(titleText); // frame.setVisible(true); // frame.toFront(); @@ -257,7 +256,7 @@ public class ECUEditor { if (answer == 0) { // BrowserControl.displayURL(ECU_DEFS_URL); } else { - showMessageDialog(Launcher.getFrame(), + showMessageDialog(ConsoleUI.getFrame(), "ECU definition files need to be configured before ROM images can be opened.\nMenu: ECU Definitions > ECU Definition Manager...", "Editor Configuration", INFORMATION_MESSAGE); @@ -286,7 +285,7 @@ public class ECUEditor { JScrollPane scroller = new JScrollPane(releaseNotes, VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_NEVER); scroller.setPreferredSize(new Dimension(600, 500)); - showMessageDialog(Launcher.getFrame(), scroller, + showMessageDialog(ConsoleUI.getFrame(), scroller, PRODUCT_NAME + VERSION + " Release Notes", INFORMATION_MESSAGE); } finally { br.close(); @@ -355,7 +354,7 @@ public class ECUEditor { }); infoPanel.add(check); - showMessageDialog(Launcher.getFrame(), infoPanel, "ECU Revision is Obsolete", INFORMATION_MESSAGE); + showMessageDialog(ConsoleUI.getFrame(), infoPanel, "ECU Revision is Obsolete", INFORMATION_MESSAGE); } } @@ -414,7 +413,7 @@ public class ECUEditor { } public void closeImage() { - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); closeImageWorker = new CloseImageWorker(getLastSelectedRom()); closeImageWorker.addPropertyChangeListener(getStatusPanel()); closeImageWorker.execute(); @@ -507,7 +506,7 @@ public class ECUEditor { } public void openImage(File inputFile) throws Exception { - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); openImageWorker = new OpenImageWorker(inputFile); openImageWorker.addPropertyChangeListener(getStatusPanel()); openImageWorker.execute(); @@ -526,7 +525,7 @@ public class ECUEditor { } public void launchLogger() { - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // launchLoggerWorker = new LaunchLoggerWorker(); // launchLoggerWorker.addPropertyChangeListener(getStatusPanel()); // launchLoggerWorker.execute(); @@ -575,7 +574,7 @@ class LaunchLoggerWorker extends SwingWorker { ECUEditor editor = ECUEditorManager.getECUEditor(); editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); editor.refreshUI(); } } @@ -605,7 +604,7 @@ class SetUserLevelWorker extends SwingWorker { ECUEditor editor = ECUEditorManager.getECUEditor(); editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); editor.refreshUI(); } } @@ -643,7 +642,7 @@ class CloseImageWorker extends SwingWorker { ECUEditor editor = ECUEditorManager.getECUEditor(); editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); editor.refreshUI(); System.gc(); } @@ -686,23 +685,23 @@ class OpenImageWorker extends SwingWorker { } // if code executes to this point, no ROM was found, report to user - showMessageDialog(Launcher.getFrame(), "ECU Definition Not Found", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); + showMessageDialog(ConsoleUI.getFrame(), "ECU Definition Not Found", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); } catch (SAXParseException spe) { // catch general parsing exception - enough people don't unzip the defs that a better error message is in order - showMessageDialog(Launcher.getFrame(), "Unable to read XML definitions. Please make sure the definition file is correct. If it is in a ZIP archive, unzip the file and try again.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); + showMessageDialog(ConsoleUI.getFrame(), "Unable to read XML definitions. Please make sure the definition file is correct. If it is in a ZIP archive, unzip the file and try again.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); } catch (StackOverflowError ex) { // handles looped inheritance, which will use up all available memory - showMessageDialog(Launcher.getFrame(), "Looped \"base\" attribute in XML definitions.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); + showMessageDialog(ConsoleUI.getFrame(), "Looped \"base\" attribute in XML definitions.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); } catch (OutOfMemoryError ome) { // handles Java heap space issues when loading multiple Roms. - showMessageDialog(Launcher.getFrame(), "Error loading Image. Out of memeory.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); + showMessageDialog(ConsoleUI.getFrame(), "Error loading Image. Out of memeory.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); } catch (Exception ex) { ex.printStackTrace(); - showMessageDialog(Launcher.getFrame(), "Error Loading. Unknown Exception.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); + showMessageDialog(ConsoleUI.getFrame(), "Error Loading. Unknown Exception.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE); } return null; } @@ -720,7 +719,7 @@ class OpenImageWorker extends SwingWorker { ECUEditor editor = ECUEditorManager.getECUEditor(); editor.getStatusPanel().setStatus("Ready..."); setProgress(0); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); editor.refreshUI(); System.gc(); } diff --git a/java_console/romraider/src/com/romraider/maps/CopySelection2DWorker.java b/java_console/romraider/src/com/romraider/maps/CopySelection2DWorker.java index 32b55a02ec..03938831d0 100644 --- a/java_console/romraider/src/com/romraider/maps/CopySelection2DWorker.java +++ b/java_console/romraider/src/com/romraider/maps/CopySelection2DWorker.java @@ -1,6 +1,6 @@ package com.romraider.maps; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.swing.*; import java.awt.*; @@ -27,7 +27,7 @@ class CopySelection2DWorker extends SwingWorker { ancestorWindow.setCursor(null); } table.setCursor(null); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); } } diff --git a/java_console/romraider/src/com/romraider/maps/CopySelectionWorker.java b/java_console/romraider/src/com/romraider/maps/CopySelectionWorker.java index 75802aef51..5693a2dd80 100644 --- a/java_console/romraider/src/com/romraider/maps/CopySelectionWorker.java +++ b/java_console/romraider/src/com/romraider/maps/CopySelectionWorker.java @@ -1,6 +1,6 @@ package com.romraider.maps; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.swing.*; import java.awt.*; @@ -60,7 +60,7 @@ class CopySelectionWorker extends SwingWorker { ancestorWindow.setCursor(null); } table.setCursor(null); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); } } diff --git a/java_console/romraider/src/com/romraider/maps/CopyTable2DWorker.java b/java_console/romraider/src/com/romraider/maps/CopyTable2DWorker.java index f9a3de4cc7..40b236deb8 100644 --- a/java_console/romraider/src/com/romraider/maps/CopyTable2DWorker.java +++ b/java_console/romraider/src/com/romraider/maps/CopyTable2DWorker.java @@ -1,6 +1,6 @@ package com.romraider.maps; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.swing.*; import java.awt.*; @@ -33,6 +33,6 @@ class CopyTable2DWorker extends SwingWorker { ancestorWindow.setCursor(null); } table.setCursor(null); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); } } \ No newline at end of file diff --git a/java_console/romraider/src/com/romraider/maps/CopyTableWorker.java b/java_console/romraider/src/com/romraider/maps/CopyTableWorker.java index 91b935bc26..22a6651304 100644 --- a/java_console/romraider/src/com/romraider/maps/CopyTableWorker.java +++ b/java_console/romraider/src/com/romraider/maps/CopyTableWorker.java @@ -1,6 +1,6 @@ package com.romraider.maps; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.swing.*; import java.awt.*; @@ -29,6 +29,6 @@ class CopyTableWorker extends SwingWorker { ancestorWindow.setCursor(null); } table.setCursor(null); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); } } \ No newline at end of file diff --git a/java_console/romraider/src/com/romraider/maps/Table.java b/java_console/romraider/src/com/romraider/maps/Table.java index 17aabdd930..d58e460da6 100644 --- a/java_console/romraider/src/com/romraider/maps/Table.java +++ b/java_console/romraider/src/com/romraider/maps/Table.java @@ -24,8 +24,7 @@ import com.romraider.editor.ecu.ECUEditorManager; import com.romraider.swing.TableToolBar; import com.romraider.util.JEPUtil; import com.romraider.util.SettingsManager; -import com.romraider.xml.RomAttributeParser; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.naming.NameNotFoundException; import javax.swing.*; @@ -35,7 +34,6 @@ import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import java.io.IOException; import java.io.Serializable; import java.util.StringTokenizer; @@ -877,7 +875,7 @@ public abstract class Table extends JPanel implements Serializable { ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); copySelectionWorker = new CopySelectionWorker(this); copySelectionWorker.execute(); @@ -899,7 +897,7 @@ public abstract class Table extends JPanel implements Serializable { if(null != ancestorWindow) { ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); copyTableWorker = new CopyTableWorker(this); copyTableWorker.execute(); diff --git a/java_console/romraider/src/com/romraider/maps/Table2D.java b/java_console/romraider/src/com/romraider/maps/Table2D.java index 44829ca696..79b3b14e25 100644 --- a/java_console/romraider/src/com/romraider/maps/Table2D.java +++ b/java_console/romraider/src/com/romraider/maps/Table2D.java @@ -21,7 +21,7 @@ package com.romraider.maps; import com.romraider.Settings; import com.romraider.util.SettingsManager; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.naming.NameNotFoundException; import javax.swing.*; @@ -241,7 +241,7 @@ public class Table2D extends TableWithData { if(null != ancestorWindow) { ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); super.copySelection(); copySelection2DWorker = new CopySelection2DWorker(this); @@ -254,7 +254,7 @@ public class Table2D extends TableWithData { if(null != ancestorWindow) { ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); CopyTable2DWorker copyTable2DWorker = new CopyTable2DWorker(this); copyTable2DWorker.execute(); diff --git a/java_console/romraider/src/com/romraider/maps/Table3D.java b/java_console/romraider/src/com/romraider/maps/Table3D.java index b3fcfbf8dd..94fce2fd79 100644 --- a/java_console/romraider/src/com/romraider/maps/Table3D.java +++ b/java_console/romraider/src/com/romraider/maps/Table3D.java @@ -47,7 +47,7 @@ import com.romraider.editor.ecu.ECUEditorManager; import com.romraider.logger.ecu.ui.swing.vertical.VerticalLabelUI; import com.romraider.util.SettingsManager; import com.romraider.xml.RomAttributeParser; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; public class Table3D extends Table { @@ -676,7 +676,7 @@ public class Table3D extends Table { if(null != ancestorWindow) { ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); copySelection3DWorker = new CopySelection3DWorker(this); copySelection3DWorker.execute(); @@ -688,7 +688,7 @@ public class Table3D extends Table { if(null != ancestorWindow) { ancestorWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } - Launcher.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ConsoleUI.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); copyTable3DWorker = new CopyTable3DWorker(this); copyTable3DWorker.execute(); @@ -1108,7 +1108,7 @@ class CopySelection3DWorker extends SwingWorker { ancestorWindow.setCursor(null); } table.setCursor(null); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); } } @@ -1136,6 +1136,6 @@ class CopyTable3DWorker extends SwingWorker { ancestorWindow.setCursor(null); } table.setCursor(null); - Launcher.getFrame().setCursor(null); + ConsoleUI.getFrame().setCursor(null); } } diff --git a/java_console/romraider/src/com/romraider/swing/DefinitionManager.java b/java_console/romraider/src/com/romraider/swing/DefinitionManager.java index 84312f1376..6776da9ae9 100644 --- a/java_console/romraider/src/com/romraider/swing/DefinitionManager.java +++ b/java_console/romraider/src/com/romraider/swing/DefinitionManager.java @@ -28,9 +28,8 @@ import java.util.Vector; import javax.swing.JFileChooser; import javax.swing.ListSelectionModel; -import com.romraider.editor.ecu.ECUEditorManager; import com.romraider.util.SettingsManager; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; public class DefinitionManager extends javax.swing.JFrame implements ActionListener { @@ -41,7 +40,7 @@ public class DefinitionManager extends javax.swing.JFrame implements ActionListe Vector fileNames; public DefinitionManager() { - this.setIconImage(Launcher.getFrame().getIconImage()); + this.setIconImage(ConsoleUI.getFrame().getIconImage()); initComponents(); initSettings(); diff --git a/java_console/romraider/src/com/romraider/swing/ECUEditorMenuBar.java b/java_console/romraider/src/com/romraider/swing/ECUEditorMenuBar.java index 8e8718b6d7..0542013363 100644 --- a/java_console/romraider/src/com/romraider/swing/ECUEditorMenuBar.java +++ b/java_console/romraider/src/com/romraider/swing/ECUEditorMenuBar.java @@ -25,7 +25,7 @@ import com.romraider.editor.ecu.ECUEditorManager; import com.romraider.maps.Rom; import com.romraider.maps.Table; import com.romraider.util.SettingsManager; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import javax.swing.*; import java.awt.event.ActionEvent; @@ -340,17 +340,17 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { //} else if (e.getSource() == romProperties) { - showMessageDialog(Launcher.getFrame(), new RomPropertyPanel(parent.getLastSelectedRom()), + showMessageDialog(ConsoleUI.getFrame(), new RomPropertyPanel(parent.getLastSelectedRom()), parent.getLastSelectedRom().getRomIDString() + " Properties", INFORMATION_MESSAGE); } else if (e.getSource() == settings) { SettingsForm form = new SettingsForm(); - form.setLocationRelativeTo(Launcher.getFrame()); + form.setLocationRelativeTo(ConsoleUI.getFrame()); form.setVisible(true); } else if (e.getSource() == compareImages){ - CompareImagesForm form = new CompareImagesForm(parent.getImages(), Launcher.getFrame().getIconImage()); - form.setLocationRelativeTo(Launcher.getFrame()); + CompareImagesForm form = new CompareImagesForm(parent.getImages(), ConsoleUI.getFrame().getIconImage()); + form.setLocationRelativeTo(ConsoleUI.getFrame()); form.setVisible(true); } else if (e.getSource() == level1) { @@ -383,7 +383,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { + "Build #: " + BUILDNUMBER + "\n" + SUPPORT_URL; String title = "About " + PRODUCT_NAME; - showMessageDialog(Launcher.getFrame(), message, title, INFORMATION_MESSAGE, ABOUT_ICON); + showMessageDialog(ConsoleUI.getFrame(), message, title, INFORMATION_MESSAGE, ABOUT_ICON); } } @@ -402,10 +402,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { ECUEditor parent = ECUEditorManager.getECUEditor(); JFileChooser fc = new JFileChooser(SettingsManager.getSettings().getLastImageDir()); fc.setFileFilter(new ECUImageFilter()); - if (fc.showSaveDialog(Launcher.getFrame()) == JFileChooser.APPROVE_OPTION) { + if (fc.showSaveDialog(ConsoleUI.getFrame()) == JFileChooser.APPROVE_OPTION) { File selectedFile = fc.getSelectedFile(); if (selectedFile.exists()) { - int option = showConfirmDialog(Launcher.getFrame(), selectedFile.getName() + " already exists! Overwrite?"); + int option = showConfirmDialog(ConsoleUI.getFrame(), selectedFile.getName() + " already exists! Overwrite?"); // option: 0 = Cancel, 1 = No if (option == CANCEL_OPTION || option == 1) { @@ -439,10 +439,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { // disable the "All files" option fc.setAcceptAllFileFilterUsed(false); - if (fc.showSaveDialog(Launcher.getFrame()) == JFileChooser.APPROVE_OPTION) { + if (fc.showSaveDialog(ConsoleUI.getFrame()) == JFileChooser.APPROVE_OPTION) { File selectedDir = fc.getSelectedFile(); if (selectedDir.exists()) { - int option = showConfirmDialog(Launcher.getFrame(), selectedDir.getName() + " already exists! Overwrite?"); + int option = showConfirmDialog(ConsoleUI.getFrame(), selectedDir.getName() + " already exists! Overwrite?"); // option: 0 = Cancel, 1 = No if (option == CANCEL_OPTION || option == 1) { @@ -499,7 +499,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { if(null != selectedFile){ if(lastSelectedRom.getRealFileSize() != Settings.SIXTEENBIT_SMALL_SIZE) { - showMessageDialog(Launcher.getFrame(), "Error converting image. Image size is invalid."); + showMessageDialog(ConsoleUI.getFrame(), "Error converting image. Image size is invalid."); } else { byte[] output = lastSelectedRom.saveFile(); byte[] incOutput = new byte[Settings.SIXTEENBIT_LARGE_SIZE]; @@ -522,7 +522,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener { if(null != selectedFile){ if(lastSelectedRom.getRealFileSize() != Settings.SIXTEENBIT_LARGE_SIZE) { - showMessageDialog(Launcher.getFrame(), "Error converting image. Image size is invalid."); + showMessageDialog(ConsoleUI.getFrame(), "Error converting image. Image size is invalid."); } else { byte[] output =lastSelectedRom.saveFile(); byte[] decOutput = new byte[Settings.SIXTEENBIT_SMALL_SIZE]; diff --git a/java_console/romraider/src/com/romraider/swing/SettingsForm.java b/java_console/romraider/src/com/romraider/swing/SettingsForm.java index a189b1a068..5eab0e804f 100644 --- a/java_console/romraider/src/com/romraider/swing/SettingsForm.java +++ b/java_console/romraider/src/com/romraider/swing/SettingsForm.java @@ -20,13 +20,11 @@ package com.romraider.swing; import static com.romraider.Version.PRODUCT_NAME; -import static java.io.File.separator; import java.awt.Color; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.io.File; import java.util.StringTokenizer; import javax.swing.ButtonGroup; @@ -53,14 +51,14 @@ import com.romraider.editor.ecu.ECUEditor; import com.romraider.editor.ecu.ECUEditorManager; //import com.romraider.util.FileAssociator; import com.romraider.util.SettingsManager; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; public class SettingsForm extends JFrame implements MouseListener { private static final long serialVersionUID = 3910602424260147767L; public SettingsForm() { - this.setIconImage(Launcher.getFrame().getIconImage()); + this.setIconImage(ConsoleUI.getFrame().getIconImage()); initComponents(); initSettings(); diff --git a/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java b/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java index 0ffee8d2db..64fb1e887d 100644 --- a/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java +++ b/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java @@ -32,8 +32,8 @@ import javax.management.modelmbean.XMLParseException; import javax.naming.NameNotFoundException; import javax.swing.JOptionPane; +import com.rusefi.ConsoleUI; import com.rusefi.FileLog; -import com.rusefi.Launcher; import org.apache.log4j.Logger; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -375,7 +375,7 @@ public final class DOMRomUnmarshaller { } catch (InvalidTableNameException ex) { // Table name is invalid, do nothing. } catch (NullPointerException ex) { - JOptionPane.showMessageDialog(Launcher.getFrame(), + JOptionPane.showMessageDialog(ConsoleUI.getFrame(), new DebugPanel(ex, SettingsManager.getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE); @@ -577,7 +577,7 @@ public final class DOMRomUnmarshaller { } catch (Exception ex) { JOptionPane.showMessageDialog( - Launcher.getFrame(), + ConsoleUI.getFrame(), new DebugPanel(ex, SettingsManager.getSettings() .getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE); diff --git a/java_console/ui/src/com/rusefi/ConsoleUI.java b/java_console/ui/src/com/rusefi/ConsoleUI.java new file mode 100644 index 0000000000..6acb2b2703 --- /dev/null +++ b/java_console/ui/src/com/rusefi/ConsoleUI.java @@ -0,0 +1,233 @@ +package com.rusefi; + +import com.rusefi.autodetect.PortDetector; +import com.rusefi.config.generated.Fields; +import com.rusefi.core.MessagesCentral; +import com.rusefi.core.Sensor; +import com.rusefi.core.SensorCentral; +import com.rusefi.io.ConnectionWatchdog; +import com.rusefi.io.LinkManager; +import com.rusefi.io.serial.BaudRateHolder; +import com.rusefi.maintenance.FirmwareFlasher; +import com.rusefi.maintenance.VersionChecker; +import com.rusefi.ui.*; +import com.rusefi.ui.console.MainFrame; +import com.rusefi.ui.console.TabbedPanel; +import com.rusefi.ui.engine.EngineSnifferPanel; +import com.rusefi.ui.logview.LogViewer; +import com.rusefi.ui.util.DefaultExceptionHandler; +import com.rusefi.ui.util.JustOneInstance; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionListener; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import static com.rusefi.rusEFIVersion.CONSOLE_VERSION; +import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; + +public class ConsoleUI { + private static final int DEFAULT_TAB_INDEX = 0; + public String port; + private static SensorCentral.SensorListener wrongVersionListener; + + public static final String TAB_INDEX = "main_tab"; + protected static final String PORT_KEY = "port"; + protected static final String SPEED_KEY = "speed"; + public static EngineSnifferPanel engineSnifferPanel; + + static Frame staticFrame; + + private final TabbedPanel tabbedPane = new TabbedPanel(); + + private final MainFrame mainFrame = new MainFrame(this, tabbedPane); + + /** + * We can listen to tab activation event if we so desire + */ + private final Map tabSelectedListeners = new HashMap<>(); + + public static Frame getFrame() { + return staticFrame; + } + + public ConsoleUI(String port) { + this.port = port; + ConsoleUI.staticFrame = mainFrame.getFrame().getFrame(); + FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); + + FileLog.MAIN.logLine("Hardware: " + FirmwareFlasher.getHardwareKind()); + + getConfig().getRoot().setProperty(PORT_KEY, port); + getConfig().getRoot().setProperty(SPEED_KEY, BaudRateHolder.INSTANCE.baudRate); + + LinkManager.start(port); + + engineSnifferPanel = new EngineSnifferPanel(getConfig().getRoot().getChild("digital_sniffer")); + if (!LinkManager.isLogViewerMode(port)) + engineSnifferPanel.setOutpinListener(LinkManager.engineState); + + if (LinkManager.isLogViewerMode(port)) + tabbedPane.addTab("Log Viewer", new LogViewer(engineSnifferPanel)); + + new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> { + FileLog.MAIN.logLine("ConnectionWatchdog.reconnectTimer restarting"); + LinkManager.restart(); + }).start(); + + GaugesPanel.DetachedRepository.INSTANCE.init(getConfig().getRoot().getChild("detached")); + GaugesPanel.DetachedRepository.INSTANCE.load(); + if (!LinkManager.isLogViewer()) + tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges"), tabbedPane.paneSettings).getContent()); + + if (!LinkManager.isLogViewer()) { + MessagesPane messagesPane = new MessagesPane(getConfig().getRoot().getChild("messages")); + tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener()); + } + if (!LinkManager.isLogViewer()) { + tabbedPane.addTab("Bench Test", new BenchTestPane().getContent()); + if (tabbedPane.paneSettings.showEtbPane) + tabbedPane.addTab("ETB", new ETBPane().getContent()); + tabbedPane.addTab("Presets", new PresetsPane().getContent()); + } + + tabbedPaneAdd("Engine Sniffer", engineSnifferPanel.getPanel(), engineSnifferPanel.getTabSelectedListener()); + + 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("ADC", new AdcPanel(new BooleanInputsModel()).createAdcPanel()); + if (tabbedPane.paneSettings.showStimulatorPane && !LinkManager.isSimulationMode && !LinkManager.isLogViewerMode(port)) { + // todo: rethink this UI? special command line key to enable it? + EcuStimulator stimulator = EcuStimulator.getInstance(); + tabbedPane.addTab("ECU stimulation", stimulator.getPanel()); + } +// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl()); + if (!LinkManager.isLogViewer()) + tabbedPane.addTab("Table Editor", tabbedPane.tableEditor); +// tabbedPane.add("Wizards", new Wizard().createPane()); + + if (!LinkManager.isLogViewer()) + tabbedPane.addTab("Settings", tabbedPane.settingsTab.createPane()); + if (!LinkManager.isLogViewer()) { + tabbedPane.addTab("Formulas/Live Data", new FormulasPane().getContent()); + tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane().getContent()); + } + + if (!LinkManager.isLogViewer() && false) // todo: fix it & better name? + tabbedPane.addTab("Logs Manager", tabbedPane.logsManager.getContent()); + if (tabbedPane.paneSettings.showFuelTunePane) + tabbedPane.addTab("Fuel Tune", tabbedPane.fuelTunePane.getContent()); + + + if (!LinkManager.isLogViewer()) { + if (tabbedPane.paneSettings.showTriggerShapePane) + tabbedPane.addTab("Trigger Shape", new AverageAnglePanel().getPanel()); + } + + tabbedPane.addTab("rusEFI Online", new OnlineTab().getContent()); + + + if (!LinkManager.isLogViewerMode(port)) { + int selectedIndex = getConfig().getRoot().getIntProperty(TAB_INDEX, DEFAULT_TAB_INDEX); + if (selectedIndex < tabbedPane.tabbedPane.getTabCount()) + tabbedPane.tabbedPane.setSelectedIndex(selectedIndex); + } + + tabbedPane.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().getFrame()); + mainFrame.getFrame().showFrame(tabbedPane.tabbedPane); + } + + static void startUi(String[] args) throws InterruptedException, InvocationTargetException { + FileLog.MAIN.start(); + + getConfig().load(); + FileLog.suspendLogging = getConfig().getRoot().getBoolProperty(GaugesPanel.DISABLE_LOGS); + Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler()); + VersionChecker.start(); + SwingUtilities.invokeAndWait(() -> awtCode(args)); + } + + /** + * Adds a tab with activation listener + */ + private void tabbedPaneAdd(String title, JComponent component, ActionListener tabSelectedListener) { + tabSelectedListeners.put(component, tabSelectedListener); + tabbedPane.addTab(title, component); + } + + private static void awtCode(String[] args) { + if (JustOneInstance.isAlreadyRunning()) { + int result = JOptionPane.showConfirmDialog(null, "Looks like another instance is already running. Do you really want to start another instance?", + "rusEfi", JOptionPane.YES_NO_OPTION); + if (result == JOptionPane.NO_OPTION) + System.exit(-1); + } + wrongVersionListener = new SensorCentral.SensorListener() { + @Override + public void onSensorUpdate(double value) { + // todo: we need to migrate to TS_SIGNATURE validation!!! + if (value != Fields.TS_FILE_VERSION) { + String message = "This copy of rusEfi console is not compatible with this version of firmware\r\n" + + "Console compatible with " + Fields.TS_FILE_VERSION + " while firmware compatible with " + + (int) value; + JOptionPane.showMessageDialog(getFrame(), message); + assert wrongVersionListener != null; + SensorCentral.getInstance().removeListener(Sensor.TS_CONFIG_VERSION, wrongVersionListener); + } + } + }; + SensorCentral.getInstance().addListener(Sensor.TS_CONFIG_VERSION, wrongVersionListener); + JustOneInstance.onStart(); + try { + boolean isPortDefined = args.length > 0; + boolean isBaudRateDefined = args.length > 1; + if (isBaudRateDefined) + BaudRateHolder.INSTANCE.baudRate = Integer.parseInt(args[1]); + + String port = null; + if (isPortDefined) + port = args[0]; + + if (isPortDefined) { + port = PortDetector.autoDetectSerialIfNeeded(port); + if (port == null) { + isPortDefined = false; + } + } + + if (isPortDefined) { + new ConsoleUI(port); + } else { + for (String p : LinkManager.getCommPorts()) + MessagesCentral.getInstance().postMessage(Launcher.class, "Available port: " + p); + new StartupFrame().chooseSerialPort(); + } + + } catch (Throwable e) { + throw new IllegalStateException(e); + } + } +} diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 674c3db9d9..9c082dae23 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -1,35 +1,10 @@ package com.rusefi; -import com.rusefi.autodetect.PortDetector; -import com.rusefi.config.generated.Fields; -import com.rusefi.core.MessagesCentral; -import com.rusefi.core.Sensor; -import com.rusefi.core.SensorCentral; -import com.rusefi.io.ConnectionWatchdog; -import com.rusefi.io.LinkManager; -import com.rusefi.io.serial.BaudRateHolder; -import com.rusefi.maintenance.FirmwareFlasher; -import com.rusefi.maintenance.VersionChecker; import com.rusefi.tools.ConsoleTools; -import com.rusefi.ui.*; -import com.rusefi.ui.console.MainFrame; -import com.rusefi.ui.console.TabbedPanel; import com.rusefi.ui.engine.EngineSnifferPanel; -import com.rusefi.ui.logview.LogViewer; import com.rusefi.ui.storage.PersistentConfiguration; -import com.rusefi.ui.util.DefaultExceptionHandler; -import com.rusefi.ui.util.JustOneInstance; -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionListener; import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; /** * this is the main entry point of rusEfi ECU console @@ -44,139 +19,6 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; public class Launcher extends rusEFIVersion { public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", ".."); public static final String TOOLS_PATH = System.getProperty("tools_path", "."); - public static final String TAB_INDEX = "main_tab"; - protected static final String PORT_KEY = "port"; - protected static final String SPEED_KEY = "speed"; - - private static final int DEFAULT_TAB_INDEX = 0; - - public static String port; - public static EngineSnifferPanel engineSnifferPanel; - private static SensorCentral.SensorListener wrongVersionListener; - - public TabbedPanel tabbedPane = new TabbedPanel(); - - private static Frame staticFrame; - - private MainFrame mainFrame = new MainFrame(tabbedPane); - - /** - * We can listen to tab activation event if we so desire - */ - private final Map tabSelectedListeners = new HashMap<>(); - - public Launcher(String port) { - Launcher.port = port; - staticFrame = mainFrame.getFrame().getFrame(); - FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); - - FileLog.MAIN.logLine("Hardware: " + FirmwareFlasher.getHardwareKind()); - - getConfig().getRoot().setProperty(PORT_KEY, port); - getConfig().getRoot().setProperty(SPEED_KEY, BaudRateHolder.INSTANCE.baudRate); - - LinkManager.start(port); - - engineSnifferPanel = new EngineSnifferPanel(getConfig().getRoot().getChild("digital_sniffer")); - if (!LinkManager.isLogViewerMode(port)) - engineSnifferPanel.setOutpinListener(LinkManager.engineState); - - if (LinkManager.isLogViewerMode(port)) - tabbedPane.addTab("Log Viewer", new LogViewer(engineSnifferPanel)); - - new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> { - FileLog.MAIN.logLine("ConnectionWatchdog.reconnectTimer restarting"); - LinkManager.restart(); - }).start(); - - GaugesPanel.DetachedRepository.INSTANCE.init(getConfig().getRoot().getChild("detached")); - GaugesPanel.DetachedRepository.INSTANCE.load(); - if (!LinkManager.isLogViewer()) - tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges"), tabbedPane.paneSettings).getContent()); - - if (!LinkManager.isLogViewer()) { - MessagesPane messagesPane = new MessagesPane(getConfig().getRoot().getChild("messages")); - tabbedPaneAdd("Messages", messagesPane.getContent(), messagesPane.getTabSelectedListener()); - } - if (!LinkManager.isLogViewer()) { - tabbedPane.addTab("Bench Test", new BenchTestPane().getContent()); - if (tabbedPane.paneSettings.showEtbPane) - tabbedPane.addTab("ETB", new ETBPane().getContent()); - tabbedPane.addTab("Presets", new PresetsPane().getContent()); - } - - tabbedPaneAdd("Engine Sniffer", engineSnifferPanel.getPanel(), engineSnifferPanel.getTabSelectedListener()); - - 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("ADC", new AdcPanel(new BooleanInputsModel()).createAdcPanel()); - if (tabbedPane.paneSettings.showStimulatorPane && !LinkManager.isSimulationMode && !LinkManager.isLogViewerMode(port)) { - // todo: rethink this UI? special command line key to enable it? - EcuStimulator stimulator = EcuStimulator.getInstance(); - tabbedPane.addTab("ECU stimulation", stimulator.getPanel()); - } -// tabbedPane.addTab("live map adjustment", new Live3DReport().getControl()); - if (!LinkManager.isLogViewer()) - tabbedPane.addTab("Table Editor", tabbedPane.tableEditor); -// tabbedPane.add("Wizards", new Wizard().createPane()); - - if (!LinkManager.isLogViewer()) - tabbedPane.addTab("Settings", tabbedPane.settingsTab.createPane()); - if (!LinkManager.isLogViewer()) { - tabbedPane.addTab("Formulas/Live Data", new FormulasPane().getContent()); - tabbedPane.addTab("Sensors Live Data", new SensorsLiveDataPane().getContent()); - } - - if (!LinkManager.isLogViewer() && false) // todo: fix it & better name? - tabbedPane.addTab("Logs Manager", tabbedPane.logsManager.getContent()); - if (tabbedPane.paneSettings.showFuelTunePane) - tabbedPane.addTab("Fuel Tune", tabbedPane.fuelTunePane.getContent()); - - - if (!LinkManager.isLogViewer()) { - if (tabbedPane.paneSettings.showTriggerShapePane) - tabbedPane.addTab("Trigger Shape", new AverageAnglePanel().getPanel()); - } - - tabbedPane.addTab("rusEFI Online", new OnlineTab().getContent()); - - - if (!LinkManager.isLogViewerMode(port)) { - int selectedIndex = getConfig().getRoot().getIntProperty(TAB_INDEX, DEFAULT_TAB_INDEX); - if (selectedIndex < tabbedPane.tabbedPane.getTabCount()) - tabbedPane.tabbedPane.setSelectedIndex(selectedIndex); - } - - tabbedPane.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().getFrame()); - mainFrame.getFrame().showFrame(tabbedPane.tabbedPane); - } - - /** - * Adds a tab with activation listener - */ - private void tabbedPaneAdd(String title, JComponent component, ActionListener tabSelectedListener) { - tabSelectedListeners.put(component, tabSelectedListener); - tabbedPane.addTab(title, component); - } /** * rusEfi console entry point @@ -195,70 +37,6 @@ public class Launcher extends rusEFIVersion { ConsoleTools.printTools(); - FileLog.MAIN.start(); - - getConfig().load(); - FileLog.suspendLogging = getConfig().getRoot().getBoolProperty(GaugesPanel.DISABLE_LOGS); - Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler()); - VersionChecker.start(); - SwingUtilities.invokeAndWait(() -> awtCode(args)); - } - - private static void awtCode(String[] args) { - if (JustOneInstance.isAlreadyRunning()) { - int result = JOptionPane.showConfirmDialog(null, "Looks like another instance is already running. Do you really want to start another instance?", - "rusEfi", JOptionPane.YES_NO_OPTION); - if (result == JOptionPane.NO_OPTION) - System.exit(-1); - } - wrongVersionListener = new SensorCentral.SensorListener() { - @Override - public void onSensorUpdate(double value) { - // todo: we need to migrate to TS_SIGNATURE validation!!! - if (value != Fields.TS_FILE_VERSION) { - String message = "This copy of rusEfi console is not compatible with this version of firmware\r\n" + - "Console compatible with " + Fields.TS_FILE_VERSION + " while firmware compatible with " + - (int) value; - JOptionPane.showMessageDialog(Launcher.getFrame(), message); - assert wrongVersionListener != null; - SensorCentral.getInstance().removeListener(Sensor.TS_CONFIG_VERSION, wrongVersionListener); - } - } - }; - SensorCentral.getInstance().addListener(Sensor.TS_CONFIG_VERSION, wrongVersionListener); - JustOneInstance.onStart(); - try { - boolean isPortDefined = args.length > 0; - boolean isBaudRateDefined = args.length > 1; - if (isBaudRateDefined) - BaudRateHolder.INSTANCE.baudRate = Integer.parseInt(args[1]); - - String port = null; - if (isPortDefined) - port = args[0]; - - - if (isPortDefined) { - port = PortDetector.autoDetectSerialIfNeeded(port); - if (port == null) { - isPortDefined = false; - } - } - - if (isPortDefined) { - new Launcher(port); - } else { - for (String p : LinkManager.getCommPorts()) - MessagesCentral.getInstance().postMessage(Launcher.class, "Available port: " + p); - new StartupFrame().chooseSerialPort(); - } - - } catch (Throwable e) { - throw new IllegalStateException(e); - } - } - - public static Frame getFrame() { - return staticFrame; + ConsoleUI.startUi(args); } } diff --git a/java_console/ui/src/com/rusefi/SimulatorHelper.java b/java_console/ui/src/com/rusefi/SimulatorHelper.java index 8a34e0ed68..4b143886ae 100644 --- a/java_console/ui/src/com/rusefi/SimulatorHelper.java +++ b/java_console/ui/src/com/rusefi/SimulatorHelper.java @@ -56,7 +56,7 @@ public class SimulatorHelper { throw new IllegalStateException("Port not opened?"); FileLog.MAIN.logLine("Port " + TcpConnector.DEFAULT_PORT + " is alive"); - new Launcher("" + TcpConnector.DEFAULT_PORT); + new ConsoleUI("" + TcpConnector.DEFAULT_PORT); } public static JComponent createSimulatorComponent(final StartupFrame portSelector) { diff --git a/java_console/ui/src/com/rusefi/StartupFrame.java b/java_console/ui/src/com/rusefi/StartupFrame.java index f59d4395e7..a3e7958366 100644 --- a/java_console/ui/src/com/rusefi/StartupFrame.java +++ b/java_console/ui/src/com/rusefi/StartupFrame.java @@ -184,7 +184,7 @@ public class StartupFrame { @Override public void actionPerformed(ActionEvent e) { disposeFrameAndProceed(); - new Launcher(LinkManager.LOG_VIEWER); + new ConsoleUI(LinkManager.LOG_VIEWER); } }); @@ -237,7 +237,7 @@ public class StartupFrame { selectedPort = autoDetectedPort; } disposeFrameAndProceed(); - new Launcher(selectedPort); + new ConsoleUI(selectedPort); } /** @@ -299,13 +299,13 @@ public class StartupFrame { comboPorts.removeAllItems(); for (final String port : ports) comboPorts.addItem(port); - String defaultPort = getConfig().getRoot().getProperty(Launcher.PORT_KEY); + String defaultPort = getConfig().getRoot().getProperty(ConsoleUI.PORT_KEY); comboPorts.setSelectedItem(defaultPort); } private static JComboBox createSpeedCombo() { JComboBox combo = new JComboBox<>(); - String defaultSpeed = getConfig().getRoot().getProperty(Launcher.SPEED_KEY, "115200"); + String defaultSpeed = getConfig().getRoot().getProperty(ConsoleUI.SPEED_KEY, "115200"); for (int speed : new int[]{9600, 14400, 19200, 38400, 57600, 115200, 460800, 921600}) combo.addItem(Integer.toString(speed)); combo.setSelectedItem(defaultSpeed); diff --git a/java_console/ui/src/com/rusefi/maintenance/DfuFlasher.java b/java_console/ui/src/com/rusefi/maintenance/DfuFlasher.java index b12b43ebc6..c450e6d196 100644 --- a/java_console/ui/src/com/rusefi/maintenance/DfuFlasher.java +++ b/java_console/ui/src/com/rusefi/maintenance/DfuFlasher.java @@ -1,6 +1,7 @@ package com.rusefi.maintenance; import com.opensr5.ini.IniFileModel; +import com.rusefi.ConsoleUI; import com.rusefi.FileLog; import com.rusefi.Launcher; import com.rusefi.Timeouts; @@ -18,7 +19,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; -import java.util.function.Function; /** * @see FirmwareFlasher @@ -58,7 +58,7 @@ public class DfuFlasher { return null; }); if (port == null) { - JOptionPane.showMessageDialog(Launcher.getFrame(), "rusEfi serial port not detected"); + JOptionPane.showMessageDialog(ConsoleUI.getFrame(), "rusEfi serial port not detected"); return; } else { messages.append("Detected rusEFI on " + port + "\n"); diff --git a/java_console/ui/src/com/rusefi/ui/LogDownloader.java b/java_console/ui/src/com/rusefi/ui/LogDownloader.java index 7fcfe18f0a..06a42304e1 100644 --- a/java_console/ui/src/com/rusefi/ui/LogDownloader.java +++ b/java_console/ui/src/com/rusefi/ui/LogDownloader.java @@ -1,9 +1,8 @@ package com.rusefi.ui; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import com.rusefi.core.MessagesCentral; import com.rusefi.io.CommandQueue; -import com.rusefi.io.InvocationConfirmationListener; import com.rusefi.ui.logview.LogViewer; import com.rusefi.ui.util.UiUtils; import org.jetbrains.annotations.NotNull; @@ -77,7 +76,7 @@ public class LogDownloader { removeFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - int i = JOptionPane.showConfirmDialog(Launcher.getFrame(), ("Do you really want to delete " + name + "?"), + int i = JOptionPane.showConfirmDialog(ConsoleUI.getFrame(), ("Do you really want to delete " + name + "?"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION); if (i == JOptionPane.YES_OPTION) { diff --git a/java_console/ui/src/com/rusefi/ui/MessagesPane.java b/java_console/ui/src/com/rusefi/ui/MessagesPane.java index b500d80aa9..832a23da82 100644 --- a/java_console/ui/src/com/rusefi/ui/MessagesPane.java +++ b/java_console/ui/src/com/rusefi/ui/MessagesPane.java @@ -1,7 +1,7 @@ package com.rusefi.ui; import ZoeloeSoft.projects.JFontChooser.JFontChooser; -import com.rusefi.Launcher; +import com.rusefi.ConsoleUI; import com.rusefi.ui.engine.EngineSnifferPanel; import com.rusefi.ui.storage.Node; import com.rusefi.ui.util.URLLabel; @@ -56,7 +56,7 @@ public class MessagesPane { fontButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - JFontChooser fc = new JFontChooser(Launcher.getFrame()); + JFontChooser fc = new JFontChooser(ConsoleUI.getFrame()); fc.setLocationRelativeTo(fontButton); if (fc.showDialog(upperPanel.getFont()) == JFontChooser.OK_OPTION) { upperPanel.setFont(fc.getFont(), config); diff --git a/java_console/ui/src/com/rusefi/ui/console/MainFrame.java b/java_console/ui/src/com/rusefi/ui/console/MainFrame.java index 98e592be70..b68ba9a841 100644 --- a/java_console/ui/src/com/rusefi/ui/console/MainFrame.java +++ b/java_console/ui/src/com/rusefi/ui/console/MainFrame.java @@ -18,6 +18,7 @@ import java.util.TimeZone; import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; public class MainFrame { + private final ConsoleUI consoleUI; private final TabbedPanel tabbedPane; /** * @see StartupFrame @@ -43,7 +44,8 @@ public class MainFrame { } }; - public MainFrame(TabbedPanel tabbedPane) { + public MainFrame(ConsoleUI consoleUI, TabbedPanel tabbedPane) { + this.consoleUI = consoleUI; this.tabbedPane = tabbedPane; } @@ -66,7 +68,7 @@ public class MainFrame { } }); - LinkManager.startAndConnect(Launcher.port, new ConnectionStateListener() { + LinkManager.startAndConnect(consoleUI.port, new ConnectionStateListener() { @Override public void onConnectionFailed() { } @@ -99,7 +101,7 @@ public class MainFrame { private void setTitle() { String disconnected = ConnectionStatusLogic.INSTANCE.isConnected() ? "" : "DISCONNECTED "; - frame.getFrame().setTitle(disconnected + "Console " + Launcher.CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + Launcher.port); + frame.getFrame().setTitle(disconnected + "Console " + Launcher.CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + consoleUI.port); } private void windowClosedHandler() { @@ -109,7 +111,7 @@ public class MainFrame { SimulatorHelper.onWindowClosed(); Node root = getConfig().getRoot(); root.setProperty("version", Launcher.CONSOLE_VERSION); - root.setProperty(Launcher.TAB_INDEX, tabbedPane.tabbedPane.getSelectedIndex()); + root.setProperty(ConsoleUI.TAB_INDEX, tabbedPane.tabbedPane.getSelectedIndex()); GaugesPanel.DetachedRepository.INSTANCE.saveConfig(); getConfig().save(); BinaryProtocol bp = BinaryProtocolHolder.getInstance().getCurrentStreamState(); diff --git a/java_console/ui/src/com/rusefi/ui/logview/LogViewer.java b/java_console/ui/src/com/rusefi/ui/logview/LogViewer.java index 6d436609ff..b5ba16592f 100644 --- a/java_console/ui/src/com/rusefi/ui/logview/LogViewer.java +++ b/java_console/ui/src/com/rusefi/ui/logview/LogViewer.java @@ -1,5 +1,6 @@ package com.rusefi.ui.logview; +import com.rusefi.ConsoleUI; import com.rusefi.FileLog; import com.rusefi.Launcher; import com.rusefi.core.EngineState; @@ -179,7 +180,7 @@ public class LogViewer extends JPanel { ChartRepository.getInstance().clear(); EngineState engineState = new EngineState(listener); // this is pretty dirty, better OOP desperately needed - Launcher.engineSnifferPanel.setOutpinListener(engineState); + ConsoleUI.engineSnifferPanel.setOutpinListener(engineState); engineState.registerStringValueAction(EngineReport.ENGINE_CHART, new EngineState.ValueCallback() { @Override public void onUpdate(String value) {