auto-sync
This commit is contained in:
parent
361fb1b74b
commit
ae22850adf
|
@ -1,9 +1,6 @@
|
|||
package com.rusefi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
|
@ -27,13 +24,23 @@ public class ConfigurationImage {
|
|||
return content.length;
|
||||
}
|
||||
|
||||
public void saveToFile(String fileName) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
public byte[] getFileContent() throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
byte[] bytes = BIN_HEADER.getBytes();
|
||||
if (bytes.length != BIN_HEADER.length())
|
||||
throw new IllegalStateException("Encoding issue");
|
||||
fos.write(bytes);
|
||||
fos.write(content);
|
||||
baos.write(bytes);
|
||||
baos.write(content);
|
||||
return baos.toByteArray();
|
||||
} finally {
|
||||
baos.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveToFile(String fileName) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
fos.write(getFileContent());
|
||||
fos.close();
|
||||
System.out.println("Saved to " + fileName);
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ public class ECUExec {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static void openRom(final ECUEditor editor, final String rom) {
|
||||
public static void openRom(final ECUEditor editor, final String rom) {
|
||||
invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -66,12 +66,11 @@ import javax.swing.tree.TreePath;
|
|||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import com.romraider.net.BrowserControl;
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.net.URL;
|
||||
import com.romraider.swing.AbstractFrame;
|
||||
import com.romraider.swing.CustomToolbarLayout;
|
||||
import com.romraider.swing.ECUEditorMenuBar;
|
||||
|
@ -147,6 +146,42 @@ public class ECUEditor extends AbstractFrame {
|
|||
toFront();
|
||||
}
|
||||
|
||||
public static void openImage(byte[] input, File definitionFile, String fileName) throws Exception {
|
||||
ECUEditor editor = ECUEditorManager.getECUEditor();
|
||||
DOMParser parser = new DOMParser();
|
||||
Document doc;
|
||||
FileInputStream fileStream;
|
||||
fileStream = new FileInputStream(definitionFile);
|
||||
InputSource src = new InputSource(fileStream);
|
||||
|
||||
parser.parse(src);
|
||||
doc = parser.getDocument();
|
||||
|
||||
Rom rom;
|
||||
try {
|
||||
rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel());
|
||||
} finally {
|
||||
// Release mem after unmarshall.
|
||||
parser.reset();
|
||||
doc.removeChild(doc.getDocumentElement());
|
||||
doc = null;
|
||||
fileStream.close();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
editor.getStatusPanel().setStatus("Populating tables...");
|
||||
|
||||
rom.setFullFileName(fileName);
|
||||
rom.populateTables(input, editor.getStatusPanel());
|
||||
|
||||
editor.getStatusPanel().setStatus("Finalizing...");
|
||||
|
||||
editor.addRom(rom);
|
||||
editor.refreshTableCompareMenus();
|
||||
|
||||
editor.getStatusPanel().setStatus("Done loading image...");
|
||||
}
|
||||
|
||||
public void initializeEditorUI() {
|
||||
//create menubar
|
||||
menuBar = new ECUEditorMenuBar();
|
||||
|
@ -478,17 +513,7 @@ public class ECUEditor extends AbstractFrame {
|
|||
openImageWorker.execute();
|
||||
}
|
||||
|
||||
public void openImages(File[] inputFiles) throws Exception {
|
||||
if(inputFiles.length < 1) {
|
||||
showMessageDialog(this, "Image Not Found", "Error Loading Image(s)", ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
for(int j = 0; j < inputFiles.length; j++) {
|
||||
openImage(inputFiles[j]);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] readFile(File inputFile) throws IOException {
|
||||
public static byte[] readFile(File inputFile) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
FileInputStream fis = new FileInputStream(inputFile);
|
||||
try {
|
||||
|
@ -643,62 +668,28 @@ class OpenImageWorker extends SwingWorker<Void, Void> {
|
|||
ECUEditor editor = ECUEditorManager.getECUEditor();
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
|
||||
DOMParser parser = new DOMParser();
|
||||
Document doc;
|
||||
FileInputStream fileStream;
|
||||
|
||||
try {
|
||||
editor.getStatusPanel().setStatus("Parsing ECU definitions...");
|
||||
setProgress(0);
|
||||
|
||||
byte[] input = editor.readFile(inputFile);
|
||||
byte[] input = ECUEditor.readFile(inputFile);
|
||||
|
||||
editor.getStatusPanel().setStatus("Finding ECU definition...");
|
||||
setProgress(10);
|
||||
|
||||
// parse ecu definition files until result found
|
||||
for (int i = 0; i < settings.getEcuDefinitionFiles().size(); i++) {
|
||||
fileStream = new FileInputStream(settings.getEcuDefinitionFiles().get(i));
|
||||
InputSource src = new InputSource(fileStream);
|
||||
|
||||
parser.parse(src);
|
||||
doc = parser.getDocument();
|
||||
|
||||
Rom rom;
|
||||
|
||||
File definitionFile = settings.getEcuDefinitionFiles().get(i);
|
||||
try {
|
||||
rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel());
|
||||
} catch (RomNotFoundException rex) {
|
||||
// rom was not found in current file, skip to next
|
||||
continue;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
showMessageDialog(editor, "Error Loading. Unknown Exception.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
|
||||
return null;
|
||||
} finally {
|
||||
// Release mem after unmarshall.
|
||||
parser.reset();
|
||||
doc.removeChild(doc.getDocumentElement());
|
||||
doc = null;
|
||||
fileStream.close();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
editor.getStatusPanel().setStatus("Populating tables...");
|
||||
setProgress(50);
|
||||
|
||||
rom.setFullFileName(inputFile);
|
||||
rom.populateTables(input, editor.getStatusPanel());
|
||||
|
||||
editor.getStatusPanel().setStatus("Finalizing...");
|
||||
setProgress(90);
|
||||
|
||||
editor.addRom(rom);
|
||||
editor.refreshTableCompareMenus();
|
||||
|
||||
editor.getStatusPanel().setStatus("Done loading image...");
|
||||
ECUEditor.openImage(input, definitionFile, inputFile.getName());
|
||||
setProgress(100);
|
||||
return null;
|
||||
|
||||
} catch (RomNotFoundException rex) {
|
||||
// rom was not found in current file, skip to next
|
||||
}
|
||||
}
|
||||
|
||||
// if code executes to this point, no ROM was found, report to user
|
||||
|
@ -716,6 +707,9 @@ class OpenImageWorker extends SwingWorker<Void, Void> {
|
|||
// handles Java heap space issues when loading multiple Roms.
|
||||
showMessageDialog(editor, "Error loading Image. Out of memeory.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
showMessageDialog(editor, "Error Loading. Unknown Exception.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import static javax.swing.JOptionPane.QUESTION_MESSAGE;
|
|||
import static javax.swing.JOptionPane.showOptionDialog;
|
||||
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -56,7 +55,6 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
|
|||
private static final Logger LOGGER = Logger.getLogger(Rom.class);
|
||||
private RomID romID = new RomID();
|
||||
private String fileName = "";
|
||||
private File fullFileName = new File(".");
|
||||
private final Vector<TableTreeNode> tableNodes = new Vector<TableTreeNode>();
|
||||
private byte[] binData;
|
||||
private boolean isAbstract = false;
|
||||
|
@ -380,13 +378,8 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
|
|||
return binData.length;
|
||||
}
|
||||
|
||||
public File getFullFileName() {
|
||||
return fullFileName;
|
||||
}
|
||||
|
||||
public void setFullFileName(File fullFileName) {
|
||||
this.fullFileName = fullFileName;
|
||||
this.setFileName(fullFileName.getName());
|
||||
public void setFullFileName(String fileName) {
|
||||
this.setFileName(fileName);
|
||||
for (TableTreeNode tableNode : tableNodes) {
|
||||
String frameTitle = this.getFileName() + " - " + tableNode.getTable().getName();
|
||||
tableNode.getFrame().setTitle(frameTitle);
|
||||
|
|
|
@ -19,19 +19,14 @@
|
|||
|
||||
package com.romraider.swing;
|
||||
|
||||
import static com.romraider.Version.ABOUT_ICON;
|
||||
import static com.romraider.Version.BUILDNUMBER;
|
||||
//import static com.romraider.Version.ECU_DEFS_URL;
|
||||
import static com.romraider.Version.PRODUCT_NAME;
|
||||
import static com.romraider.Version.SUPPORT_URL;
|
||||
import static com.romraider.Version.VERSION;
|
||||
import static javax.swing.JOptionPane.CANCEL_OPTION;
|
||||
import static javax.swing.JOptionPane.ERROR_MESSAGE;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showConfirmDialog;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.editor.ecu.ECUEditorManager;
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -39,34 +34,24 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.JSeparator;
|
||||
import static com.romraider.Version.*;
|
||||
import static javax.swing.JOptionPane.*;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.editor.ecu.ECUEditorManager;
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
import com.romraider.net.BrowserControl;
|
||||
import com.romraider.util.SettingsManager;
|
||||
//import static com.romraider.Version.ECU_DEFS_URL;
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -4777040428837855236L;
|
||||
private final JMenu fileMenu = new JMenu("File");
|
||||
private final JMenuItem openImage = new JMenuItem("Open Image...");
|
||||
private final JMenuItem openImages = new JMenuItem("Open Image(s)...");
|
||||
private final JMenuItem saveImage = new JMenuItem("Save Image As...");
|
||||
private final JMenuItem saveAsRepository = new JMenuItem("Save Image As Repository...");
|
||||
// private final JMenu fileMenu = new JMenu("File");
|
||||
// private final JMenuItem openImage = new JMenuItem("Open Image...");
|
||||
// private final JMenuItem openImages = new JMenuItem("Open Image(s)...");
|
||||
// private final JMenuItem saveImage = new JMenuItem("Save Image As...");
|
||||
// private final JMenuItem saveAsRepository = new JMenuItem("Save Image As Repository...");
|
||||
private final JMenuItem refreshImage = new JMenuItem("Refresh Image");
|
||||
private final JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
private final JMenuItem closeAll = new JMenuItem("Close All Images");
|
||||
private final JMenuItem exit = new JMenuItem("Exit");
|
||||
// private final JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
// private final JMenuItem closeAll = new JMenuItem("Close All Images");
|
||||
// private final JMenuItem exit = new JMenuItem("Exit");
|
||||
|
||||
// private final JMenu definitionMenu = new JMenu("ECU Definitions");
|
||||
// private final JMenuItem defManager = new JMenuItem("ECU Definition Manager...");
|
||||
|
@ -94,7 +79,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
// private final JMenu loggerMenu = new JMenu("Logger");
|
||||
// private final JMenuItem openLogger = new JMenuItem("Launch Logger...");
|
||||
|
||||
private final JMenu ramTuneMenu = new JMenu("SSM");
|
||||
// private final JMenu ramTuneMenu = new JMenu("SSM");
|
||||
private final JMenuItem launchRamTuneTestApp = new JMenuItem("Launch Test App...");
|
||||
|
||||
private final JMenu helpMenu = new JMenu("Help");
|
||||
|
@ -102,44 +87,44 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
|
||||
public ECUEditorMenuBar() {
|
||||
// file menu items
|
||||
add(fileMenu);
|
||||
fileMenu.setMnemonic('F');
|
||||
|
||||
fileMenu.add(openImage);
|
||||
openImage.addActionListener(this);
|
||||
openImage.setMnemonic('O');
|
||||
// add(fileMenu);
|
||||
// fileMenu.setMnemonic('F');
|
||||
//
|
||||
// fileMenu.add(openImage);
|
||||
// openImage.addActionListener(this);
|
||||
// openImage.setMnemonic('O');
|
||||
|
||||
//fileMenu.add(openImages);
|
||||
//openImages.addActionListener(this);
|
||||
//openImages.setMnemonic('I');
|
||||
|
||||
fileMenu.add(saveImage);
|
||||
saveImage.addActionListener(this);
|
||||
saveImage.setMnemonic('S');
|
||||
|
||||
fileMenu.add(saveAsRepository);
|
||||
saveAsRepository.setMnemonic('D');
|
||||
saveAsRepository.addActionListener(this);
|
||||
|
||||
fileMenu.add(refreshImage);
|
||||
refreshImage.addActionListener(this);
|
||||
refreshImage.setMnemonic('R');
|
||||
|
||||
fileMenu.add(new JSeparator());
|
||||
|
||||
fileMenu.add(closeImage);
|
||||
closeImage.addActionListener(this);
|
||||
closeImage.setMnemonic('C');
|
||||
// fileMenu.add(saveImage);
|
||||
// saveImage.addActionListener(this);
|
||||
// saveImage.setMnemonic('S');
|
||||
//
|
||||
// fileMenu.add(saveAsRepository);
|
||||
// saveAsRepository.setMnemonic('D');
|
||||
// saveAsRepository.addActionListener(this);
|
||||
//
|
||||
// fileMenu.add(refreshImage);
|
||||
// refreshImage.addActionListener(this);
|
||||
// refreshImage.setMnemonic('R');
|
||||
//
|
||||
// fileMenu.add(new JSeparator());
|
||||
//
|
||||
// fileMenu.add(closeImage);
|
||||
// closeImage.addActionListener(this);
|
||||
// closeImage.setMnemonic('C');
|
||||
|
||||
//fileMenu.add(closeAll);
|
||||
//closeAll.addActionListener(this);
|
||||
//closeAll.setMnemonic('A');
|
||||
|
||||
fileMenu.add(new JSeparator());
|
||||
|
||||
fileMenu.add(exit);
|
||||
exit.addActionListener(this);
|
||||
exit.setMnemonic('X');
|
||||
// fileMenu.add(new JSeparator());
|
||||
//
|
||||
// fileMenu.add(exit);
|
||||
// exit.addActionListener(this);
|
||||
// exit.setMnemonic('X');
|
||||
|
||||
// edit menu items
|
||||
add(editMenu);
|
||||
|
@ -242,10 +227,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
// openLogger.setMnemonic('O');
|
||||
|
||||
// ramtune menu items
|
||||
add(ramTuneMenu);
|
||||
ramTuneMenu.setMnemonic('R');
|
||||
|
||||
ramTuneMenu.add(launchRamTuneTestApp);
|
||||
// add(ramTuneMenu);
|
||||
// ramTuneMenu.setMnemonic('R');
|
||||
//
|
||||
// ramTuneMenu.add(launchRamTuneTestApp);
|
||||
launchRamTuneTestApp.addActionListener(this);
|
||||
launchRamTuneTestApp.setMnemonic('L');
|
||||
|
||||
|
@ -263,28 +248,28 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
public void updateMenu() {
|
||||
String file = getLastSelectedRomFileName();
|
||||
if ("".equals(file)) {
|
||||
saveImage.setEnabled(false);
|
||||
saveAsRepository.setEnabled(false);
|
||||
closeImage.setEnabled(false);
|
||||
// saveImage.setEnabled(false);
|
||||
// saveAsRepository.setEnabled(false);
|
||||
// closeImage.setEnabled(false);
|
||||
//closeAll.setEnabled(false);
|
||||
romProperties.setEnabled(false);
|
||||
saveImage.setText("Save As...");
|
||||
saveAsRepository.setText("Save As Repository...");
|
||||
// saveImage.setText("Save As...");
|
||||
// saveAsRepository.setText("Save As Repository...");
|
||||
compareImages.setEnabled(false);
|
||||
convertRom.setEnabled(false);
|
||||
} else {
|
||||
saveImage.setEnabled(true);
|
||||
saveAsRepository.setEnabled(true);
|
||||
closeImage.setEnabled(true);
|
||||
// saveImage.setEnabled(true);
|
||||
// saveAsRepository.setEnabled(true);
|
||||
// closeImage.setEnabled(true);
|
||||
//closeAll.setEnabled(true);
|
||||
romProperties.setEnabled(true);
|
||||
saveImage.setText("Save " + file + " As...");
|
||||
saveAsRepository.setText("Save "+ file +" As Repository...");
|
||||
// saveImage.setText("Save " + file + " As...");
|
||||
// saveAsRepository.setText("Save "+ file +" As Repository...");
|
||||
compareImages.setEnabled(true);
|
||||
convertRom.setEnabled(true);
|
||||
}
|
||||
refreshImage.setText("Refresh " + file);
|
||||
closeImage.setText("Close " + file);
|
||||
// closeImage.setText("Close " + file);
|
||||
romProperties.setText(file + "Properties");
|
||||
|
||||
int lastSelectedRomSize = 0;
|
||||
|
@ -304,7 +289,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
convertDecrease.setEnabled(false);
|
||||
}
|
||||
|
||||
openImages.setEnabled(false);
|
||||
//openImages.setEnabled(false);
|
||||
// editDefinition.setEnabled(false);
|
||||
revalidate();
|
||||
}
|
||||
|
@ -312,58 +297,51 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ECUEditor parent = ECUEditorManager.getECUEditor();
|
||||
if (e.getSource() == openImage) {
|
||||
try {
|
||||
openImageDialog();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
// if (e.getSource() == openImage) {
|
||||
// try {
|
||||
// openImageDialog();
|
||||
// } catch (Exception ex) {
|
||||
// showMessageDialog(parent,
|
||||
// new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
// }
|
||||
//
|
||||
// } else if (e.getSource() == openImages) {
|
||||
// try {
|
||||
// openImagesDialog();
|
||||
// } catch (Exception ex) {
|
||||
// showMessageDialog(parent,
|
||||
// new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
// }
|
||||
//
|
||||
// } else if (e.getSource() == saveImage) {
|
||||
// try {
|
||||
// this.saveImage();
|
||||
// } catch (Exception ex) {
|
||||
// showMessageDialog(parent,
|
||||
// new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
// }
|
||||
// } else if (e.getSource() == saveAsRepository) {
|
||||
// try {
|
||||
// this.saveAsRepository();
|
||||
// } catch(Exception ex) {
|
||||
// showMessageDialog(parent,
|
||||
// new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
// }
|
||||
// } else if (e.getSource() == closeImage) {
|
||||
// parent.closeImage();
|
||||
//
|
||||
// } else if (e.getSource() == closeAll) {
|
||||
// parent.closeAllImages();
|
||||
//
|
||||
// } else if (e.getSource() == exit) {
|
||||
// parent.handleExit();
|
||||
// System.exit(0);
|
||||
|
||||
} else if (e.getSource() == openImages) {
|
||||
try {
|
||||
openImagesDialog();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == saveImage) {
|
||||
try {
|
||||
this.saveImage();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == saveAsRepository) {
|
||||
try {
|
||||
this.saveAsRepository();
|
||||
} catch(Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == closeImage) {
|
||||
parent.closeImage();
|
||||
|
||||
} else if (e.getSource() == closeAll) {
|
||||
parent.closeAllImages();
|
||||
|
||||
} else if (e.getSource() == exit) {
|
||||
parent.handleExit();
|
||||
System.exit(0);
|
||||
|
||||
} else if (e.getSource() == romProperties) {
|
||||
//} else
|
||||
if (e.getSource() == romProperties) {
|
||||
showMessageDialog(parent, new RomPropertyPanel(parent.getLastSelectedRom()),
|
||||
parent.getLastSelectedRom().getRomIDString() + " Properties", INFORMATION_MESSAGE);
|
||||
|
||||
} else if (e.getSource() == refreshImage) {
|
||||
try {
|
||||
refreshImage();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent, new DebugPanel(ex,
|
||||
getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == settings) {
|
||||
SettingsForm form = new SettingsForm();
|
||||
form.setLocationRelativeTo(parent);
|
||||
|
@ -374,29 +352,6 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
form.setLocationRelativeTo(parent);
|
||||
form.setVisible(true);
|
||||
|
||||
} else if (e.getSource() == convertIncrease) {
|
||||
try {
|
||||
increaseRomSize();
|
||||
refreshImage();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == convertDecrease) {
|
||||
try {
|
||||
decreaseRomSize();
|
||||
refreshImage();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
// } else if (e.getSource() == defManager) {
|
||||
// DefinitionManager form = new DefinitionManager();
|
||||
// form.setLocationRelativeTo(parent);
|
||||
// form.setVisible(true);
|
||||
|
||||
} else if (e.getSource() == level1) {
|
||||
parent.setUserLevel(1);
|
||||
|
||||
|
@ -431,40 +386,6 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshImage() throws Exception {
|
||||
ECUEditor parent = ECUEditorManager.getECUEditor();
|
||||
if (parent.getLastSelectedRom() != null) {
|
||||
File file = parent.getLastSelectedRom().getFullFileName();
|
||||
parent.closeImage();
|
||||
parent.openImage(file);
|
||||
}
|
||||
}
|
||||
|
||||
public void openImageDialog() throws Exception {
|
||||
ECUEditor parent = ECUEditorManager.getECUEditor();
|
||||
JFileChooser fc = new JFileChooser(SettingsManager.getSettings().getLastImageDir());
|
||||
fc.setFileFilter(new ECUImageFilter());
|
||||
fc.setDialogTitle("Open Image");
|
||||
|
||||
if (fc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
parent.openImage(fc.getSelectedFile());
|
||||
SettingsManager.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
public void openImagesDialog() throws Exception {
|
||||
ECUEditor parent = ECUEditorManager.getECUEditor();
|
||||
JFileChooser fc = new JFileChooser(getSettings().getLastImageDir());
|
||||
fc.setFileFilter(new ECUImageFilter());
|
||||
fc.setMultiSelectionEnabled(true);
|
||||
fc.setDialogTitle("Open Image(s)");
|
||||
|
||||
if(fc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
parent.openImages(fc.getSelectedFiles());
|
||||
SettingsManager.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
public void saveImage() throws Exception {
|
||||
Rom lastSelectedRom = ECUEditorManager.getECUEditor().getLastSelectedRom();
|
||||
if (lastSelectedRom != null) {
|
||||
|
@ -503,7 +424,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
} finally {
|
||||
fos.close();
|
||||
}
|
||||
parent.getLastSelectedRom().setFullFileName(selectedFile.getAbsoluteFile());
|
||||
parent.getLastSelectedRom().setFullFileName(selectedFile.getAbsoluteFile().getName());
|
||||
parent.setLastSelectedRom(parent.getLastSelectedRom());
|
||||
SettingsManager.getSettings().setLastImageDir(selectedFile.getParentFile());
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import com.romraider.util.SettingsManager;
|
|||
public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = 7778170684606193919L;
|
||||
private final JButton openImage = new JButton();
|
||||
private final JButton saveImage = new JButton();
|
||||
private final JButton refreshImage = new JButton();
|
||||
private final JButton closeImage = new JButton();
|
||||
|
@ -56,13 +55,10 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
|
||||
this.updateIcons();
|
||||
|
||||
this.add(openImage);
|
||||
this.add(saveImage);
|
||||
this.add(closeImage);
|
||||
this.add(refreshImage);
|
||||
|
||||
openImage.setMaximumSize(new Dimension(58, 50));
|
||||
openImage.setBorder(createLineBorder(new Color(150, 150, 150), 0));
|
||||
saveImage.setMaximumSize(new Dimension(50, 50));
|
||||
saveImage.setBorder(createLineBorder(new Color(150, 150, 150), 0));
|
||||
closeImage.setMaximumSize(new Dimension(50, 50));
|
||||
|
@ -72,7 +68,6 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
|
||||
this.updateButtons();
|
||||
|
||||
openImage.addActionListener(this);
|
||||
saveImage.addActionListener(this);
|
||||
closeImage.addActionListener(this);
|
||||
refreshImage.addActionListener(this);
|
||||
|
@ -80,7 +75,6 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
|
||||
public void updateIcons() {
|
||||
int iconScale = getSettings().getEditorIconScale();
|
||||
openImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-open.png")), iconScale));
|
||||
saveImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-save.png")), iconScale));
|
||||
refreshImage.setIcon(rescaleImageIcon(new ImageIcon(getClass().getResource("/graphics/icon-refresh.png")), iconScale));
|
||||
closeImage.setIcon(rescaleImageIcon(new ImageIcon( getClass().getResource("/graphics/icon-close.png")), iconScale));
|
||||
|
@ -101,7 +95,6 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
public void updateButtons() {
|
||||
String file = getEditor().getLastSelectedRomFileName();
|
||||
|
||||
openImage.setToolTipText("Open Image");
|
||||
saveImage.setToolTipText("Save " + file + " As New Image...");
|
||||
refreshImage.setToolTipText("Refresh " + file + " from saved copy");
|
||||
closeImage.setToolTipText("Close " + file);
|
||||
|
@ -120,14 +113,7 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == openImage) {
|
||||
try {
|
||||
((ECUEditorMenuBar) getEditor().getJMenuBar()).openImageDialog();
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
|
||||
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == saveImage) {
|
||||
if (e.getSource() == saveImage) {
|
||||
try {
|
||||
((ECUEditorMenuBar) getEditor().getJMenuBar()).saveImage();
|
||||
getEditor().refreshUI();
|
||||
|
@ -138,12 +124,6 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
|
|||
} else if (e.getSource() == closeImage) {
|
||||
getEditor().closeImage();
|
||||
} else if (e.getSource() == refreshImage) {
|
||||
try {
|
||||
((ECUEditorMenuBar) getEditor().getJMenuBar()).refreshImage();
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(getEditor(), new DebugPanel(ex,
|
||||
getSettings().getSupportURL()), "Exception", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.rusefi;
|
||||
|
||||
|
||||
import com.romraider.ECUExec;
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.editor.ecu.ECUEditorManager;
|
||||
import com.romraider.swing.LookAndFeelManager;
|
||||
import com.romraider.util.LogManager;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
@ -19,10 +21,16 @@ public class RomRaiderWrapper {
|
|||
private static final String DEFINITION_FILE = "..\\firmware\\integration\\rusefi.xml";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
if (settings.getEcuDefinitionFiles().isEmpty())
|
||||
settings.addEcuDefinitionFile(new File(DEFINITION_FILE));
|
||||
startRomRaider();
|
||||
|
||||
ECUExec.openRom(ECUEditorManager.getECUEditor(), "rusefi_configuration.bin");
|
||||
}
|
||||
|
||||
public static ECUEditor startRomRaider() {
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
settings.getEcuDefinitionFiles().clear();
|
||||
|
||||
settings.addEcuDefinitionFile(new File(DEFINITION_FILE));
|
||||
|
||||
LogManager.initDebugLogging();
|
||||
|
||||
|
@ -30,6 +38,6 @@ public class RomRaiderWrapper {
|
|||
|
||||
ECUEditor editor = getECUEditor();
|
||||
editor.initializeEditorUI();
|
||||
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,11 @@ public class UploadChanges {
|
|||
public void run() {
|
||||
try {
|
||||
showUi(port);
|
||||
} catch (SerialPortException | IOException | InterruptedException e) {
|
||||
} catch (SerialPortException e) {
|
||||
throw new IllegalStateException(e);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +103,13 @@ public class UploadChanges {
|
|||
public void run() {
|
||||
try {
|
||||
patch(ci1, ci2, bp, logger);
|
||||
} catch (InterruptedException | EOFException | SerialPortException e) {
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Error: " + e);
|
||||
throw new IllegalStateException(e);
|
||||
} catch (EOFException e) {
|
||||
logger.error("Error: " + e);
|
||||
throw new IllegalStateException(e);
|
||||
} catch (SerialPortException e) {
|
||||
logger.error("Error: " + e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -121,5 +131,6 @@ public class UploadChanges {
|
|||
offset = range.second;
|
||||
}
|
||||
bp.burn();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package com.rusefi.binaryprotocol;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.rusefi.ConfigurationImage;
|
||||
import com.rusefi.Logger;
|
||||
import com.rusefi.RomRaiderWrapper;
|
||||
import com.rusefi.io.serial.PortHolder;
|
||||
import jssc.SerialPort;
|
||||
import jssc.SerialPortException;
|
||||
|
@ -14,7 +18,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public class BinaryProtocolCmd {
|
||||
|
||||
public static void main(String[] args) throws SerialPortException, InterruptedException, IOException {
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 1) {
|
||||
System.out.println("Exactly one parameter expected");
|
||||
return;
|
||||
|
@ -32,7 +36,6 @@ public class BinaryProtocolCmd {
|
|||
}
|
||||
BinaryProtocol bp = new BinaryProtocol(logger, serialPort);
|
||||
|
||||
|
||||
PortHolder.setupPort(serialPort, 38400);
|
||||
logger.info("Looks good");
|
||||
bp.exchange(new byte[]{'S'});
|
||||
|
@ -43,6 +46,11 @@ public class BinaryProtocolCmd {
|
|||
|
||||
image.saveToFile("rusefi_configuration.bin");
|
||||
|
||||
RomRaiderWrapper.startRomRaider();
|
||||
|
||||
ECUEditor.openImage(image.getFileContent(), SettingsManager.getSettings().getEcuDefinitionFiles().elementAt(0),
|
||||
"rusEfi");
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue