mirror of https://github.com/rusefi/RomRaider.git
Merge 5 commits of remote-tracking branch 'scotthew/ScotthewFixes', minus numerous formatting changes.
This commit is contained in:
commit
2b816dabce
|
@ -37,8 +37,37 @@ import java.util.Vector;
|
|||
public class Settings implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1026542922680475190L;
|
||||
private Dimension windowSize = new Dimension(800, 600);
|
||||
private Point windowLocation = new Point();
|
||||
|
||||
public static final String NEW_LINE = System.getProperty("line.separator");
|
||||
public static final String TAB = "\t";
|
||||
|
||||
public static final String TABLE_CLIPBOARD_FORMAT_ELEMENT = "table-clipboard-format";
|
||||
public static final String TABLE_CLIPBOARD_FORMAT_ATTRIBUTE = "format-string";
|
||||
public static final String TABLE_ELEMENT = "table";
|
||||
public static final String TABLE1D_ELEMENT = "table1D";
|
||||
public static final String TABLE2D_ELEMENT = "table2D";
|
||||
public static final String TABLE3D_ELEMENT = "table3D";
|
||||
public static final String TABLE_HEADER_ATTRIBUTE = "table-header";
|
||||
|
||||
public static final String DEFAULT_CLIPBOARD_FORMAT = "Default";
|
||||
public static final String DEFAULT_TABLE_HEADER = "[Table1D]" + NEW_LINE;
|
||||
public static final String DEFAULT_TABLE1D_HEADER = "";
|
||||
public static final String DEFAULT_TABLE2D_HEADER = "[Table2D]" + NEW_LINE;
|
||||
public static final String DEFAULT_TABLE3D_HEADER = "[Table3D]" + NEW_LINE;
|
||||
|
||||
public static final String AIRBOYS_CLIPBOARD_FORMAT = "Airboys";
|
||||
public static final String AIRBOYS_TABLE_HEADER = "";
|
||||
public static final String AIRBOYS_TABLE1D_HEADER = "";
|
||||
public static final String AIRBOYS_TABLE2D_HEADER = "[Table2D]" + NEW_LINE;
|
||||
public static final String AIRBOYS_TABLE3D_HEADER = "[Table3D]" + TAB;
|
||||
|
||||
public static final String CUSTOM_CLIPBOARD_FORMAT = "Custom";
|
||||
|
||||
public static final String REPOSITORY_ELEMENT_NAME = "repository-dir";
|
||||
public static final String REPOSITORY_ATTRIBUTE_NAME = "path";
|
||||
|
||||
private final Dimension windowSize = new Dimension(800, 600);
|
||||
private final Point windowLocation = new Point();
|
||||
private int splitPaneLocation = 150;
|
||||
private boolean windowMaximized;
|
||||
|
||||
|
@ -46,6 +75,7 @@ public class Settings implements Serializable {
|
|||
|
||||
private Vector<File> ecuDefinitionFiles = new Vector<File>();
|
||||
private File lastImageDir = new File("images");
|
||||
private File lastRepositoryDir = new File("repositories");
|
||||
private boolean obsoleteWarning = true;
|
||||
private boolean calcConflictWarning = true;
|
||||
private boolean debug;
|
||||
|
@ -92,6 +122,12 @@ public class Settings implements Serializable {
|
|||
private static String j2534Device;
|
||||
private static String j2534Protocol = "ISO9141";
|
||||
|
||||
private String tableClipboardFormat = DEFAULT_CLIPBOARD_FORMAT; // Currently 2 options. Default and Airboy. Custom is not hooked up.
|
||||
private String tableHeader = DEFAULT_TABLE_HEADER;
|
||||
private String table1DHeader = DEFAULT_TABLE1D_HEADER;
|
||||
private String table2DHeader = DEFAULT_TABLE2D_HEADER;
|
||||
private String table3DHeader = DEFAULT_TABLE3D_HEADER;
|
||||
|
||||
public Settings() {
|
||||
//center window by default
|
||||
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
|
@ -135,6 +171,14 @@ public class Settings implements Serializable {
|
|||
this.lastImageDir = lastImageDir;
|
||||
}
|
||||
|
||||
public File getLastRepositoryDir() {
|
||||
return lastRepositoryDir;
|
||||
}
|
||||
|
||||
public void setLastRepositoryDir(File lastRepositoryDir) {
|
||||
this.lastRepositoryDir = lastRepositoryDir;
|
||||
}
|
||||
|
||||
public int getSplitPaneLocation() {
|
||||
return splitPaneLocation;
|
||||
}
|
||||
|
@ -445,7 +489,7 @@ public class Settings implements Serializable {
|
|||
public void setLoggerPluginPorts(Map<String, String> loggerPluginPorts) {
|
||||
this.loggerPluginPorts = loggerPluginPorts;
|
||||
}
|
||||
|
||||
|
||||
public void setLoggerParameterListState(boolean ShowListState) {
|
||||
this.loggerParameterListState = ShowListState;
|
||||
}
|
||||
|
@ -509,4 +553,60 @@ public class Settings implements Serializable {
|
|||
public static String getJ2534Protocol() {
|
||||
return j2534Protocol;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTableClipboardFormat(String formatString) {
|
||||
this.tableClipboardFormat = formatString;
|
||||
}
|
||||
|
||||
public String getTableClipboardFormat() {
|
||||
return this.tableClipboardFormat;
|
||||
}
|
||||
|
||||
public void setTableHeader(String header) {
|
||||
this.tableHeader = header;
|
||||
}
|
||||
|
||||
public String getTableHeader() {
|
||||
return this.tableHeader;
|
||||
}
|
||||
|
||||
public void setTable1DHeader(String header) {
|
||||
this.table1DHeader = header;
|
||||
}
|
||||
|
||||
public String getTable1DHeader() {
|
||||
return this.table1DHeader;
|
||||
}
|
||||
|
||||
public void setTable2DHeader(String header) {
|
||||
this.table2DHeader = header;
|
||||
}
|
||||
|
||||
public String getTable2DHeader() {
|
||||
return this.table2DHeader;
|
||||
}
|
||||
|
||||
public void setTable3DHeader(String header) {
|
||||
this.table3DHeader = header;
|
||||
}
|
||||
|
||||
public String getTable3DHeader() {
|
||||
return this.table3DHeader;
|
||||
}
|
||||
|
||||
public void setDefaultFormat() {
|
||||
this.tableClipboardFormat = DEFAULT_CLIPBOARD_FORMAT;
|
||||
this.tableHeader = DEFAULT_TABLE_HEADER;
|
||||
this.table1DHeader = DEFAULT_TABLE1D_HEADER;
|
||||
this.table2DHeader = DEFAULT_TABLE2D_HEADER;
|
||||
this.table3DHeader = DEFAULT_TABLE3D_HEADER;
|
||||
}
|
||||
|
||||
public void setAirboysFormat() {
|
||||
this.tableClipboardFormat = AIRBOYS_CLIPBOARD_FORMAT;
|
||||
this.tableHeader = AIRBOYS_TABLE_HEADER;
|
||||
this.table1DHeader = AIRBOYS_TABLE1D_HEADER;
|
||||
this.table2DHeader = AIRBOYS_TABLE2D_HEADER;
|
||||
this.table3DHeader = AIRBOYS_TABLE3D_HEADER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,21 +48,11 @@ import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
|||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.JOptionPane.showOptionDialog;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS;
|
||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.tree.TreePath;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
@ -80,21 +70,34 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
public class ECUEditor extends AbstractFrame {
|
||||
private static final long serialVersionUID = -7826850987392016292L;
|
||||
|
||||
private String titleText = PRODUCT_NAME + " v" + VERSION + " | ECU Editor";
|
||||
private final String titleText = PRODUCT_NAME + " v" + VERSION + " | ECU Editor";
|
||||
|
||||
private static final String NEW_LINE = System.getProperty("line.separator");
|
||||
private final SettingsManager settingsManager = new SettingsManagerImpl();
|
||||
private RomTreeRootNode imageRoot = new RomTreeRootNode("Open Images");
|
||||
private RomTree imageList = new RomTree(imageRoot);
|
||||
private final RomTreeRootNode imageRoot = new RomTreeRootNode("Open Images");
|
||||
private final RomTree imageList = new RomTree(imageRoot);
|
||||
public MDIDesktopPane rightPanel = new MDIDesktopPane();
|
||||
public JProgressPane statusPanel = new JProgressPane();
|
||||
private JSplitPane splitPane = new JSplitPane();
|
||||
private Rom lastSelectedRom = null;
|
||||
private ECUEditorToolBar toolBar;
|
||||
private ECUEditorMenuBar menuBar;
|
||||
private final ECUEditorMenuBar menuBar;
|
||||
private Settings settings;
|
||||
|
||||
public ECUEditor() {
|
||||
|
@ -200,6 +203,7 @@ public class ECUEditor extends AbstractFrame {
|
|||
settings.setWindowSize(getSize());
|
||||
settings.setWindowLocation(getLocation());
|
||||
|
||||
// Save when exit to save file settings.
|
||||
settingsManager.save(settings, statusPanel);
|
||||
statusPanel.update("Ready...", 0);
|
||||
repaint();
|
||||
|
@ -433,13 +437,26 @@ public class ECUEditor extends AbstractFrame {
|
|||
|
||||
} catch (StackOverflowError ex) {
|
||||
// handles looped inheritance, which will use up all available memory
|
||||
showMessageDialog(this, "Looped \"base\" attribute in XML definitions.", "Error Loading ROM", ERROR_MESSAGE);
|
||||
showMessageDialog(this, "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(this, "Error loading Image. Out of memeory.", "Error Loading " + inputFile.getName(), ERROR_MESSAGE);
|
||||
|
||||
} finally {
|
||||
// remove progress bar
|
||||
//progress.dispose();
|
||||
statusPanel.update("Ready...", 0);
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -458,5 +475,7 @@ public class ECUEditor extends AbstractFrame {
|
|||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
public SettingsManager getSettingsManager() {
|
||||
return this.settingsManager;
|
||||
}
|
||||
}
|
|
@ -262,8 +262,8 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
private List<EcuParameter> ecuParams;
|
||||
private SerialPortRefresher refresher;
|
||||
private JWindow startStatus;
|
||||
private JLabel startText = new JLabel(" Initializing Logger...");
|
||||
private String HOME = System.getProperty("user.home");
|
||||
private final JLabel startText = new JLabel(" Initializing Logger...");
|
||||
private final String HOME = System.getProperty("user.home");
|
||||
private StatusIndicator statusIndicator;
|
||||
|
||||
public EcuLogger(Settings settings) {
|
||||
|
@ -505,9 +505,9 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
defVersion);
|
||||
LOGGER.info(loadResult);
|
||||
} catch (ConfigurationException cfe) {
|
||||
reportError(cfe);
|
||||
showMissingConfigDialog();
|
||||
}
|
||||
reportError(cfe);
|
||||
showMissingConfigDialog();
|
||||
}
|
||||
catch (Exception e) {
|
||||
reportError(e);
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
settings.setDestinationId(TCU_ID);
|
||||
target = "TCU";
|
||||
}
|
||||
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.romraider.logger.ecu.ui.tab;
|
||||
package com.romraider.logger.ecu.ui.tab.dyno;
|
||||
|
||||
import com.romraider.logger.ecu.ui.handler.graph.SpringUtilities;
|
||||
import com.romraider.logger.ecu.ui.tab.CircleDrawer;
|
||||
import com.romraider.logger.ecu.ui.tab.XYTrendline;
|
||||
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import jamlab.Polyfit;
|
||||
import static java.awt.Color.BLACK;
|
|
@ -30,9 +30,9 @@ import com.romraider.logger.ecu.definition.EcuSwitch;
|
|||
import com.romraider.logger.ecu.definition.ExternalData;
|
||||
import com.romraider.logger.ecu.definition.LoggerData;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
import com.romraider.logger.ecu.ui.tab.DynoChartPanel;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.calculateMph;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.calculateRpm;
|
||||
import static com.romraider.logger.car.util.TorqueCalculator.calculateTorque;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.*;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import static java.awt.GridBagConstraints.CENTER;
|
||||
import static java.awt.GridBagConstraints.HORIZONTAL;
|
||||
|
@ -180,26 +180,26 @@ public final class DynoControlPanel extends JPanel {
|
|||
private String[] widthArr;
|
||||
private String[] aspectArr;
|
||||
private String[] sizeArr;
|
||||
private JTextField carMass = new JTextField("0", 4);
|
||||
private JTextField deltaMass = new JTextField("225", 4);
|
||||
private JTextField dragCoeff = new JTextField("0", 4);
|
||||
private JTextField rollCoeff = new JTextField("0", 4);
|
||||
private JTextField frontalArea = new JTextField("0", 4);
|
||||
private JTextField rpmMin = new JTextField("2000", 4);
|
||||
private JTextField rpmMax = new JTextField("6500", 4);
|
||||
private JTextField elevation = new JTextField("200", 4);
|
||||
private JTextField relHumid = new JTextField("60", 4);
|
||||
private JTextField ambTemp = new JTextField("68", 4);
|
||||
private JTextField gearRatio = new JTextField("0", 4);
|
||||
private JTextField finalRatio = new JTextField("0", 4);
|
||||
private JTextField transmission = new JTextField("0", 4);
|
||||
private JTextField tireWidth = new JTextField("0", 4);
|
||||
private JTextField tireAspect = new JTextField("0", 4);
|
||||
private JTextField tireSize = new JTextField("0", 4);
|
||||
private JLabel elevLabel = new JLabel("Elevation (ft)");
|
||||
private JLabel tempLabel = new JLabel("Air Temperature (\u00b0F)");
|
||||
private JLabel deltaMassLabel = new JLabel("Delta Weight (lbs)");
|
||||
private JLabel carMassLabel = new JLabel("Base Weight (lbs)");
|
||||
private final JTextField carMass = new JTextField("0", 4);
|
||||
private final JTextField deltaMass = new JTextField("225", 4);
|
||||
private final JTextField dragCoeff = new JTextField("0", 4);
|
||||
private final JTextField rollCoeff = new JTextField("0", 4);
|
||||
private final JTextField frontalArea = new JTextField("0", 4);
|
||||
private final JTextField rpmMin = new JTextField("2000", 4);
|
||||
private final JTextField rpmMax = new JTextField("6500", 4);
|
||||
private final JTextField elevation = new JTextField("200", 4);
|
||||
private final JTextField relHumid = new JTextField("60", 4);
|
||||
private final JTextField ambTemp = new JTextField("68", 4);
|
||||
private final JTextField gearRatio = new JTextField("0", 4);
|
||||
private final JTextField finalRatio = new JTextField("0", 4);
|
||||
private final JTextField transmission = new JTextField("0", 4);
|
||||
private final JTextField tireWidth = new JTextField("0", 4);
|
||||
private final JTextField tireAspect = new JTextField("0", 4);
|
||||
private final JTextField tireSize = new JTextField("0", 4);
|
||||
private final JLabel elevLabel = new JLabel("Elevation (ft)");
|
||||
private final JLabel tempLabel = new JLabel("Air Temperature (\u00b0F)");
|
||||
private final JLabel deltaMassLabel = new JLabel("Delta Weight (lbs)");
|
||||
private final JLabel carMassLabel = new JLabel("Base Weight (lbs)");
|
||||
// private static final String SI = "SI";
|
||||
private String units = IMPERIAL;
|
||||
private String preUnits = IMPERIAL;
|
||||
|
@ -211,8 +211,8 @@ public final class DynoControlPanel extends JPanel {
|
|||
private String iatLogUnits = "F";
|
||||
private String atmLogUnits = "psi";
|
||||
private String vsLogUnits = LOG_VS_I;
|
||||
private double[] results = new double[5];
|
||||
private String[] resultStrings = new String[6];
|
||||
private final double[] results = new double[5];
|
||||
private final String[] resultStrings = new String[6];
|
||||
// private String hpUnits = "hp(I)";
|
||||
// private String tqUnits = "lbf-ft";
|
||||
private double distance;
|
||||
|
|
|
@ -19,20 +19,22 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.tab.dyno;
|
||||
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.WEST;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
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;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
import com.romraider.logger.ecu.ui.tab.DynoChartPanel;
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.WEST;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.List;
|
||||
|
||||
public final class DynoTabImpl extends JPanel implements DynoTab {
|
||||
private static final long serialVersionUID = 2787020251963102201L;
|
||||
|
@ -47,65 +49,81 @@ public final class DynoTabImpl extends JPanel implements DynoTab {
|
|||
add(chartPanel, CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcRpm(double vs) {
|
||||
return controlPanel.calcRpm(vs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnv(double iat, double pressure) {
|
||||
controlPanel.updateEnv(iat, pressure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidET(long now, double vs) {
|
||||
return controlPanel.isValidET(now, vs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecordET() {
|
||||
return controlPanel.isRecordET();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecordData() {
|
||||
return controlPanel.isRecordData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManual() {
|
||||
return controlPanel.isManual();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnv() {
|
||||
return controlPanel.getEnv();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidData(double rpm, double ta) {
|
||||
return controlPanel.isValidData(rpm, ta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData(double rpm, double hp, double tq) {
|
||||
chartPanel.addData(rpm, hp, tq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRawData(double time, double rpm) {
|
||||
chartPanel.addRawData(time, rpm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData(double rpm, double hp) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSampleCount() {
|
||||
return chartPanel.getSampleCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEcuParams(List<EcuParameter> params) {
|
||||
controlPanel.setEcuParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEcuSwitches(List<EcuSwitch> switches) {
|
||||
controlPanel.setEcuSwitches(switches);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalDatas(List<ExternalData> external) {
|
||||
controlPanel.setExternalDatas(external);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ import java.util.Vector;
|
|||
|
||||
public abstract class Table extends JPanel implements Serializable {
|
||||
private static final long serialVersionUID = 6559256489995552645L;
|
||||
private static final String BLANK = "";
|
||||
protected static final String BLANK = "";
|
||||
|
||||
public static final int ENDIAN_LITTLE = 1;
|
||||
public static final int ENDIAN_BIG = 2;
|
||||
|
@ -74,6 +74,8 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
public static final boolean STORAGE_DATA_SIGNED = false;
|
||||
|
||||
protected static final Color UNCHANGED_VALUE_COLOR = new Color(160, 160, 160);
|
||||
protected static final String NEW_LINE = System.getProperty("line.separator");
|
||||
protected static final String TAB = "\t";
|
||||
|
||||
protected String name;
|
||||
protected int type;
|
||||
|
@ -281,6 +283,13 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
getFrame().getToolBar().multiply();
|
||||
}
|
||||
};
|
||||
Action numNegAction = new AbstractAction() {
|
||||
private static final long serialVersionUID = -6346750245035640773L;
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getFrame().getToolBar().focusSetValue('-');
|
||||
}
|
||||
};
|
||||
|
||||
// set input mapping
|
||||
InputMap im = getInputMap(WHEN_IN_FOCUSED_WINDOW);
|
||||
|
@ -312,6 +321,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
KeyStroke numPoint = KeyStroke.getKeyStroke('.');
|
||||
KeyStroke copy = KeyStroke.getKeyStroke("control C");
|
||||
KeyStroke paste = KeyStroke.getKeyStroke("control V");
|
||||
KeyStroke numNeg = KeyStroke.getKeyStroke('-');
|
||||
|
||||
im.put(right, "right");
|
||||
im.put(left, "left");
|
||||
|
@ -340,6 +350,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
im.put(paste, "pasteAction");
|
||||
im.put(mulKey, "mulAction");
|
||||
im.put(mulKeys, "mulAction");
|
||||
im.put(numNeg, "numNeg");
|
||||
|
||||
getActionMap().put(im.get(right), rightAction);
|
||||
getActionMap().put(im.get(left), leftAction);
|
||||
|
@ -368,6 +379,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
getActionMap().put(im.get(mulKeys), multiplyAction);
|
||||
getActionMap().put(im.get(copy), copyAction);
|
||||
getActionMap().put(im.get(paste), pasteAction);
|
||||
getActionMap().put(im.get(numNeg), numNegAction);
|
||||
|
||||
this.setInputMap(WHEN_FOCUSED, im);
|
||||
}
|
||||
|
@ -966,22 +978,23 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
public StringBuffer getTableAsString() {
|
||||
//make a string of the selection
|
||||
StringBuffer output = new StringBuffer(BLANK);
|
||||
for (int i = 0; i < getDataSize(); i++) {
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
output.append(data[i].getText());
|
||||
if (i < getDataSize() - 1) {
|
||||
output.append("\t");
|
||||
if (i < data.length - 1) {
|
||||
output.append(TAB);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public void copyTable() {
|
||||
String newline = System.getProperty("line.separator");
|
||||
StringBuffer output = new StringBuffer("[Table1D]" + newline);
|
||||
String tableHeader = settings.getTableHeader();
|
||||
|
||||
StringBuffer output = new StringBuffer(tableHeader);
|
||||
for (int i = 0; i < getDataSize(); i++) {
|
||||
output.append(data[i].getText());
|
||||
if (i < getDataSize() - 1) {
|
||||
output.append("\t");
|
||||
output.append(TAB);
|
||||
}
|
||||
}
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(String.valueOf(output)), null);
|
||||
|
@ -1061,24 +1074,24 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
}
|
||||
|
||||
public void applyColorSettings(Settings settings) {
|
||||
if (this.getType() != TABLE_SWITCH) {
|
||||
this.setSettings(settings);
|
||||
|
||||
// apply settings to cells
|
||||
for (int i = 0; i < getDataSize(); i++) {
|
||||
this.setMaxColor(settings.getMaxColor());
|
||||
this.setMinColor(settings.getMinColor());
|
||||
data[i].setHighlightColor(settings.getHighlightColor());
|
||||
data[i].setIncreaseBorder(settings.getIncreaseBorder());
|
||||
data[i].setDecreaseBorder(settings.getDecreaseBorder());
|
||||
data[i].setFont(settings.getTableFont());
|
||||
data[i].repaint();
|
||||
}
|
||||
cellHeight = (int) settings.getCellSize().getHeight();
|
||||
cellWidth = (int) settings.getCellSize().getWidth();
|
||||
colorize();
|
||||
validateScaling();
|
||||
}
|
||||
if (this.getType() != TABLE_SWITCH) {
|
||||
this.setSettings(settings);
|
||||
|
||||
// apply settings to cells
|
||||
for (int i = 0; i < getDataSize(); i++) {
|
||||
this.setMaxColor(settings.getMaxColor());
|
||||
this.setMinColor(settings.getMinColor());
|
||||
data[i].setHighlightColor(settings.getHighlightColor());
|
||||
data[i].setIncreaseBorder(settings.getIncreaseBorder());
|
||||
data[i].setDecreaseBorder(settings.getDecreaseBorder());
|
||||
data[i].setFont(settings.getTableFont());
|
||||
data[i].repaint();
|
||||
}
|
||||
cellHeight = (int) settings.getCellSize().getHeight();
|
||||
cellWidth = (int) settings.getCellSize().getWidth();
|
||||
colorize();
|
||||
validateScaling();
|
||||
}
|
||||
}
|
||||
|
||||
public void resize() {
|
||||
|
@ -1135,7 +1148,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
getSettings().setCalcConflictWarning(((JCheckBox) e.getSource()).isSelected());
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
JOptionPane.showMessageDialog(container.getContainer(), panel,
|
||||
"Warning", JOptionPane.ERROR_MESSAGE);
|
||||
|
|
|
@ -152,7 +152,7 @@ public class Table1D extends Table {
|
|||
for (int i = 0; i < getDataSize(); i++) {
|
||||
output.append(data[i].getText());
|
||||
if (i < getDataSize() - 1) {
|
||||
output.append("\t");
|
||||
output.append(TAB);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
|
|
|
@ -216,8 +216,10 @@ public class Table2D extends Table {
|
|||
}
|
||||
|
||||
public void copyTable() {
|
||||
String tableHeader = settings.getTable2DHeader();
|
||||
|
||||
// create string
|
||||
StringBuffer output = new StringBuffer("[Table2D]" + NEW_LINE);
|
||||
StringBuffer output = new StringBuffer(tableHeader);
|
||||
output.append(axis.getTableAsString()).append(NEW_LINE);
|
||||
output.append(super.getTableAsString());
|
||||
//copy to clipboard
|
||||
|
|
|
@ -212,6 +212,26 @@ public class Table3D extends Table {
|
|||
add(new JLabel(getScale().getUnit(), JLabel.CENTER), BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
public StringBuffer getTableAsString() {
|
||||
// Make a string of the table
|
||||
StringBuffer output = new StringBuffer(BLANK);
|
||||
output.append(xAxis.getTableAsString()).append(NEW_LINE);
|
||||
|
||||
for (int y = 0; y < getSizeY(); y++) {
|
||||
output.append(yAxis.getCellAsString(y)).append(TAB);
|
||||
for (int x = 0; x < getSizeX(); x++) {
|
||||
output.append(data[x][y].getText());
|
||||
if (x < getSizeX() - 1) {
|
||||
output.append(TAB);
|
||||
}
|
||||
}
|
||||
if (y < getSizeY() - 1) {
|
||||
output.append(NEW_LINE);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public void colorize() {
|
||||
if (compareType == COMPARE_OFF) {
|
||||
if (!isStatic && !isAxis) {
|
||||
|
@ -691,20 +711,21 @@ public class Table3D extends Table {
|
|||
|
||||
public void copyTable() {
|
||||
// create string
|
||||
String newline = System.getProperty("line.separator");
|
||||
StringBuffer output = new StringBuffer("[Table3D]" + newline);
|
||||
output.append(xAxis.getTableAsString()).append(newline);
|
||||
String tableHeader = settings.getTable3DHeader();
|
||||
|
||||
StringBuffer output = new StringBuffer(tableHeader);
|
||||
output.append(xAxis.getTableAsString()).append(NEW_LINE);
|
||||
|
||||
for (int y = 0; y < getSizeY(); y++) {
|
||||
output.append(yAxis.getCellAsString(y)).append("\t");
|
||||
output.append(yAxis.getCellAsString(y)).append(TAB);
|
||||
for (int x = 0; x < getSizeX(); x++) {
|
||||
output.append(data[x][y].getText());
|
||||
if (x < getSizeX() - 1) {
|
||||
output.append("\t");
|
||||
output.append(TAB);
|
||||
}
|
||||
}
|
||||
if (y < getSizeY() - 1) {
|
||||
output.append(newline);
|
||||
output.append(NEW_LINE);
|
||||
}
|
||||
}
|
||||
//copy to clipboard
|
||||
|
|
|
@ -0,0 +1,369 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 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.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class CompareImagesForm extends JFrame implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -8937472127815934398L;
|
||||
private Vector<Rom> roms;
|
||||
private JPanel contentPane;
|
||||
private JComboBox comboBoxImageLeft;
|
||||
private JComboBox comboBoxImageRight;
|
||||
private JButton btnCompare;
|
||||
private JList listChanges;
|
||||
private DefaultListModel listModelChanges = new DefaultListModel();
|
||||
private ChangeListCellRenderer changeRenderer = new ChangeListCellRenderer();
|
||||
private JScrollPane scrollPaneResults;
|
||||
private JLabel lblImageResultString;
|
||||
public static Color equal = new Color(52,114,53);
|
||||
public static Color different = new Color(193, 27, 23);
|
||||
public static Color missing = new Color(251,185,23);
|
||||
|
||||
public CompareImagesForm(Vector<Rom> roms) {
|
||||
setResizable(false);
|
||||
this.roms = roms;
|
||||
|
||||
setTitle("Compare Images");
|
||||
|
||||
setBounds(100, 100, 600, 450);
|
||||
this.contentPane = new JPanel();
|
||||
this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(this.contentPane);
|
||||
|
||||
JLabel lblSelectImages = new JLabel("Selected Images");
|
||||
lblSelectImages.setBounds(10, 11, 79, 14);
|
||||
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JPanel panelImageSelector = new JPanel();
|
||||
panelImageSelector.setBounds(10, 36, 574, 94);
|
||||
panelImageSelector.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
|
||||
panelImageSelector.setLayout(null);
|
||||
|
||||
JLabel lblImageLeft = new JLabel("Image (Left):");
|
||||
lblImageLeft.setBounds(10, 10, 70, 14);
|
||||
panelImageSelector.add(lblImageLeft);
|
||||
|
||||
this.comboBoxImageLeft = new JComboBox();
|
||||
this.comboBoxImageLeft.setBounds(89, 7, 475, 20);
|
||||
this.comboBoxImageLeft.setToolTipText("Select an image to compare.");
|
||||
this.comboBoxImageLeft.setRenderer( new ComboBoxRenderer() );
|
||||
panelImageSelector.add(this.comboBoxImageLeft);
|
||||
|
||||
JLabel lblImageRight = new JLabel("Image (Right):");
|
||||
lblImageRight.setBounds(10, 35, 70, 14);
|
||||
panelImageSelector.add(lblImageRight);
|
||||
|
||||
this.comboBoxImageRight = new JComboBox();
|
||||
this.comboBoxImageRight.setBounds(89, 32, 475, 20);
|
||||
this.comboBoxImageRight.setToolTipText("Select an image to compare.");
|
||||
this.comboBoxImageRight.setRenderer( new ComboBoxRenderer() );
|
||||
panelImageSelector.add(this.comboBoxImageRight);
|
||||
|
||||
this.btnCompare = new JButton("Compare");
|
||||
this.btnCompare.addActionListener(this);
|
||||
this.btnCompare.setBounds(10, 64, 89, 23);
|
||||
panelImageSelector.add(this.btnCompare);
|
||||
this.contentPane.add(panelImageSelector);
|
||||
this.contentPane.add(lblSelectImages);
|
||||
|
||||
JLabel lblResults = new JLabel("Results:");
|
||||
lblResults.setBounds(10, 141, 46, 14);
|
||||
contentPane.add(lblResults);
|
||||
|
||||
lblImageResultString = new JLabel("Compare images...");
|
||||
lblImageResultString.setBounds(66, 141, 518, 14);
|
||||
contentPane.add(lblImageResultString);
|
||||
scrollPaneResults = new JScrollPane();
|
||||
scrollPaneResults.setBounds(10, 166, 574, 245);
|
||||
contentPane.add(scrollPaneResults);
|
||||
|
||||
this.listChanges = new JList(this.listModelChanges);
|
||||
scrollPaneResults.setViewportView(this.listChanges);
|
||||
listChanges.setCellRenderer(changeRenderer);
|
||||
listChanges.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
|
||||
populateComboBoxes();
|
||||
}
|
||||
|
||||
public void populateComboBoxes()
|
||||
{
|
||||
for(int i=0; i<roms.size(); i++) {
|
||||
Rom curRom = roms.get(i);
|
||||
comboBoxImageLeft.addItem(curRom);
|
||||
comboBoxImageRight.addItem(curRom);
|
||||
}
|
||||
if(comboBoxImageRight.getItemCount() > 1) {
|
||||
comboBoxImageRight.setSelectedIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void compareTables(Rom left, Rom right)
|
||||
{
|
||||
listModelChanges.clear();
|
||||
|
||||
Vector<Table> leftTables = left.getTables();
|
||||
Vector<Table> rightTables = right.getTables();
|
||||
|
||||
int equal = 0;
|
||||
int different = 0;
|
||||
int missing = 0;
|
||||
|
||||
String leftTableName;
|
||||
String rightTableName;
|
||||
String leftTableAsString;
|
||||
String rightTableAsString;
|
||||
Boolean found = false;
|
||||
|
||||
// Compare the tables.
|
||||
for(int x=0;x<leftTables.size();x++) {
|
||||
found = false;
|
||||
leftTableName = leftTables.get(x).getName().trim().toLowerCase();
|
||||
for(int y=0;y<rightTables.size();y++) {
|
||||
rightTableName = rightTables.get(y).getName().trim().toLowerCase();
|
||||
if(leftTableName.equals(rightTableName)) {
|
||||
// Same table. Compare table as string
|
||||
found = true;
|
||||
leftTableAsString = leftTables.get(x).getTableAsString().toString().trim().toLowerCase();
|
||||
rightTableAsString = rightTables.get(y).getTableAsString().toString().trim().toLowerCase();
|
||||
if(leftTableAsString.equals(rightTableAsString)) {
|
||||
// Tables are equal
|
||||
equal++;
|
||||
listModelChanges.addElement(new ListItem(1, leftTables.get(x).getName()));
|
||||
} else {
|
||||
// Tables are different
|
||||
different++;
|
||||
listModelChanges.addElement(new ListItem(2, leftTables.get(x).getName()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
missing++;
|
||||
listModelChanges.addElement(new ListItem(3, leftTables.get(x).getName()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if rightTables has tables that do not exist in left table.
|
||||
for(int x=0;x<rightTables.size();x++) {
|
||||
found = false;
|
||||
rightTableName = rightTables.get(x).getName().trim().toLowerCase();
|
||||
for(int y=0;y<leftTables.size();y++) {
|
||||
leftTableName = leftTables.get(y).getName().trim().toLowerCase();
|
||||
if(rightTableName.equals(leftTableName))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
missing++;
|
||||
listModelChanges.addElement(new ListItem(3, rightTables.get(x).getName()));
|
||||
}
|
||||
}
|
||||
|
||||
// Fill out the result string.
|
||||
if(equal > 0 && different == 0 && missing == 0) {
|
||||
lblImageResultString.setText("Images are equal.");
|
||||
lblImageResultString.setForeground(CompareImagesForm.equal);
|
||||
} else if(different > 0) {
|
||||
lblImageResultString.setText("Images are NOT equal. Equal Tables: "+equal+", Changed Tables: "+different+", Missing Tables: "+missing);
|
||||
lblImageResultString.setForeground(CompareImagesForm.different);
|
||||
} else {
|
||||
lblImageResultString.setText("Images are NOT equal. Equal Tables: "+equal+", Changed Tables: "+different+", Missing Tables: "+missing);
|
||||
lblImageResultString.setForeground(CompareImagesForm.missing);
|
||||
}
|
||||
|
||||
// Check if the list has items.
|
||||
if(listModelChanges.size() < 1)
|
||||
{
|
||||
listModelChanges.addElement(new ListItem(0, "No tables are equal, different, or missing."));
|
||||
lblImageResultString.setText("Unable to compare images.");
|
||||
lblImageResultString.setForeground(Color.RED);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add list items for 0 counts.
|
||||
if(equal == 0)
|
||||
{
|
||||
listModelChanges.addElement(new ListItem(1, "No Equal Tables."));
|
||||
}
|
||||
|
||||
if(different == 0)
|
||||
{
|
||||
listModelChanges.addElement(new ListItem(2, "No Changed Tables."));
|
||||
}
|
||||
|
||||
if(missing == 0)
|
||||
{
|
||||
listModelChanges.addElement(new ListItem(3, "No Missing Tables."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
if (e.getSource() == this.btnCompare) {
|
||||
if(this.comboBoxImageLeft.getItemCount() > 0 && this.comboBoxImageRight.getItemCount() > 0)
|
||||
{
|
||||
Rom leftRom = (Rom)this.comboBoxImageLeft.getSelectedItem();
|
||||
Rom rightRom = (Rom)this.comboBoxImageRight.getSelectedItem();
|
||||
if(leftRom != null && rightRom != null)
|
||||
{
|
||||
compareTables(leftRom, rightRom);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
class ComboBoxRenderer extends JLabel implements ListCellRenderer
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 831689602429105854L;
|
||||
|
||||
public ComboBoxRenderer() {
|
||||
setOpaque(true);
|
||||
setHorizontalAlignment(LEFT);
|
||||
setVerticalAlignment(CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
if(isSelected) {
|
||||
setBackground(list.getSelectionBackground());
|
||||
setForeground(list.getSelectionForeground());
|
||||
} else {
|
||||
setBackground(list.getBackground());
|
||||
setForeground(list.getForeground());
|
||||
}
|
||||
|
||||
if(value != null)
|
||||
{
|
||||
// Set the text to the rom file name.
|
||||
Rom rom = (Rom)value;
|
||||
setText(rom.getFileName());
|
||||
setFont(list.getFont());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeListCellRenderer extends JLabel implements ListCellRenderer {
|
||||
|
||||
private static final long serialVersionUID = -3645192077787635239L;
|
||||
|
||||
public ChangeListCellRenderer()
|
||||
{
|
||||
setOpaque(true);
|
||||
setHorizontalAlignment(LEFT);
|
||||
setVerticalAlignment(CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList paramList, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
// Set the background color.
|
||||
if(isSelected) {
|
||||
setBackground(paramList.getSelectionBackground());
|
||||
} else {
|
||||
setBackground(paramList.getBackground());
|
||||
}
|
||||
|
||||
// Set the foreground color based on the item type.
|
||||
ListItem item = (ListItem)value;
|
||||
switch(item.getType()) {
|
||||
case 1:
|
||||
// equal - default green
|
||||
setForeground(CompareImagesForm.equal);
|
||||
break;
|
||||
case 2:
|
||||
// different - default red
|
||||
setForeground(CompareImagesForm.different);
|
||||
break;
|
||||
case 3:
|
||||
// missing - default yellow
|
||||
setForeground(CompareImagesForm.missing);
|
||||
break;
|
||||
default:
|
||||
setForeground(paramList.getForeground());
|
||||
break;
|
||||
}
|
||||
setText(item.getValue());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class ListItem {
|
||||
|
||||
private int type;
|
||||
private String value;
|
||||
|
||||
public ListItem(int type, String value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -19,23 +19,27 @@
|
|||
|
||||
package com.romraider.swing;
|
||||
|
||||
import com.centerkey.utils.BareBonesBrowserLaunch;
|
||||
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;
|
||||
import static javax.swing.JFrame.DISPOSE_ON_CLOSE;
|
||||
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 java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenu;
|
||||
|
@ -43,50 +47,56 @@ import javax.swing.JMenuBar;
|
|||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.JSeparator;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import com.centerkey.utils.BareBonesBrowserLaunch;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
import com.romraider.ramtune.test.RamTuneTestApp;
|
||||
|
||||
public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -4777040428837855236L;
|
||||
private JMenu fileMenu = new JMenu("File");
|
||||
private JMenuItem openImage = new JMenuItem("Open Image...");
|
||||
private JMenuItem saveImage = new JMenuItem("Save Image As...");
|
||||
private JMenuItem refreshImage = new JMenuItem("Refresh Image");
|
||||
private JMenuItem closeImage = new JMenuItem("Close Image");
|
||||
private JMenuItem closeAll = new JMenuItem("Close All Images");
|
||||
private JMenuItem exit = new JMenuItem("Exit");
|
||||
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 JMenu definitionMenu = new JMenu("ECU Definitions");
|
||||
private JMenuItem defManager = new JMenuItem("ECU Definition Manager...");
|
||||
private final JMenu definitionMenu = new JMenu("ECU Definitions");
|
||||
private final JMenuItem defManager = new JMenuItem("ECU Definition Manager...");
|
||||
// private JMenuItem editDefinition = new JMenuItem("Edit ECU Definitions...");
|
||||
private JMenuItem updateDefinition = new JMenuItem("Get ECU Definitions...");
|
||||
private final JMenuItem updateDefinition = new JMenuItem("Get ECU Definitions...");
|
||||
|
||||
private JMenu editMenu = new JMenu("Edit");
|
||||
private JMenuItem settings = new JMenuItem(PRODUCT_NAME + " Settings...");
|
||||
private final JMenu editMenu = new JMenu("Edit");
|
||||
private final JMenuItem settings = new JMenuItem(PRODUCT_NAME + " Settings...");
|
||||
private final JMenuItem compareImages = new JMenuItem("Compare Images...");
|
||||
|
||||
private JMenu viewMenu = new JMenu("View");
|
||||
private JMenuItem romProperties = new JMenuItem("ECU Image Properties");
|
||||
private ButtonGroup levelGroup = new ButtonGroup();
|
||||
private JMenu levelMenu = new JMenu("User Level");
|
||||
private JRadioButtonMenuItem level1 = new JRadioButtonMenuItem("1 Beginner");
|
||||
private JRadioButtonMenuItem level2 = new JRadioButtonMenuItem("2 Intermediate");
|
||||
private JRadioButtonMenuItem level3 = new JRadioButtonMenuItem("3 Advanced");
|
||||
private JRadioButtonMenuItem level4 = new JRadioButtonMenuItem("4 Highest");
|
||||
private JRadioButtonMenuItem level5 = new JRadioButtonMenuItem("5 Debug Mode");
|
||||
private final JMenu viewMenu = new JMenu("View");
|
||||
private final JMenuItem romProperties = new JMenuItem("ECU Image Properties");
|
||||
private final ButtonGroup levelGroup = new ButtonGroup();
|
||||
private final JMenu levelMenu = new JMenu("User Level");
|
||||
private final JRadioButtonMenuItem level1 = new JRadioButtonMenuItem("1 Beginner");
|
||||
private final JRadioButtonMenuItem level2 = new JRadioButtonMenuItem("2 Intermediate");
|
||||
private final JRadioButtonMenuItem level3 = new JRadioButtonMenuItem("3 Advanced");
|
||||
private final JRadioButtonMenuItem level4 = new JRadioButtonMenuItem("4 Highest");
|
||||
private final JRadioButtonMenuItem level5 = new JRadioButtonMenuItem("5 Debug Mode");
|
||||
|
||||
private JMenu loggerMenu = new JMenu("Logger");
|
||||
private JMenuItem openLogger = new JMenuItem("Launch Logger...");
|
||||
private final JMenu loggerMenu = new JMenu("Logger");
|
||||
private final JMenuItem openLogger = new JMenuItem("Launch Logger...");
|
||||
|
||||
private JMenu ramTuneMenu = new JMenu("SSM");
|
||||
private JMenuItem launchRamTuneTestApp = new JMenuItem("Launch Test App...");
|
||||
private final JMenu ramTuneMenu = new JMenu("SSM");
|
||||
private final JMenuItem launchRamTuneTestApp = new JMenuItem("Launch Test App...");
|
||||
|
||||
private JMenu helpMenu = new JMenu("Help");
|
||||
private JMenuItem about = new JMenuItem("About " + PRODUCT_NAME);
|
||||
private final JMenu helpMenu = new JMenu("Help");
|
||||
private final JMenuItem about = new JMenuItem("About " + PRODUCT_NAME);
|
||||
|
||||
private ECUEditor parent;
|
||||
private final ECUEditor parent;
|
||||
|
||||
public ECUEditorMenuBar(ECUEditor parent) {
|
||||
this.parent = parent;
|
||||
|
@ -95,13 +105,17 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
add(fileMenu);
|
||||
fileMenu.setMnemonic('F');
|
||||
openImage.setMnemonic('O');
|
||||
openImage.setMnemonic('I');
|
||||
saveImage.setMnemonic('S');
|
||||
saveAsRepository.setMnemonic('D');
|
||||
refreshImage.setMnemonic('R');
|
||||
closeImage.setMnemonic('C');
|
||||
closeAll.setMnemonic('A');
|
||||
exit.setMnemonic('X');
|
||||
fileMenu.add(openImage);
|
||||
fileMenu.add(openImages);
|
||||
fileMenu.add(saveImage);
|
||||
fileMenu.add(saveAsRepository);
|
||||
fileMenu.add(refreshImage);
|
||||
fileMenu.add(new JSeparator());
|
||||
fileMenu.add(closeImage);
|
||||
|
@ -109,7 +123,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
fileMenu.add(new JSeparator());
|
||||
fileMenu.add(exit);
|
||||
openImage.addActionListener(this);
|
||||
openImages.addActionListener(this);
|
||||
saveImage.addActionListener(this);
|
||||
saveAsRepository.addActionListener(this);
|
||||
refreshImage.addActionListener(this);
|
||||
closeImage.addActionListener(this);
|
||||
closeAll.addActionListener(this);
|
||||
|
@ -120,19 +136,22 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
editMenu.setMnemonic('E');
|
||||
editMenu.add(settings);
|
||||
settings.addActionListener(this);
|
||||
editMenu.add(compareImages);
|
||||
compareImages.addActionListener(this);
|
||||
|
||||
// ecu def menu items
|
||||
add(definitionMenu);
|
||||
definitionMenu.setMnemonic('D');
|
||||
defManager.setMnemonic('D');
|
||||
// editDefinition.setMnemonic('E');
|
||||
// editDefinition.setMnemonic('E');
|
||||
updateDefinition.setMnemonic('U');
|
||||
settings.setMnemonic('S');
|
||||
compareImages.setMnemonic('C');
|
||||
definitionMenu.add(defManager);
|
||||
// definitionMenu.add(editDefinition);
|
||||
// definitionMenu.add(editDefinition);
|
||||
definitionMenu.add(updateDefinition);
|
||||
defManager.addActionListener(this);
|
||||
// editDefinition.addActionListener(this);
|
||||
// editDefinition.addActionListener(this);
|
||||
updateDefinition.addActionListener(this);
|
||||
|
||||
// view menu items
|
||||
|
@ -198,7 +217,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
about.addActionListener(this);
|
||||
|
||||
// disable unused buttons! 0.3.1
|
||||
// editDefinition.setEnabled(false);
|
||||
// editDefinition.setEnabled(false);
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
@ -206,22 +225,29 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
String file = getLastSelectedRomFileName();
|
||||
if ("".equals(file)) {
|
||||
saveImage.setEnabled(false);
|
||||
saveAsRepository.setEnabled(false);
|
||||
closeImage.setEnabled(false);
|
||||
closeAll.setEnabled(false);
|
||||
romProperties.setEnabled(false);
|
||||
saveImage.setText("Save As...");
|
||||
saveAsRepository.setText("Save As Repository...");
|
||||
compareImages.setEnabled(false);
|
||||
} else {
|
||||
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...");
|
||||
compareImages.setEnabled(true);
|
||||
}
|
||||
refreshImage.setText("Refresh " + file);
|
||||
closeImage.setText("Close " + file);
|
||||
romProperties.setText(file + "Properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == openImage) {
|
||||
try {
|
||||
|
@ -231,6 +257,14 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == openImages) {
|
||||
try {
|
||||
openImagesDialog();
|
||||
} catch (Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == saveImage) {
|
||||
try {
|
||||
this.saveImage(parent.getLastSelectedRom());
|
||||
|
@ -238,7 +272,13 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
} else if (e.getSource() == saveAsRepository) {
|
||||
try {
|
||||
this.saveAsRepository(parent.getLastSelectedRom(), parent.getSettings().getLastRepositoryDir());
|
||||
} catch(Exception ex) {
|
||||
showMessageDialog(parent,
|
||||
new DebugPanel(ex, parent.getSettings().getSupportURL()), "Exception", ERROR_MESSAGE);
|
||||
}
|
||||
} else if (e.getSource() == closeImage) {
|
||||
this.closeImage();
|
||||
|
||||
|
@ -267,6 +307,11 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
form.setLocationRelativeTo(parent);
|
||||
form.setVisible(true);
|
||||
|
||||
} else if (e.getSource() == compareImages){
|
||||
CompareImagesForm form = new CompareImagesForm(parent.getImages());
|
||||
form.setLocationRelativeTo(parent);
|
||||
form.setVisible(true);
|
||||
|
||||
} else if (e.getSource() == defManager) {
|
||||
DefinitionManager form = new DefinitionManager(parent);
|
||||
form.setLocationRelativeTo(parent);
|
||||
|
@ -288,9 +333,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
parent.setUserLevel(5);
|
||||
|
||||
} else if (e.getSource() == openLogger) {
|
||||
parent.statusPanel.update("Launching Logger...", 10);
|
||||
parent.statusPanel.update("Launching Logger...", 10);
|
||||
EcuLogger.startLogger(DISPOSE_ON_CLOSE, parent);
|
||||
parent.statusPanel.update("Ready...", 0);
|
||||
parent.statusPanel.update("Ready...", 0);
|
||||
|
||||
} else if (e.getSource() == updateDefinition) {
|
||||
BareBonesBrowserLaunch.openURL(ECU_DEFS_URL);
|
||||
|
@ -320,12 +365,26 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
public void openImageDialog() throws Exception {
|
||||
JFileChooser fc = new JFileChooser(parent.getSettings().getLastImageDir());
|
||||
fc.setFileFilter(new ECUImageFilter());
|
||||
fc.setDialogTitle("Open Image");
|
||||
|
||||
if (fc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
parent.openImage(fc.getSelectedFile());
|
||||
parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
public void openImagesDialog() throws Exception {
|
||||
JFileChooser fc = new JFileChooser(parent.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());
|
||||
parent.getSettings().setLastImageDir(fc.getCurrentDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
public void closeImage() {
|
||||
parent.closeImage();
|
||||
}
|
||||
|
@ -342,7 +401,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
boolean save = true;
|
||||
File selectedFile = fc.getSelectedFile();
|
||||
if (selectedFile.exists()) {
|
||||
if (showConfirmDialog(parent, selectedFile.getName() + " already exists! Overwrite?") == CANCEL_OPTION) {
|
||||
int option = showConfirmDialog(parent, selectedFile.getName() + " already exists! Overwrite?");
|
||||
|
||||
// option: 0 = Cancel, 1 = No
|
||||
if (option == CANCEL_OPTION || option == 1) {
|
||||
save = false;
|
||||
}
|
||||
}
|
||||
|
@ -362,6 +424,54 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void saveAsRepository(Rom image, File lastRepositoryDir) throws Exception {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(lastRepositoryDir);
|
||||
fc.setDialogTitle("Select Repository Directory");
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
// disable the "All files" option
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
String separator = System.getProperty("file.separator");
|
||||
|
||||
if (fc.showSaveDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||
boolean save = true;
|
||||
File selectedDir = fc.getSelectedFile();
|
||||
if (selectedDir.exists()) {
|
||||
int option = showConfirmDialog(parent, selectedDir.getName() + " already exists! Overwrite?");
|
||||
|
||||
// option: 0 = Cancel, 1 = No
|
||||
if (option == CANCEL_OPTION || option == 1) {
|
||||
save = false;
|
||||
}
|
||||
}
|
||||
if(save) {
|
||||
Vector<Table> romTables = image.getTables();
|
||||
for(int i=0;i<romTables.size();i++) {
|
||||
Table curTable = romTables.get(i);
|
||||
String category = curTable.getCategory();
|
||||
String tableName = curTable.getName();
|
||||
String tableDirString = selectedDir.getAbsolutePath() + separator + category;
|
||||
File tableDir = new File(tableDirString.replace('/', '-'));
|
||||
tableDir.mkdirs();
|
||||
String tableFileString = tableDir.getAbsolutePath() + separator + tableName+".txt";
|
||||
File tableFile = new File(tableFileString.replace('/', '-'));
|
||||
if(tableFile.exists())
|
||||
{
|
||||
tableFile.delete();
|
||||
}
|
||||
tableFile.createNewFile();
|
||||
StringBuffer tableData = curTable.getTableAsString();
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(tableFile));
|
||||
try {
|
||||
out.write(tableData.toString());
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getLastSelectedRomFileName() {
|
||||
Rom lastSelectedRom = parent.getLastSelectedRom();
|
||||
return lastSelectedRom == null ? "" : lastSelectedRom.getFileName() + " ";
|
||||
|
|
|
@ -34,6 +34,12 @@ import java.awt.event.MouseListener;
|
|||
import java.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||
|
||||
public class SettingsForm extends JFrame implements MouseListener {
|
||||
|
||||
private static final long serialVersionUID = 3910602424260147767L;
|
||||
|
@ -104,6 +110,14 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
|
||||
valueLimitWarning.setSelected(settings.isValueLimitWarning());
|
||||
warningColor.setBackground(settings.getWarningColor());
|
||||
|
||||
if(settings.getTableClipboardFormat().equalsIgnoreCase(Settings.AIRBOYS_CLIPBOARD_FORMAT)) {
|
||||
this.rdbtnAirboys.setSelected(true);
|
||||
} else if(settings.getTableClipboardFormat().equalsIgnoreCase(Settings.CUSTOM_CLIPBOARD_FORMAT)) {
|
||||
this.rdbtnCustom.setSelected(true);
|
||||
} else {
|
||||
this.rdbtnDefault.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
|
||||
|
@ -115,7 +129,10 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
btnOk = new javax.swing.JButton();
|
||||
btnApply = new javax.swing.JButton();
|
||||
reset = new javax.swing.JButton();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
settingsTabbedPane = new javax.swing.JTabbedPane();
|
||||
jPanelClipboard = new javax.swing.JPanel();
|
||||
jPanelDefault = new javax.swing.JPanel();
|
||||
jPanelTableDisplay = new javax.swing.JPanel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
lblAxis = new javax.swing.JLabel();
|
||||
lblHighlight = new javax.swing.JLabel();
|
||||
|
@ -149,6 +166,14 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
jLabel1 = new javax.swing.JLabel();
|
||||
tableClickCount = new javax.swing.JComboBox();
|
||||
|
||||
clipboardButtonGroup = new ButtonGroup();
|
||||
rdbtnDefault = new JRadioButton("RomRaider Default");
|
||||
rdbtnAirboys = new JRadioButton("Airboys Spreadsheet");
|
||||
rdbtnCustom = new JRadioButton("Custom (manually specify formats in settings.xml)");
|
||||
clipboardButtonGroup.add(this.rdbtnDefault);
|
||||
clipboardButtonGroup.add(this.rdbtnAirboys);
|
||||
clipboardButtonGroup.add(this.rdbtnCustom);
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(PRODUCT_NAME + " Settings");
|
||||
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
|
@ -177,7 +202,6 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
|
||||
reset.setText("Restore Defaults");
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Table Display"));
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Background"));
|
||||
lblAxis.setText("Axis Cell:");
|
||||
|
||||
|
@ -213,50 +237,50 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
jPanel2.setLayout(jPanel2Layout);
|
||||
jPanel2Layout.setHorizontalGroup(
|
||||
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
|
||||
.add(lblWarning)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(4, 4, 4)
|
||||
.add(lblMin))
|
||||
.add(lblMax)))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(maxColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE)
|
||||
.add(lblHighlight)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(highlightColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(minColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 55, Short.MAX_VALUE)
|
||||
.add(lblAxis)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(axisColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.add(warningColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(4, 4, 4)
|
||||
.add(lblMin))
|
||||
.add(lblMax)))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(maxColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE)
|
||||
.add(lblHighlight)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(highlightColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(minColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 55, Short.MAX_VALUE)
|
||||
.add(lblAxis)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(axisColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.add(warningColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(jPanel2Layout.createSequentialGroup()
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(lblMax)
|
||||
.add(maxColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(highlightColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblHighlight))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(lblMin)
|
||||
.add(minColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(axisColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblAxis))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(warningColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblWarning)))
|
||||
);
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(lblMin)
|
||||
.add(minColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(axisColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblAxis))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(warningColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblWarning)))
|
||||
);
|
||||
|
||||
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Cell Borders"));
|
||||
lblIncrease.setText("Increased:");
|
||||
|
@ -275,7 +299,7 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
jPanel3.setLayout(jPanel3Layout);
|
||||
jPanel3Layout.setHorizontalGroup(
|
||||
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(lblIncrease)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
|
@ -285,15 +309,15 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(decreaseColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(decreaseColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblDecrease)
|
||||
.add(lblIncrease)
|
||||
.add(increaseColor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
);
|
||||
|
||||
lblCellHeight.setText("Cell Height:");
|
||||
|
||||
|
@ -332,139 +356,205 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
jPanel4.setLayout(jPanel4Layout);
|
||||
jPanel4Layout.setHorizontalGroup(
|
||||
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(extensionBin)
|
||||
.add(extensionHex))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 93, Short.MAX_VALUE)
|
||||
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
|
||||
.add(btnAddAssocs, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(btnRemoveAssocs))
|
||||
.add(25, 25, 25))
|
||||
);
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 93, Short.MAX_VALUE)
|
||||
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
|
||||
.add(btnAddAssocs, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(btnRemoveAssocs))
|
||||
.add(25, 25, 25))
|
||||
);
|
||||
jPanel4Layout.setVerticalGroup(
|
||||
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel4Layout.createSequentialGroup()
|
||||
.add(jPanel4Layout.createSequentialGroup()
|
||||
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(btnAddAssocs)
|
||||
.add(extensionHex))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(btnRemoveAssocs)
|
||||
.add(extensionBin)))
|
||||
);
|
||||
|
||||
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
|
||||
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(saveDebugTables)
|
||||
.add(displayHighTables)
|
||||
.add(valueLimitWarning))
|
||||
.add(jPanel1Layout.createSequentialGroup()
|
||||
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(lblCellHeight)
|
||||
.add(lblFont))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(btnChooseFont)
|
||||
.add(jPanel1Layout.createSequentialGroup()
|
||||
.add(cellHeight, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 42, Short.MAX_VALUE)
|
||||
.add(lblCellWidth)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(cellWidth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
|
||||
.add(47, 47, 47))
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(jPanel1Layout.createSequentialGroup()
|
||||
.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(22, 22, 22)
|
||||
.add(saveDebugTables)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(displayHighTables)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(valueLimitWarning)
|
||||
.add(27, 27, 27)
|
||||
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(lblCellWidth)
|
||||
.add(cellWidth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(lblCellHeight)
|
||||
.add(cellHeight, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(lblFont)
|
||||
.add(btnChooseFont, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
|
||||
);
|
||||
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(btnRemoveAssocs)
|
||||
.add(extensionBin)))
|
||||
);
|
||||
|
||||
jLabel1.setText("click to open tables");
|
||||
|
||||
tableClickCount.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Single", "Double"}));
|
||||
|
||||
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
initTabs();
|
||||
|
||||
settingsTabbedPane.addTab("General", jPanelDefault);
|
||||
settingsTabbedPane.addTab("Table Display", jPanelTableDisplay);
|
||||
settingsTabbedPane.addTab("Clipboard", jPanelClipboard);
|
||||
|
||||
// Content Pane Layout
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
|
||||
layout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, calcConflictWarning)
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, obsoleteWarning)
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
|
||||
.add(tableClickCount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(jLabel1))
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, debug)
|
||||
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
|
||||
.add(reset)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 34, Short.MAX_VALUE)
|
||||
.add(btnApply)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(btnOk)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(btnCancel)))
|
||||
.addContainerGap())
|
||||
);
|
||||
.addGroup(layout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(settingsTabbedPane, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 432, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(reset)
|
||||
.addPreferredGap(ComponentPlacement.RELATED, 136, Short.MAX_VALUE)
|
||||
.addComponent(btnApply)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(btnOk)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
|
||||
.add(layout.createSequentialGroup()
|
||||
layout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(jLabel1)
|
||||
.add(tableClickCount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(obsoleteWarning)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(calcConflictWarning)
|
||||
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
|
||||
.add(debug)
|
||||
.add(17, 17, 17)
|
||||
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
|
||||
.add(22, 22, 22)
|
||||
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
|
||||
.add(btnCancel)
|
||||
.add(btnApply)
|
||||
.add(reset)
|
||||
.add(btnOk))
|
||||
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
.addComponent(settingsTabbedPane, GroupLayout.PREFERRED_SIZE, 542, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
|
||||
.addComponent(btnCancel)
|
||||
.addComponent(btnOk)
|
||||
.addComponent(btnApply)
|
||||
.addComponent(reset))
|
||||
.addContainerGap())
|
||||
);
|
||||
getContentPane().setLayout(layout);
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void initTabs() {
|
||||
// Init Default Tab Panel
|
||||
GroupLayout jPanelDefaultLayout = new GroupLayout(jPanelDefault);
|
||||
jPanelDefaultLayout.setVerticalGroup(
|
||||
jPanelDefaultLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(jPanelDefaultLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanelDefaultLayout.createParallelGroup(Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(tableClickCount, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(obsoleteWarning)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(calcConflictWarning)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(debug)
|
||||
.addGap(17)
|
||||
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
jPanelDefaultLayout.setHorizontalGroup(
|
||||
jPanelDefaultLayout.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(Alignment.LEADING, jPanelDefaultLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanelDefaultLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(jPanelDefaultLayout.createSequentialGroup()
|
||||
.addGroup(jPanelDefaultLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(calcConflictWarning)
|
||||
.addComponent(obsoleteWarning)
|
||||
.addGroup(jPanelDefaultLayout.createSequentialGroup()
|
||||
.addComponent(tableClickCount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1))
|
||||
.addComponent(debug))
|
||||
.addContainerGap(45, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanelDefault.setLayout(jPanelDefaultLayout);
|
||||
|
||||
// Init Table Display Tab
|
||||
GroupLayout jPanelTableDisplayLayout = new GroupLayout(jPanelTableDisplay);
|
||||
jPanelTableDisplayLayout.setHorizontalGroup(
|
||||
jPanelTableDisplayLayout.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(jPanelTableDisplayLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanelTableDisplayLayout.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(jPanelTableDisplayLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(saveDebugTables)
|
||||
.addComponent(displayHighTables)
|
||||
.addComponent(valueLimitWarning))
|
||||
.addGroup(jPanelTableDisplayLayout.createSequentialGroup()
|
||||
.addGroup(jPanelTableDisplayLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(lblCellHeight)
|
||||
.addComponent(lblFont))
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addGroup(jPanelTableDisplayLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(btnChooseFont)
|
||||
.addGroup(jPanelTableDisplayLayout.createSequentialGroup()
|
||||
.addComponent(cellHeight, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED, 139, Short.MAX_VALUE)
|
||||
.addComponent(lblCellWidth)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(cellWidth, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)))))
|
||||
.addGap(47))
|
||||
.addGroup(Alignment.LEADING, jPanelTableDisplayLayout.createSequentialGroup()
|
||||
.addComponent(jPanel4, GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addGroup(Alignment.LEADING, jPanelTableDisplayLayout.createSequentialGroup()
|
||||
.addComponent(jPanel3, GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addComponent(jPanel2, GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
|
||||
);
|
||||
jPanelTableDisplayLayout.setVerticalGroup(
|
||||
jPanelTableDisplayLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(jPanelTableDisplayLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(saveDebugTables)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(displayHighTables)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(valueLimitWarning)
|
||||
.addGap(27)
|
||||
.addGroup(jPanelTableDisplayLayout.createParallelGroup(Alignment.BASELINE)
|
||||
.addComponent(lblCellWidth)
|
||||
.addComponent(cellWidth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblCellHeight)
|
||||
.addComponent(cellHeight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addGroup(jPanelTableDisplayLayout.createParallelGroup(Alignment.BASELINE)
|
||||
.addComponent(lblFont)
|
||||
.addComponent(btnChooseFont, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanelTableDisplay.setLayout(jPanelTableDisplayLayout);
|
||||
|
||||
// Init Clipboard Tab Panel
|
||||
GroupLayout jPanelClipboardLayout = new GroupLayout(jPanelClipboard);
|
||||
jPanelClipboardLayout.setHorizontalGroup(
|
||||
jPanelClipboardLayout.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(jPanelClipboardLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanelClipboardLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(jPanelClipboardLayout.createSequentialGroup()
|
||||
.addGap(17)
|
||||
.addGroup(jPanelClipboardLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(rdbtnAirboys)
|
||||
.addComponent(rdbtnDefault)
|
||||
.addComponent(rdbtnCustom))))
|
||||
.addGap(157))
|
||||
);
|
||||
jPanelClipboardLayout.setVerticalGroup(
|
||||
jPanelClipboardLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(jPanelClipboardLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(rdbtnDefault)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(rdbtnAirboys)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(rdbtnCustom)
|
||||
.addGap(435))
|
||||
);
|
||||
jPanelClipboard.setLayout(jPanelClipboardLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getSource() == maxColor) {
|
||||
Color color = JColorChooser.showDialog(this.getContentPane(),
|
||||
|
@ -511,7 +601,10 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
} else if (e.getSource() == btnApply) {
|
||||
applySettings();
|
||||
} else if (e.getSource() == btnOk) {
|
||||
// Apply settings to Settings object.
|
||||
applySettings();
|
||||
// Write settings to file.
|
||||
saveSettings();
|
||||
this.dispose();
|
||||
} else if (e.getSource() == btnCancel) {
|
||||
this.dispose();
|
||||
|
@ -592,7 +685,20 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
settings.setValueLimitWarning(valueLimitWarning.isSelected());
|
||||
settings.setWarningColor(warningColor.getBackground());
|
||||
|
||||
parent.setSettings(settings);
|
||||
if(rdbtnAirboys.isSelected())
|
||||
{
|
||||
settings.setAirboysFormat();
|
||||
} else if(rdbtnCustom.isSelected()) {
|
||||
settings.setTableClipboardFormat(Settings.CUSTOM_CLIPBOARD_FORMAT);
|
||||
// Table Header settings need to be manually edited in the settings.xml file;
|
||||
} else {
|
||||
settings.setDefaultFormat();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSettings()
|
||||
{
|
||||
parent.getSettingsManager().save(settings);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
@ -626,7 +732,10 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
private javax.swing.JLabel highlightColor;
|
||||
private javax.swing.JLabel increaseColor;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JTabbedPane settingsTabbedPane;
|
||||
private javax.swing.JPanel jPanelDefault;
|
||||
private javax.swing.JPanel jPanelClipboard;
|
||||
private javax.swing.JPanel jPanelTableDisplay;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JPanel jPanel4;
|
||||
|
@ -648,6 +757,8 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
private javax.swing.JComboBox tableClickCount;
|
||||
private javax.swing.JCheckBox valueLimitWarning;
|
||||
private javax.swing.JLabel warningColor;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private ButtonGroup clipboardButtonGroup;
|
||||
private javax.swing.JRadioButton rdbtnDefault;
|
||||
private javax.swing.JRadioButton rdbtnAirboys;
|
||||
private javax.swing.JRadioButton rdbtnCustom;
|
||||
}
|
|
@ -19,24 +19,28 @@
|
|||
|
||||
package com.romraider.util;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import static com.romraider.Version.VERSION;
|
||||
import com.romraider.swing.JProgressPane;
|
||||
import com.romraider.xml.DOMSettingsBuilder;
|
||||
import com.romraider.xml.DOMSettingsUnmarshaller;
|
||||
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.swing.JProgressPane;
|
||||
import com.romraider.xml.DOMSettingsBuilder;
|
||||
import com.romraider.xml.DOMSettingsUnmarshaller;
|
||||
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
|
||||
|
||||
public final class SettingsManagerImpl implements SettingsManager {
|
||||
private static final String SETTINGS_FILE = "/.RomRaider/settings.xml";
|
||||
private static final String HOME = System.getProperty("user.home");
|
||||
private static final String HOME = System.getProperty("user.home");
|
||||
|
||||
@Override
|
||||
public Settings load() {
|
||||
try {
|
||||
InputSource src = new InputSource(new FileInputStream(new File(HOME + SETTINGS_FILE)));
|
||||
|
@ -54,17 +58,19 @@ public final class SettingsManagerImpl implements SettingsManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Settings settings) {
|
||||
save(settings, new JProgressPane());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Settings settings, JProgressPane progress) {
|
||||
DOMSettingsBuilder builder = new DOMSettingsBuilder();
|
||||
try {
|
||||
new File(HOME + "/.RomRaider/").mkdir(); // Creates directory if it does not exist
|
||||
builder.buildSettings(settings, new File(HOME + SETTINGS_FILE), progress, VERSION);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ public final class DOMSettingsBuilder {
|
|||
settingsNode.appendChild(buildTableDisplay(settings));
|
||||
progress.update("Saving logger settings...", 75);
|
||||
settingsNode.appendChild(buildLogger(settings));
|
||||
progress.update("Saving table clipboard format settings...", 80);
|
||||
settingsNode.appendChild(buildTableClipboardFormat(settings));
|
||||
|
||||
OutputFormat of = new OutputFormat("XML", "ISO-8859-1", true);
|
||||
of.setIndent(1);
|
||||
|
@ -100,6 +102,11 @@ public final class DOMSettingsBuilder {
|
|||
imageDir.setAttribute("path", settings.getLastImageDir().getAbsolutePath());
|
||||
files.appendChild(imageDir);
|
||||
|
||||
// repository directory
|
||||
IIOMetadataNode repositoryDir = new IIOMetadataNode(Settings.REPOSITORY_ELEMENT_NAME);
|
||||
repositoryDir.setAttribute(Settings.REPOSITORY_ATTRIBUTE_NAME, settings.getLastRepositoryDir().getAbsolutePath());
|
||||
files.appendChild(repositoryDir);
|
||||
|
||||
// ecu definition files
|
||||
Vector<File> defFiles = settings.getEcuDefinitionFiles();
|
||||
|
||||
|
@ -308,4 +315,31 @@ public final class DOMSettingsBuilder {
|
|||
|
||||
return loggerSettings;
|
||||
}
|
||||
}
|
||||
|
||||
private IIOMetadataNode buildTableClipboardFormat(Settings settings) {
|
||||
// Head Node
|
||||
IIOMetadataNode tableClipboardFormatSetting = new IIOMetadataNode(Settings.TABLE_CLIPBOARD_FORMAT_ELEMENT);
|
||||
tableClipboardFormatSetting.setAttribute(Settings.TABLE_CLIPBOARD_FORMAT_ATTRIBUTE, settings.getTableClipboardFormat());
|
||||
|
||||
// Table Child
|
||||
IIOMetadataNode tableFormatSetting = new IIOMetadataNode(Settings.TABLE_ELEMENT);
|
||||
// Table1D Child
|
||||
IIOMetadataNode table1DFormatSetting = new IIOMetadataNode(Settings.TABLE1D_ELEMENT);
|
||||
// Table2D Child
|
||||
IIOMetadataNode table2DFormatSetting = new IIOMetadataNode(Settings.TABLE2D_ELEMENT);
|
||||
// Table3D Child
|
||||
IIOMetadataNode table3DFormatSetting = new IIOMetadataNode(Settings.TABLE3D_ELEMENT);
|
||||
|
||||
tableFormatSetting.setAttribute(Settings.TABLE_HEADER_ATTRIBUTE, settings.getTableHeader());
|
||||
table1DFormatSetting.setAttribute(Settings.TABLE_HEADER_ATTRIBUTE, settings.getTable1DHeader());
|
||||
table2DFormatSetting.setAttribute(Settings.TABLE_HEADER_ATTRIBUTE, settings.getTable2DHeader());
|
||||
table3DFormatSetting.setAttribute(Settings.TABLE_HEADER_ATTRIBUTE, settings.getTable3DHeader());
|
||||
|
||||
tableClipboardFormatSetting.appendChild(tableFormatSetting);
|
||||
tableClipboardFormatSetting.appendChild(table1DFormatSetting);
|
||||
tableClipboardFormatSetting.appendChild(table2DFormatSetting);
|
||||
tableClipboardFormatSetting.appendChild(table3DFormatSetting);
|
||||
|
||||
return tableClipboardFormatSetting;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ public final class DOMSettingsUnmarshaller {
|
|||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("logger")) {
|
||||
settings = unmarshallLogger(n, settings);
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase(Settings.TABLE_CLIPBOARD_FORMAT_ELEMENT)) {
|
||||
settings = this.unmarshallClipboardFormat(n, settings);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
|
@ -104,6 +106,9 @@ public final class DOMSettingsUnmarshaller {
|
|||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("image_dir")) {
|
||||
settings.setLastImageDir(new File(unmarshallAttribute(n, "path", "ecu_defs.xml")));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase(Settings.REPOSITORY_ELEMENT_NAME)) {
|
||||
settings.setLastRepositoryDir(new File(unmarshallAttribute(n, Settings.REPOSITORY_ATTRIBUTE_NAME, "repositories")));
|
||||
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
|
@ -251,7 +256,7 @@ public final class DOMSettingsUnmarshaller {
|
|||
settings.setFileLoggingAbsoluteTimestamp(unmarshallAttribute(n, "absolutetimestamp", false));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("debug")) {
|
||||
settings.setLoggerDebuggingLevel(unmarshallAttribute(n, "level", "info"));
|
||||
settings.setLoggerDebuggingLevel(unmarshallAttribute(n, "level", "info"));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("plugins")) {
|
||||
Map<String, String> pluginPorts = new HashMap<String, String>();
|
||||
|
@ -278,4 +283,34 @@ public final class DOMSettingsUnmarshaller {
|
|||
unmarshallAttribute(colorNode, "b", 155));
|
||||
}
|
||||
|
||||
}
|
||||
private Settings unmarshallClipboardFormat(Node formatNode, Settings settings) {
|
||||
String tableClipboardFormat = unmarshallAttribute(formatNode, Settings.TABLE_CLIPBOARD_FORMAT_ATTRIBUTE, Settings.DEFAULT_CLIPBOARD_FORMAT);
|
||||
if(tableClipboardFormat.equalsIgnoreCase(Settings.CUSTOM_CLIPBOARD_FORMAT)) {
|
||||
settings.setTableClipboardFormat(Settings.CUSTOM_CLIPBOARD_FORMAT);
|
||||
} else if (tableClipboardFormat.equalsIgnoreCase(Settings.AIRBOYS_CLIPBOARD_FORMAT)) {
|
||||
settings.setAirboysFormat();
|
||||
return settings;
|
||||
} else {
|
||||
settings.setDefaultFormat();
|
||||
return settings;
|
||||
}
|
||||
|
||||
NodeList tableFormats = formatNode.getChildNodes();
|
||||
for( int i = 0; i < tableFormats.getLength(); i++) {
|
||||
Node tableNode = tableFormats.item(i);
|
||||
if(tableNode.getNodeType() == ELEMENT_NODE) {
|
||||
if(tableNode.getNodeName().equalsIgnoreCase(Settings.TABLE_ELEMENT)) {
|
||||
settings.setTableHeader(unmarshallAttribute(tableNode, Settings.TABLE_HEADER_ATTRIBUTE, Settings.DEFAULT_TABLE_HEADER));
|
||||
} else if(tableNode.getNodeName().equalsIgnoreCase(Settings.TABLE1D_ELEMENT)) {
|
||||
settings.setTable1DHeader(unmarshallAttribute(tableNode, Settings.TABLE_HEADER_ATTRIBUTE, Settings.DEFAULT_TABLE1D_HEADER));
|
||||
} else if(tableNode.getNodeName().equalsIgnoreCase(Settings.TABLE2D_ELEMENT)) {
|
||||
settings.setTable2DHeader(unmarshallAttribute(tableNode, Settings.TABLE_HEADER_ATTRIBUTE, Settings.DEFAULT_TABLE2D_HEADER));
|
||||
} else if(tableNode.getNodeName().equalsIgnoreCase(Settings.TABLE3D_ELEMENT)) {
|
||||
settings.setTable3DHeader(unmarshallAttribute(tableNode, Settings.TABLE_HEADER_ATTRIBUTE, Settings.DEFAULT_TABLE3D_HEADER));
|
||||
}
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue