- Make abstract base class for all frames (ECUEditor, ECULogger, RamTuneTetsApp). This should simplify adding new windows

- Move ECUEditor package down to parallel ECULogger.  This is general cleanup refactoring
- Collect some commonality from Injector and MAF tabs into Tab interface.  This simplifies the tab implementations somewhat, but does not address the fundamental question of what a "tab" should be.  There was more commonality that could have been consolidated, but that seemed potentially restrictive.


git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@229 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
lizzardo 2009-03-15 17:01:13 +00:00
parent 7546cddf50
commit f27639cb39
21 changed files with 126 additions and 80 deletions

View File

@ -19,14 +19,15 @@
package com.romraider;
import static com.romraider.ECUEditorManager.getECUEditor;
import static com.romraider.Version.PRODUCT_NAME;
import static com.romraider.editor.ecu.ECUEditorManager.getECUEditor;
import static com.romraider.logger.ecu.EcuLogger.startLogger;
import static com.romraider.swing.LookAndFeelManager.initLookAndFeel;
import static com.romraider.util.LogManager.initDebugLogging;
import static com.romraider.util.RomServer.isRunning;
import static com.romraider.util.RomServer.sendRomToOpenInstance;
import static com.romraider.util.RomServer.waitForRom;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.util.SettingsManager;
import com.romraider.util.SettingsManagerImpl;
import org.apache.log4j.Logger;

View File

