From b7e2a4d25c989e48134eada5f35ccba06524bd9c Mon Sep 17 00:00:00 2001 From: Dale Schultz Date: Tue, 13 Sep 2011 20:28:14 +0000 Subject: [PATCH] More Editor/Logger refinements git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@329 38686702-15cf-42e4-a595-3071df8bf5ea --- src/com/romraider/logger/ecu/EcuLogger.java | 83 +++++-------------- src/com/romraider/maps/Rom.java | 21 ++++- src/com/romraider/maps/RomID.java | 10 +++ src/com/romraider/swing/RomPropertyPanel.java | 19 ++++- 4 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/com/romraider/logger/ecu/EcuLogger.java b/src/com/romraider/logger/ecu/EcuLogger.java index 6afb6ebe..d5ab911d 100644 --- a/src/com/romraider/logger/ecu/EcuLogger.java +++ b/src/com/romraider/logger/ecu/EcuLogger.java @@ -191,6 +191,11 @@ public final class EcuLogger extends AbstractFrame implements MessageListener { private static final String FILE_NAME_EXTENTION = "Text to add to the saved logfile name"; private static final String ECU_TEXT = "Engine Control Unit Polling"; private static final String TCU_TEXT = "Transmission Control Unit Polling"; + private static final String[] logFileText = {"1st PT","2nd PT","3rd PT", // PT = Part Throttle + "4th PT","5th PT","6th PT", + "1st WOT","2nd WOT","3rd WOT", + "4th WOT","5th WOT","6th WOT", + "cruising"}; private static final byte ECU_ID = (byte) 0x10; private static final byte TCU_ID = (byte) 0x18; private static String target = "ECU"; @@ -922,78 +927,32 @@ public final class EcuLogger extends AbstractFrame implements MessageListener { }); JPopupMenu fileNamePopup = new JPopupMenu(); - JMenuItem ecuIdItem1 = new JMenuItem("Use Current " + target + " ID"); - ecuIdItem1.addActionListener(new ActionListener() { + JMenuItem ecuIdItem = new JMenuItem("Use Current " + target + " ID"); + ecuIdItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fileNameExtention.setText(ecuInit.getEcuId()); settings.setLogfileNameText(fileNameExtention.getText()); } }); - JMenuItem ecuIdItem2 = new JMenuItem("1st WOT"); - ecuIdItem2.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("1st_WOT"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem3 = new JMenuItem("2nd WOT"); - ecuIdItem3.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("2nd_WOT"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem4 = new JMenuItem("3rd WOT"); - ecuIdItem4.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("3rd_WOT"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem5 = new JMenuItem("4th WOT"); - ecuIdItem5.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("4th_WOT"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem6 = new JMenuItem("5th WOT"); - ecuIdItem6.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("5th_WOT"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem7 = new JMenuItem("6th WOT"); - ecuIdItem7.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("6th_WOT"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem8 = new JMenuItem("cruising"); - ecuIdItem8.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - fileNameExtention.setText("cruising"); - settings.setLogfileNameText(fileNameExtention.getText()); - } - }); - JMenuItem ecuIdItem9 = new JMenuItem("Clear Logfile Text"); - ecuIdItem9.addActionListener(new ActionListener() { + fileNamePopup.add(ecuIdItem); + for (final String item : logFileText) { + ecuIdItem = new JMenuItem(item); + ecuIdItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + fileNameExtention.setText(item.replaceAll(" ", "_")); + settings.setLogfileNameText(fileNameExtention.getText()); + } + }); + fileNamePopup.add(ecuIdItem); + } + ecuIdItem = new JMenuItem("Clear Logfile Text"); + ecuIdItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fileNameExtention.setText(""); settings.setLogfileNameText(fileNameExtention.getText()); } }); - fileNamePopup.add(ecuIdItem1); - fileNamePopup.add(ecuIdItem2); - fileNamePopup.add(ecuIdItem3); - fileNamePopup.add(ecuIdItem4); - fileNamePopup.add(ecuIdItem5); - fileNamePopup.add(ecuIdItem6); - fileNamePopup.add(ecuIdItem7); - fileNamePopup.add(ecuIdItem8); - fileNamePopup.add(ecuIdItem9); + fileNamePopup.add(ecuIdItem); fileNameExtention.addMouseListener(new LogFileNameFieldAction(fileNamePopup)); JPanel panel = new JPanel(); diff --git a/src/com/romraider/maps/Rom.java b/src/com/romraider/maps/Rom.java index ac619392..825516c6 100644 --- a/src/com/romraider/maps/Rom.java +++ b/src/com/romraider/maps/Rom.java @@ -25,6 +25,7 @@ import com.romraider.swing.JProgressPane; import com.romraider.xml.TableNotFoundException; import static com.romraider.maps.RomChecksum.calculateRomChecksum; import static com.romraider.util.HexUtil.asBytes; +import static com.romraider.util.HexUtil.asHex; import org.apache.log4j.Logger; import javax.swing.JOptionPane; import java.io.File; @@ -106,6 +107,7 @@ public class Rom implements Serializable { try { table.populateTable(binData); TableUpdateHandler.getInstance().registerTable(table); + if (table.getName().equalsIgnoreCase("Checksum Fix")) setEditStamp(binData, table.getStorageAddress()); } catch (ArrayIndexOutOfBoundsException ex) { LOGGER.error(table.getName() + @@ -133,7 +135,24 @@ public class Rom implements Serializable { } } - public void setRomID(RomID romID) { + private void setEditStamp(byte[] binData, int address) { + byte[] stampData = new byte[4]; + System.arraycopy(binData, address+204, stampData, 0, stampData.length); + String stamp = asHex(stampData); + if (stamp.equalsIgnoreCase("FFFFFFFF")) { + romID.setEditStamp(""); + } + else { + StringBuilder niceStamp = new StringBuilder(stamp); + niceStamp.insert(6, " v"); + niceStamp.insert(4, "-"); + niceStamp.insert(2, "-"); + niceStamp.insert(0, "20"); + romID.setEditStamp(niceStamp.toString()); + } + } + + public void setRomID(RomID romID) { this.romID = romID; } diff --git a/src/com/romraider/maps/RomID.java b/src/com/romraider/maps/RomID.java index 0da5eea3..c40da685 100644 --- a/src/com/romraider/maps/RomID.java +++ b/src/com/romraider/maps/RomID.java @@ -39,6 +39,7 @@ public class RomID implements Serializable { private String year = "Unknown"; private String flashMethod = "";//flash method string used for ecuflash private String memModel = "";//model used for reflashing with ecuflash + private String editStamp = "";//YYYY-MM-DD and v, the save count for this ROM private int fileSize = 0; private int ramOffset = 0; private boolean obsolete = false; // whether a more recent revision exists @@ -190,4 +191,13 @@ public class RomID implements Serializable { public void setObsolete(boolean obsolete) { this.obsolete = obsolete; } + + public String getEditStamp() { + return editStamp; + } + + public void setEditStamp(String editStamp) { + this.editStamp = editStamp; + } + } \ No newline at end of file diff --git a/src/com/romraider/swing/RomPropertyPanel.java b/src/com/romraider/swing/RomPropertyPanel.java index bb9f56d6..2c7d9258 100644 --- a/src/com/romraider/swing/RomPropertyPanel.java +++ b/src/com/romraider/swing/RomPropertyPanel.java @@ -43,6 +43,7 @@ public class RomPropertyPanel extends javax.swing.JPanel { model.setText(rom.getRomID().getModel()); submodel.setText(rom.getRomID().getSubModel()); transmission.setText(rom.getRomID().getTransmission()); + editStamp.setText(rom.getRomID().getEditStamp()); tableList.setListData(rom.getTables()); } @@ -80,7 +81,13 @@ public class RomPropertyPanel extends javax.swing.JPanel { jScrollPane1 = new javax.swing.JScrollPane(); tableList = new javax.swing.JList(); lblTables = new javax.swing.JLabel(); + lblEditStamp = new javax.swing.JLabel(); + editStamp = new javax.swing.JLabel(); + lblEditStamp.setText("Edit Stamp:"); + + editStamp.setText("stamp"); + lblFilename.setText("Filename:"); fileName.setText("Filename"); @@ -195,11 +202,13 @@ public class RomPropertyPanel extends javax.swing.JPanel { .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(lblInternalId) - .add(lblStorageAddress)) + .add(lblStorageAddress) + .add(lblEditStamp)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 53, Short.MAX_VALUE) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(internalID) - .add(storageAddress)) + .add(storageAddress) + .add(editStamp)) .add(36, 36, 36)) .add(lblTables) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) @@ -229,7 +238,9 @@ public class RomPropertyPanel extends javax.swing.JPanel { .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lblFilesize) - .add(fileSize)))) + .add(fileSize) + .add(lblEditStamp) + .add(editStamp)))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(lblTables) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) @@ -291,6 +302,8 @@ public class RomPropertyPanel extends javax.swing.JPanel { private javax.swing.JLabel transmission; private javax.swing.JLabel xmlID; private javax.swing.JLabel year; + private javax.swing.JLabel lblEditStamp; + private javax.swing.JLabel editStamp; // End of variables declaration//GEN-END:variables } \ No newline at end of file