diff --git a/ecu_defs/ecu_defs.xml b/ecu_defs/ecu_defs.xml
index 800830e1..115f919d 100644
--- a/ecu_defs/ecu_defs.xml
+++ b/ecu_defs/ecu_defs.xml
@@ -17,17 +17,85 @@
wrx04
unknown
-
+
+
-
+
-
+
"This is a map of base ignition values."
-
+
+
+
+
+
+ "This is a map of base ignition values."
+
+
+
+
+
+
+ "Maximum allowed wastegate duty cycle."
+
+
+
+
+
+
+ "Target boost level."
+
+
+
+
+
+
+ "Low detonation fuel map, used when Ignition Advance Multiplier is greater than 4."
+
+
+
+
+
+
+ "Low detonation fuel map, used when Ignition Advance Multiplier is 4 or less."
+
+
+
+
+
+
+ "Maximum allowed Exhaust Gas Temperature limit before Check Engine Light."
+
+
+
"RPM at which limiter turns on and off."
-
+
"Injector flow rating in cc/min"
diff --git a/release notes.txt b/release notes.txt
index de3ff8bd..51289e12 100644
--- a/release notes.txt
+++ b/release notes.txt
@@ -6,12 +6,27 @@ Enginuity is currently in ALPHA TEST status, meaning it is untested and not inte
Until Enginuity reaches a mature point, releases will be quite frequent and will usually contain significant changes. However, some times I may release a revision to add a single feature I'd like users to have, or maybe just to add a certain ECU version. Until more features are complete, version support will be quite limited. If you'd like your ECU version to be added, please visit openecu.org and post a message in the Technical Tuning Software forum, with your image attached.
-.20a Release Notes
+0.2.1a Release Notes
------------------
As of this version, Enginuity has been completely rewritten and has NOT been tested thoroughly. This release is intended ONLY AS AN ALPHA TEST RELEASE and to be used ONLY BY EXPERIENCED USERS WILLING TO ACCEPT THE RISK. PLEASE register and report any bugs encountered at www.enginuity.org. More information about Enginuity and how to help test is available at www.enginuity.org.
+Version .20a had very little error handling, which prevented it from executing properly under unexpected conditions and most of these issues have been resolved, which should help with testing. I've also included a more complete ECU definition file for revision A4TF400E.
+
+
Changes:
--------
+0.2.1a (2/13/2006)
+------------------
+- Handles storage addresses that are out of range
+- Fixed conflicting parent/child table sizes (done)
+- Replaced "" menu with "Table" -- makes it more obviously a menu
+- Fixed 3D table sizing problem
+- Fixed colorizing exception
+- Fixed backwards endians
+- Fixed storage address out of range exception
+- Improved close image method
+
+
.20a (2/11/2006)
----------------
-Completely rewritten
@@ -32,7 +47,7 @@ Changes:
-Improved axis cell modification
-Axis cell changes can be saved
-Supported ECU Versions/Version Added
+Supported ECU Versions/Version Added - Deprecated as of version .20a. ECU versions are now defined in ecu_defs.xml.
----------------------
2004/2005 USDM WRX:
-A4TF300E .13a
diff --git a/src/Enginuity/ECUEditor.java b/src/Enginuity/ECUEditor.java
index d5400ed0..04147340 100644
--- a/src/Enginuity/ECUEditor.java
+++ b/src/Enginuity/ECUEditor.java
@@ -33,7 +33,7 @@ public class ECUEditor extends JFrame implements WindowListener {
private RomTree imageList = new RomTree(imageRoot);
private Vector images = new Vector();
private Settings settings = new Settings();
- private String version = new String(".20 Alpha");
+ private String version = new String("0.2.1 Alpha");
private String titleText = new String("Enginuity v" + version);
private JDesktopPane rightPanel = new JDesktopPane();
private Rom lastSelectedRom = null;
@@ -126,6 +126,7 @@ public class ECUEditor extends JFrame implements WindowListener {
RomTreeNode[] tableNodes = new RomTreeNode[tables.size()];
for (int i = 0; i < tables.size(); i++) {
tableNodes[i] = new RomTreeNode(tables.get(i));
+ //tableNodes[i].set
node.add(tableNodes[i]);
TableFrame frame = new TableFrame(tables.get(i));
@@ -136,20 +137,27 @@ public class ECUEditor extends JFrame implements WindowListener {
this.setLastSelectedRom(input);
}
- public void closeImage() {
- for (int i = 0; i < images.size(); i++) {
- if (images.get(i) == lastSelectedRom) {
- images.remove(i);
- }
- }
+ public void closeImage() {
for (int i = 0; i < imageRoot.getChildCount(); i++) {
if (((RomTreeNode)imageRoot.getChildAt(i)).getRom() == lastSelectedRom) {
+ ((Rom)images.get(i)).closeImage();
imageRoot.remove((DefaultMutableTreeNode)imageRoot.getChildAt(i));
+ images.remove(i);
}
}
imageList.updateUI();
setLastSelectedRom(null);
}
+
+ public void closeAllImages() {
+ while (imageRoot.getChildCount() > 0) {
+ ((Rom)images.get(0)).closeImage();
+ imageRoot.remove(0);
+ images.remove(0);
+ }
+ imageList.updateUI();
+ setLastSelectedRom(null);
+ }
public Rom getLastSelectedRom() {
return lastSelectedRom;
@@ -162,6 +170,8 @@ public class ECUEditor extends JFrame implements WindowListener {
} else {
this.setTitle(titleText + " - " + lastSelectedRom.getFileName());
}
+ toolBar.updateButtons();
+ menuBar.updateMenu();
}
public ECUEditorToolBar getToolBar() {
diff --git a/src/Enginuity/Maps/Rom.java b/src/Enginuity/Maps/Rom.java
index 2a48525a..bc615441 100644
--- a/src/Enginuity/Maps/Rom.java
+++ b/src/Enginuity/Maps/Rom.java
@@ -4,6 +4,9 @@ package Enginuity.Maps;
import Enginuity.ECUEditor;
import java.util.Vector;
+import javax.swing.JOptionPane;
+
+//import Enginuity.
public class Rom {
@@ -17,14 +20,18 @@ public class Rom {
}
public void addTable(Table table) {
- getTables().add(table);
+ tables.add(table);
}
public void populateTables(byte[] binData) {
this.binData = binData;
for (int i = 0; i < getTables().size(); i++) {
- //System.out.println("Populating table " + tables.get(i).getName());
- getTables().get(i).populateTable(binData);
+ try {
+ tables.get(i).populateTable(binData);
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ new JOptionPane().showMessageDialog(container, "Storage address for table \"" + tables.get(i).getName() + "\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE);
+ tables.remove(i);
+ }
}
}
@@ -77,4 +84,10 @@ public class Rom {
}
return binData;
}
+
+ public void closeImage() {
+ for (int i = 0; i < tables.size(); i++) {
+ tables.get(i).getFrame().dispose();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Enginuity/Maps/Table.java b/src/Enginuity/Maps/Table.java
index 2855385c..a20c3678 100644
--- a/src/Enginuity/Maps/Table.java
+++ b/src/Enginuity/Maps/Table.java
@@ -6,6 +6,7 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JLabel;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
public abstract class Table extends JPanel {
@@ -51,13 +52,17 @@ public abstract class Table extends JPanel {
centerPanel.setVisible(true);
}
- public void populateTable(byte[] input) {
+ public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
if (!isStatic) {
for (int i = 0; i < data.length; i++) {
if (data[i] == null) {
data[i] = new DataCell(scale);
data[i].setTable(this);
- data[i].setBinValue(RomAttributeParser.parseByteValue(input, endian, storageAddress + i * storageType, storageType));
+ try {
+ data[i].setBinValue(RomAttributeParser.parseByteValue(input, endian, storageAddress + i * storageType, storageType));
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
centerPanel.add(data[i]);
data[i].setYCoord(i);
data[i].setOriginalValue(data[i].getBinValue());
diff --git a/src/Enginuity/Maps/Table1D.java b/src/Enginuity/Maps/Table1D.java
index b7c78d04..17dafa92 100644
--- a/src/Enginuity/Maps/Table1D.java
+++ b/src/Enginuity/Maps/Table1D.java
@@ -10,10 +10,14 @@ public class Table1D extends Table {
super();
}
- public void populateTable(byte[] input) {
+ public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
centerLayout.setRows(1);
centerLayout.setColumns(this.getDataSize());
- super.populateTable(input);
+ try {
+ super.populateTable(input);
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
// add to table
for (int i = 0; i < this.getDataSize(); i++) {
diff --git a/src/Enginuity/Maps/Table2D.java b/src/Enginuity/Maps/Table2D.java
index 509fae4f..d1db8a56 100644
--- a/src/Enginuity/Maps/Table2D.java
+++ b/src/Enginuity/Maps/Table2D.java
@@ -36,11 +36,16 @@ public class Table2D extends Table {
frame.setSize(width, height);
}
- public void populateTable(byte[] input) {
+ public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
centerLayout.setRows(2);
centerLayout.setColumns(this.getDataSize());
- axis.populateTable(input);
- super.populateTable(input);
+
+ try {
+ axis.populateTable(input);
+ super.populateTable(input);
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
// add to table
for (int i = 0; i < this.getDataSize(); i++) {
diff --git a/src/Enginuity/Maps/Table3D.java b/src/Enginuity/Maps/Table3D.java
index bdeed074..ac4f949b 100644
--- a/src/Enginuity/Maps/Table3D.java
+++ b/src/Enginuity/Maps/Table3D.java
@@ -8,6 +8,7 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JLabel;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class Table3D extends Table {
@@ -21,7 +22,7 @@ public class Table3D extends Table {
public Table3D() {
super();
- verticalOverhead += 2;
+ verticalOverhead += 31;
horizontalOverhead += 5;
}
@@ -83,17 +84,22 @@ public class Table3D extends Table {
return data[0].length;
}
- public void populateTable(byte[] input) throws NullPointerException {
+ public void populateTable(byte[] input) throws NullPointerException, ArrayIndexOutOfBoundsException {
// fill first empty cell
centerPanel.add(new JLabel());
// populate axiis
- xAxis.populateTable(input);
- yAxis.populateTable(input);
+ try {
+ xAxis.populateTable(input);
+ yAxis.populateTable(input);
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
for (int i = 0; i < xAxis.getDataSize(); i++) {
centerPanel.add(xAxis.getDataCell(i));
}
-
+
int offset = 0;
for (int x = 0; x < yAxis.getDataSize(); x++) {
@@ -101,11 +107,16 @@ public class Table3D extends Table {
for (int y = 0; y < xAxis.getDataSize(); y++) {
data[y][x] = new DataCell(scale);
data[y][x].setTable(this);
- data[y][x].setBinValue(
- RomAttributeParser.parseByteValue(input,
- endian,
- storageAddress + offset * storageType,
- storageType));
+ try {
+ data[y][x].setBinValue(
+ RomAttributeParser.parseByteValue(input,
+ endian,
+ storageAddress + offset * storageType,
+ storageType));
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
centerPanel.add(data[y][x]);
data[y][x].setXCoord(y);
data[y][x].setYCoord(x);
@@ -144,6 +155,7 @@ public class Table3D extends Table {
for (int y = 0; y < data[0].length; y++) {
double scale = (double)(data[x][y].getBinValue() - low) / (high - low);
int g = (int)(255 - (255 - 140) * scale);
+ if (g > 255) g = 255;
data[x][y].setColor(new Color(255, g, 125));
}
}
diff --git a/src/Enginuity/Maps/XML/DOMRomUnmarshaller.java b/src/Enginuity/Maps/XML/DOMRomUnmarshaller.java
index 23055e10..372a23cd 100644
--- a/src/Enginuity/Maps/XML/DOMRomUnmarshaller.java
+++ b/src/Enginuity/Maps/XML/DOMRomUnmarshaller.java
@@ -160,7 +160,7 @@ public class DOMRomUnmarshaller {
if (n.getNodeName().equalsIgnoreCase("table")) {
if (table.getType() == Table.TABLE_2D) {
- if ((unmarshallTable(n).getType() == Table.TABLE_Y_AXIS) ||
+ if ((unmarshallTable(n).getType() == Table.TABLE_Y_AXIS) ||
(unmarshallTable(n).getType() == Table.TABLE_X_AXIS)) {
Table tempTable = (Table1D)(unmarshallTable(n));
tempTable.setAxisParent(table);
@@ -169,11 +169,12 @@ public class DOMRomUnmarshaller {
} else if (table.getType() == Table.TABLE_3D) {
if (unmarshallTable(n).getType() == Table.TABLE_X_AXIS) {
Table tempTable = (Table1D)(unmarshallTable(n));
- tempTable.setAxisParent(table);
+ tempTable.setAxisParent(table);
+ tempTable.setDataSize(((Table3D)table).getSizeX());
((Table3D)table).setXAxis((Table1D)tempTable);
} else if (unmarshallTable(n).getType() == Table.TABLE_Y_AXIS) {
Table tempTable = (Table1D)(unmarshallTable(n));
- tempTable.setAxisParent(table);
+ tempTable.setAxisParent(table);
((Table3D)table).setYAxis((Table1D)tempTable);
}
}
@@ -192,6 +193,14 @@ public class DOMRomUnmarshaller {
// unexpected node-type in Table (skip)
}
}
+
+ // set axis sizes
+ if (table.getType() == Table.TABLE_2D) {
+ if (((Table2D)table).getAxis().isStatic() == false) ((Table2D)table).getAxis().setDataSize(table.getDataSize());
+ } else if (table.getType() == Table.TABLE_3D) {
+ if (((Table3D)table).getXAxis().isStatic() == false) ((Table3D)table).getXAxis().setDataSize(((Table3D)table).getSizeX());
+ if (((Table3D)table).getYAxis().isStatic() == false) ((Table3D)table).getYAxis().setDataSize(((Table3D)table).getSizeY());
+ }
return table;
}
diff --git a/src/Enginuity/Maps/XML/RomAttributeParser.java b/src/Enginuity/Maps/XML/RomAttributeParser.java
index fa104f5e..731ba7e4 100644
--- a/src/Enginuity/Maps/XML/RomAttributeParser.java
+++ b/src/Enginuity/Maps/XML/RomAttributeParser.java
@@ -4,9 +4,6 @@ package Enginuity.Maps.XML;
import Enginuity.Maps.Table;
import Enginuity.Maps.Scale;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
public abstract class RomAttributeParser {
@@ -57,18 +54,22 @@ public abstract class RomAttributeParser {
}
}
- public static int parseByteValue(byte[] input, int endian, int address, int length) {
- int output = 0;
- if (endian == Table.ENDIAN_LITTLE) {
- for (int i = 0; i < length; i++) {
- output += (input[address + i] & 0xff) << 8 * (length - i - 1);
- }
- } else {
- for (int i = 0; i < length; i++) {
- output += (input[address + length - i - 1] & 0xff) << 8 * (length - i - 1);
+ public static int parseByteValue(byte[] input, int endian, int address, int length) throws ArrayIndexOutOfBoundsException {
+ try {
+ int output = 0;
+ if (endian == Table.ENDIAN_BIG) {
+ for (int i = 0; i < length; i++) {
+ output += (input[address + i] & 0xff) << 8 * (length - i - 1);
+ }
+ } else { // little endian
+ for (int i = 0; i < length; i++) {
+ output += (input[address + length - i - 1] & 0xff) << 8 * (length - i - 1);
+ }
}
+ return output;
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new ArrayIndexOutOfBoundsException();
}
- return output;
}
public static byte[] parseIntegerValue(int input, int endian, int length) {
@@ -82,10 +83,10 @@ public abstract class RomAttributeParser {
byte[] output = new byte[length];
for (int i = 0; i < length; i++) {
- if (endian == Table.ENDIAN_LITTLE) {
+ if (endian == Table.ENDIAN_BIG) {
//output[i] = byteArray[i + length];
output[i] = byteArray[4 - length + i];
- } else { // big endian
+ } else { // little endian
output[length - 1 - i] = byteArray[4 - length + i];
}
}
diff --git a/src/Enginuity/SwingComponents/ECUEditorMenuBar.java b/src/Enginuity/SwingComponents/ECUEditorMenuBar.java
index 6e5a23ab..8ab13e64 100644
--- a/src/Enginuity/SwingComponents/ECUEditorMenuBar.java
+++ b/src/Enginuity/SwingComponents/ECUEditorMenuBar.java
@@ -31,6 +31,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
private JMenuItem openImage = new JMenuItem("Open Image");
private JMenuItem saveImage = new JMenuItem("Save Image");
private JMenuItem closeImage = new JMenuItem("Close Image");
+ private JMenuItem closeAll = new JMenuItem("Close All Images");
private JMenuItem exit = new JMenuItem("Exit");
private ECUEditor parent;
@@ -42,18 +43,42 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
openImage.setMnemonic('O');
saveImage.setMnemonic('S');
closeImage.setMnemonic('C');
+ closeAll.setMnemonic('A');
exit.setMnemonic('X');
openImage.addActionListener(this);
saveImage.addActionListener(this);
closeImage.addActionListener(this);
+ closeAll.addActionListener(this);
exit.addActionListener(this);
fileMenu.add(openImage);
fileMenu.add(saveImage);
fileMenu.add(closeImage);
+ fileMenu.add(closeAll);
fileMenu.add(new JSeparator());
- fileMenu.add(exit);
+ fileMenu.add(exit);
+
+ this.updateMenu();
+ }
+
+ public void updateMenu() {
+ String file = "";
+ try {
+ file = " " + parent.getLastSelectedRom().getFileName();
+ } catch (NullPointerException ex) { }
+ if (file.equals("")) {
+ saveImage.setEnabled(false);
+ closeImage.setEnabled(false);
+ closeAll.setEnabled(false);
+ } else {
+ saveImage.setEnabled(true);
+ closeImage.setEnabled(true);
+ closeAll.setEnabled(true);
+ }
+
+ saveImage.setText("Save" + file);
+ closeImage.setText("Close" + file);
}
public void actionPerformed(ActionEvent e) {
@@ -61,16 +86,18 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
try {
this.openImageDialog();
} catch (XMLParseException ex) {
- new JOptionPane(ex, JOptionPane.ERROR_MESSAGE);
+ new JOptionPane().showMessageDialog(parent, ex, "XML Parse Exception", JOptionPane.ERROR_MESSAGE);
}
} else if (e.getSource() == saveImage) {
try {
this.saveImage(parent.getLastSelectedRom());
} catch (XMLParseException ex) {
- new JOptionPane(ex, JOptionPane.ERROR_MESSAGE);
+ new JOptionPane().showMessageDialog(parent, ex, "XML Parse Exception", JOptionPane.ERROR_MESSAGE);
}
} else if (e.getSource() == closeImage) {
this.closeImage();
+ } else if (e.getSource() == closeAll) {
+ this.closeAllImages();
} else if (e.getSource() == exit) {
System.exit(0);
}
@@ -80,6 +107,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
parent.closeImage();
}
+ public void closeAllImages() {
+ parent.closeAllImages();
+ }
+
public void saveImage(Rom input) throws XMLParseException {
if (parent.getLastSelectedRom() != null) {
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
diff --git a/src/Enginuity/SwingComponents/ECUEditorToolBar.java b/src/Enginuity/SwingComponents/ECUEditorToolBar.java
index c6197249..5e8fd91d 100644
--- a/src/Enginuity/SwingComponents/ECUEditorToolBar.java
+++ b/src/Enginuity/SwingComponents/ECUEditorToolBar.java
@@ -22,12 +22,33 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
this.add(openImage);
this.add(saveImage);
this.add(closeImage);
+
+ updateButtons();
openImage.addActionListener(this);
saveImage.addActionListener(this);
closeImage.addActionListener(this);
}
+ public void updateButtons() {
+ String file = "";
+ try {
+ file = " " + parent.getLastSelectedRom().getFileName();
+ } catch (NullPointerException ex) { }
+
+ openImage.setToolTipText("Open Image");
+ saveImage.setToolTipText("Save" + file);
+ closeImage.setToolTipText("Close" + file);
+
+ if (file.equals("")) {
+ saveImage.setEnabled(false);
+ closeImage.setEnabled(false);
+ } else {
+ saveImage.setEnabled(true);
+ closeImage.setEnabled(true);
+ }
+ }
+
public void actionPerformed(ActionEvent e) {
if (e.getSource() == openImage) {
try {
diff --git a/src/Enginuity/SwingComponents/EnginuityMenuBar.java b/src/Enginuity/SwingComponents/EnginuityMenuBar.java
new file mode 100644
index 00000000..98e6d863
--- /dev/null
+++ b/src/Enginuity/SwingComponents/EnginuityMenuBar.java
@@ -0,0 +1,124 @@
+package Enginuity.SwingComponents;
+
+import Enginuity.*;
+import Enginuity.Exceptions.RomNotFoundException;
+import Enginuity.Maps.ECUDefinitionCollection;
+import Enginuity.Maps.Rom;
+import Enginuity.Maps.XML.DOMRomUnmarshaller;
+import com.sun.org.apache.xerces.internal.parsers.DOMParser;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.FileInputStream;
+import javax.management.modelmbean.XMLParseException;
+import javax.swing.JFileChooser;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JSeparator;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import org.xml.sax.SAXException;
+
+
+public class EnginuityMenuBar extends JMenuBar implements ActionListener {
+
+ private JMenu fileMenu = new JMenu("File");
+ private JMenuItem openImage = new JMenuItem("Open Image");
+ private JMenuItem saveImage = new JMenuItem("Save Image");
+ private JMenuItem closeImage = new JMenuItem("Close Image");
+ private JMenuItem exit = new JMenuItem("Exit");
+ private ECUEditor parent;
+
+ public EnginuityMenuBar(ECUEditor parent) {
+ this.parent = parent;
+
+ add(fileMenu);
+ fileMenu.setMnemonic('F');
+ openImage.setMnemonic('O');
+ saveImage.setMnemonic('S');
+ closeImage.setMnemonic('C');
+ exit.setMnemonic('X');
+
+ openImage.addActionListener(this);
+ saveImage.addActionListener(this);
+ closeImage.addActionListener(this);
+ exit.addActionListener(this);
+
+ fileMenu.add(openImage);
+ fileMenu.add(saveImage);
+ fileMenu.add(closeImage);
+ fileMenu.add(new JSeparator());
+ fileMenu.add(exit);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == openImage) {
+ openImage();
+ } else if (e.getSource() == saveImage) {
+ this.saveImage(parent.getLastSelectedRom());
+ } else if (e.getSource() == closeImage) {
+ // close image code here
+ } else if (e.getSource() == exit) {
+ System.exit(0);
+ }
+ }
+
+ public void saveImage(Rom input) {
+ JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
+
+ if (fc.showSaveDialog(parent) == fc.APPROVE_OPTION) {
+ try {
+ byte[] output = parent.getLastSelectedRom().saveFile();
+ FileOutputStream fos = new FileOutputStream(fc.getSelectedFile());
+ fos.write(output);
+ fos.close();
+
+ } catch (FileNotFoundException ex) {
+ ex.printStackTrace();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public void openImage() {
+ JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
+ if (fc.showOpenDialog(parent) == fc.APPROVE_OPTION) {
+
+ try {
+ ECUDefinitionCollection roms = new ECUDefinitionCollection();
+ InputSource src = new InputSource(new FileInputStream(parent.getSettings().getEcuDefinitionFile()));
+ DOMRomUnmarshaller domUms = new DOMRomUnmarshaller();
+ DOMParser parser = new DOMParser();
+ parser.parse(src);
+ Document doc = parser.getDocument();
+
+ roms = domUms.unmarshallXMLDefinition(doc.getDocumentElement());
+ Rom ecuImage = roms.parseRom(fc.getSelectedFile());
+ ecuImage.setFileName(fc.getSelectedFile().getName());
+
+ parent.addRom(ecuImage);
+ parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
+ //System.out.println("File opened: " + ecuImage.getFileName());
+
+ } catch (FileNotFoundException ex) {
+ ex.printStackTrace();
+ } catch (XMLParseException ex) {
+ ex.printStackTrace();
+ } catch (SAXException ex) {
+ ex.printStackTrace();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ } catch (RomNotFoundException ex) {
+ new JOptionPane().showMessageDialog(parent, "ECU Definition Not Found", fc.getSelectedFile().getName() + " - Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ } else {
+ // no file selected (do nothing)
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Enginuity/SwingComponents/ImagePopupMenu.java b/src/Enginuity/SwingComponents/ImagePopupMenu.java
new file mode 100644
index 00000000..b8d58bf8
--- /dev/null
+++ b/src/Enginuity/SwingComponents/ImagePopupMenu.java
@@ -0,0 +1,24 @@
+package Enginuity.SwingComponents;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+public class ImagePopupMenu extends JPopupMenu implements MouseListener {
+
+ private JMenuItem properties = new JMenuItem("Properties");
+
+ public ImagePopupMenu() {
+ addMouseListener(this);
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ }
+
+ public void mousePressed(MouseEvent e) { }
+ public void mouseReleased(MouseEvent e) { }
+ public void mouseEntered(MouseEvent e) { }
+ public void mouseExited(MouseEvent e) { }
+}
\ No newline at end of file
diff --git a/src/Enginuity/SwingComponents/RomTree.java b/src/Enginuity/SwingComponents/RomTree.java
index fa6e473a..2a0bbb8d 100644
--- a/src/Enginuity/SwingComponents/RomTree.java
+++ b/src/Enginuity/SwingComponents/RomTree.java
@@ -8,6 +8,7 @@ import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
public class RomTree extends JTree implements MouseListener, TreeSelectionListener {
@@ -40,7 +41,7 @@ public class RomTree extends JTree implements MouseListener, TreeSelectionListen
}
}
- public void mousePressed(MouseEvent e) { }
+ public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
diff --git a/src/Enginuity/SwingComponents/RomTreeNode.java b/src/Enginuity/SwingComponents/RomTreeNode.java
index ad36e3b9..555eef0f 100644
--- a/src/Enginuity/SwingComponents/RomTreeNode.java
+++ b/src/Enginuity/SwingComponents/RomTreeNode.java
@@ -9,6 +9,7 @@ public class RomTreeNode extends DefaultMutableTreeNode {
private String type;
private Rom rom;
private Table table;
+ private String toolTip;
public RomTreeNode(Rom rom) {
super(rom.getFileName());
@@ -39,4 +40,12 @@ public class RomTreeNode extends DefaultMutableTreeNode {
public void setTable(Table table) {
this.table = table;
}
+
+ public void setToolTipText(String input) {
+ toolTip = input;
+ }
+
+ public String getToolTipText() {
+ return toolTip;
+ }
}
\ No newline at end of file
diff --git a/src/Enginuity/SwingComponents/TableMenuBar.java b/src/Enginuity/SwingComponents/TableMenuBar.java
index 2ca61d62..99ce7ee0 100644
--- a/src/Enginuity/SwingComponents/TableMenuBar.java
+++ b/src/Enginuity/SwingComponents/TableMenuBar.java
@@ -25,7 +25,6 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
super();
this.table = table;
this.add(fileMenu);
- fileMenu.setText(table.getName());
close.setText("Close " + table.getName());
fileMenu.add(compare);
fileMenu.add(copy);
@@ -48,6 +47,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
close.addActionListener(this);
fileMenu.setMnemonic('F');
+ fileMenu.setMnemonic('T');
compare.setMnemonic('P');
graph.setMnemonic('G');
overlay.setMnemonic('L');
diff --git a/src/Enginuity/SwingComponents/TableToolBar.java b/src/Enginuity/SwingComponents/TableToolBar.java
index ce237e8a..ec47d426 100644
--- a/src/Enginuity/SwingComponents/TableToolBar.java
+++ b/src/Enginuity/SwingComponents/TableToolBar.java
@@ -17,6 +17,10 @@ public class TableToolBar extends JToolBar implements MouseListener {
this.setFloatable(false);
this.add(increment);
this.add(decrement);
+
+ increment.setToolTipText("Increment Value (Coarse)");
+ decrement.setToolTipText("Decrement Value (Coarse)");
+
increment.addMouseListener(this);
decrement.addMouseListener(this);
}