@ -17,16 +17,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider;
package com.romraider.editor.ecu;
import com.centerkey.utils.BareBonesBrowserLaunch;
import static com.romraider.Version.ECU_DEFS_URL;
import static com.romraider.Version.PRODUCT_NAME;
import static com.romraider.Version.VERSION;
import com.romraider.Settings;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.maps.Rom;
import com.romraider.maps.Table;
import com.romraider.net.URL;
import com.romraider.swing.AbstractFrame;
import com.romraider.swing.ECUEditorMenuBar;
import com.romraider.swing.ECUEditorToolBar;
import com.romraider.swing.JProgressPane;
@ -44,7 +46,6 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
@ -65,9 +66,7 @@ import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -76,7 +75,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;
public class ECUEditor extends JFrame implements WindowListener, PropertyChangeListener {
public class ECUEditor extends AbstractFrame {
private static final long serialVersionUID = -7826850987392016292L;
private String titleText = PRODUCT_NAME + " v" + VERSION + " | ECU Editor";

View File

@ -17,10 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider;
package com.romraider.editor.ecu;
import javax.swing.SwingUtilities;
public class ECUEditorManager {
private static ECUEditor editor = null;

View File

@ -20,11 +20,12 @@
package com.romraider.logger.ecu;
import static com.centerkey.utils.BareBonesBrowserLaunch.openURL;
import com.romraider.ECUEditor;
import com.romraider.Settings;
import static com.romraider.Version.LOGGER_DEFS_URL;
import static com.romraider.Version.PRODUCT_NAME;
import static com.romraider.Version.VERSION;
import com.romraider.swing.AbstractFrame;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.io.serial.port.SerialPortRefresher;
import com.romraider.logger.ecu.comms.controller.LoggerController;
import com.romraider.logger.ecu.comms.controller.LoggerControllerImpl;
@ -140,9 +141,7 @@ import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import static java.lang.System.currentTimeMillis;
import java.util.ArrayList;
@ -163,7 +162,7 @@ TODO: Add custom graph tab (eg. engine speed vs. boost, etc.)
TODO: Add log analysis tab (or maybe new window?), including log playback, custom graphs, map compare, etc
*/
public final class EcuLogger extends JFrame implements WindowListener, PropertyChangeListener, MessageListener {
public final class EcuLogger extends AbstractFrame implements MessageListener {
private static final long serialVersionUID = 7145423251696282784L;
private static final Logger LOGGER = Logger.getLogger(EcuLogger.class);
private static final String ECU_LOGGER_TITLE = PRODUCT_NAME + " v" + VERSION + " | ECU Logger";

View File

@ -19,10 +19,31 @@
package com.romraider.logger.ecu.ui.tab;
import java.util.List;
import javax.swing.JPanel;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;
/**
* Interface for Logger tabs that have the following:
*
* Control panel where logging information and constraints are set
* ChartPanel where graph of data is displayed
*
*/
public interface Tab {
JPanel getPanel();
boolean isValidMafvChange(double value);
boolean isRecordData();
void addData(double xData, double yData);
void setEcuParams(List<EcuParameter> params);
void setEcuSwitches(List<EcuSwitch> switches);
void setExternalDatas(List<ExternalData> external);
}

View File

@ -19,7 +19,7 @@
package com.romraider.logger.ecu.ui.tab.injector;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;

View File

@ -19,11 +19,7 @@
package com.romraider.logger.ecu.ui.tab.injector;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;
import com.romraider.logger.ecu.ui.tab.Tab;
import java.util.List;
public interface InjectorTab extends Tab {
@ -31,8 +27,6 @@ public interface InjectorTab extends Tab {
double getFuelDensity();
boolean isRecordData();
boolean isValidClOl(double value);
boolean isValidAfr(double value);
@ -41,17 +35,12 @@ public interface InjectorTab extends Tab {
boolean isValidMaf(double value);
boolean isValidMafvChange(double value);
boolean isValidCoolantTemp(double value);
boolean isValidIntakeAirTemp(double value);
boolean isValidTipInThrottle(double value);
void addData(double mafv, double correction);
void setEcuParams(List<EcuParameter> params);
void setEcuSwitches(List<EcuSwitch> switches);
void setExternalDatas(List<ExternalData> external);
}

View File

@ -19,7 +19,7 @@
package com.romraider.logger.ecu.ui.tab.injector;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;
@ -91,8 +91,8 @@ public final class InjectorTabImpl extends JPanel implements InjectorTab {
return controlPanel.isValidTipInThrottle(value);
}
public void addData(double mafv, double correction) {
chartPanel.addData(mafv, correction);
public void addData(double pulseWidth, double fuelcc) {
chartPanel.addData(pulseWidth, fuelcc);
}
public void setEcuParams(List<EcuParameter> params) {

View File

@ -19,7 +19,7 @@
package com.romraider.logger.ecu.ui.tab.maf;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;

View File

@ -19,14 +19,9 @@
package com.romraider.logger.ecu.ui.tab.maf;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;
import com.romraider.logger.ecu.ui.tab.Tab;
import java.util.List;
public interface MafTab extends Tab {
boolean isRecordData();
boolean isValidClOl(double value);
@ -36,17 +31,12 @@ public interface MafTab extends Tab {
boolean isValidMaf(double value);
boolean isValidMafvChange(double value);
boolean isValidCoolantTemp(double value);
boolean isValidIntakeAirTemp(double value);
boolean isValidTipInThrottle(double value);
void addData(double mafv, double correction);
void setEcuParams(List<EcuParameter> params);
void setEcuSwitches(List<EcuSwitch> switches);
void setExternalDatas(List<ExternalData> external);
}

View File

@ -19,7 +19,7 @@
package com.romraider.logger.ecu.ui.tab.maf;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.definition.EcuParameter;
import com.romraider.logger.ecu.definition.EcuSwitch;
import com.romraider.logger.ecu.definition.ExternalData;

View File

@ -19,7 +19,7 @@
package com.romraider.maps;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.swing.JProgressPane;
import com.romraider.xml.TableNotFoundException;

View File

@ -20,6 +20,7 @@
package com.romraider.ramtune.test;
import com.romraider.Settings;
import com.romraider.swing.AbstractFrame;
import com.romraider.io.connection.ConnectionProperties;
import com.romraider.io.protocol.Protocol;
import com.romraider.io.protocol.ssm.SSMProtocol;
@ -41,7 +42,6 @@ import static com.romraider.util.ThreadUtil.sleep;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
@ -72,8 +72,6 @@ import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
@ -85,7 +83,7 @@ import java.util.List;
*
* It is also a bit of a mess and needs to be cleaned up...
*/
public final class RamTuneTestApp extends JFrame implements WindowListener {
public final class RamTuneTestApp extends AbstractFrame {
private static final long serialVersionUID = 7140513114169019846L;
private static final String REGEX_VALID_ADDRESS_BYTES = "[0-9a-fA-F]{6}";
private static final String REGEX_VALID_DATA_BYTES = "[0-9a-fA-F]{2,}";
@ -387,27 +385,6 @@ public final class RamTuneTestApp extends JFrame implements WindowListener {
showMessageDialog(this, message, "Error", ERROR_MESSAGE);
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
//**********************************************************************
public static void main(String[] args) {

View File

@ -0,0 +1,65 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2009 RomRaider.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.romraider.swing;
import java.awt.HeadlessException;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
public abstract class AbstractFrame extends JFrame implements WindowListener, PropertyChangeListener {
public AbstractFrame() throws HeadlessException {
super();
}
public AbstractFrame(String arg0) throws HeadlessException {
super(arg0);
}
private static final long serialVersionUID = 7948304087075622157L;
public void windowActivated(WindowEvent arg0) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void propertyChange(PropertyChangeEvent arg0) {
}
}

View File

@ -19,7 +19,8 @@
package com.romraider.swing;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import javax.swing.JFileChooser;
import javax.swing.ListSelectionModel;
import java.awt.Font;

View File

@ -20,13 +20,14 @@
package com.romraider.swing;
import com.centerkey.utils.BareBonesBrowserLaunch;
import com.romraider.ECUEditor;
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 com.romraider.editor.ecu.ECUEditor;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.maps.Rom;
import com.romraider.ramtune.test.RamTuneTestApp;

View File

@ -19,7 +19,7 @@
package com.romraider.swing;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.maps.Rom;
import static javax.swing.BorderFactory.createLineBorder;
import javax.swing.ImageIcon;

View File

@ -19,7 +19,8 @@
package com.romraider.swing;
import com.romraider.ECUEditor;
import com.romraider.editor.ecu.ECUEditor;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

View File

@ -78,7 +78,7 @@ public class RomTreeNode extends DefaultMutableTreeNode {
DefaultMutableTreeNode category = getChildAt(i);
// loop through tables in each category
for (Enumeration j = category.children(); j.hasMoreElements();) {
for (Enumeration<?> j = category.children(); j.hasMoreElements();) {
((TableTreeNode) j.nextElement()).getFrame().dispose();
}

View File

@ -20,9 +20,10 @@
package com.romraider.swing;
import ZoeloeSoft.projects.JFontChooser.JFontChooser;
import com.romraider.ECUEditor;
import com.romraider.Settings;
import static com.romraider.Version.PRODUCT_NAME;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.util.FileAssociator;
import javax.swing.JColorChooser;
import javax.swing.JFrame;

View File

@ -21,8 +21,8 @@
package com.romraider.xml;
import com.romraider.ECUEditor;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.maps.DataCell;
import com.romraider.maps.Rom;
import com.romraider.maps.RomID;