More Editor Cleanup:

- Combined idea of RomTreeNode and Rom into one.
 - Rom now contains a list of TableTreeNodes.
 - TableTreeNode now consists of a TableFrame.java.
 - TableFrame includes the reference to the table.
 - Fixed DTC TablePropertyPanel error.
 - Fixed definition locating routine.
This commit is contained in:
Scotthew 2013-05-28 15:15:06 -07:00
parent 1c9ce70774
commit 291155f47a
24 changed files with 326 additions and 463 deletions

View File

@ -109,6 +109,8 @@ public class Settings implements Serializable {
public static final Color UNCHANGED_VALUE_COLOR = new Color(160, 160, 160);
public static final String INVALID_ATTRIBUTE_TEXT = "invalid";
/* Rom Settings */
public static final int CHECK_TOTAL = 0x5AA5A55A;

View File

@ -69,7 +69,6 @@ import org.xml.sax.SAXParseException;
import com.centerkey.utils.BareBonesBrowserLaunch;
import com.romraider.Settings;
import com.romraider.logger.ecu.EcuLogger;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.maps.Rom;
import com.romraider.maps.Table;
import com.romraider.net.URL;
@ -80,7 +79,6 @@ import com.romraider.swing.ECUEditorToolBar;
import com.romraider.swing.JProgressPane;
import com.romraider.swing.MDIDesktopPane;
import com.romraider.swing.RomTree;
import com.romraider.swing.RomTreeNode;
import com.romraider.swing.RomTreeRootNode;
import com.romraider.swing.TableFrame;
import com.romraider.swing.TableToolBar;
@ -277,13 +275,13 @@ public class ECUEditor extends AbstractFrame {
public void addRom(Rom input) {
// add to ecu image list pane
RomTreeNode romNode = new RomTreeNode(input, getSettings().getUserLevel(), getSettings().isDisplayHighTables());
getImageRoot().add(romNode);
input.refresh(getSettings().getUserLevel(), getSettings().isDisplayHighTables());
getImageRoot().add(input);
getImageList().setVisible(true);
getImageList().expandPath(new TreePath(getImageRoot()));
getImageList().expandPath(new TreePath(romNode.getPath()));
getImageList().expandPath(new TreePath(input.getPath()));
// uncomment collapsePath if you want ROM to open collapsed.
// imageList.collapsePath(addedRomPath);
@ -333,9 +331,7 @@ public class ECUEditor extends AbstractFrame {
public void removeDisplayTable(TableFrame frame) {
frame.setVisible(false);
updateTableToolBar(null);
rightPanel.remove(frame);
rightPanel.repaint();
}
@ -369,11 +365,6 @@ public class ECUEditor extends AbstractFrame {
} else {
setTitle(titleText + " - " + lastSelectedRom.getFileName());
}
// update filenames
for (int i = 0; i < imageRoot.getChildCount(); i++) {
((RomTreeNode) imageRoot.getChildAt(i)).updateFileName();
}
}
public ECUEditorToolBar getToolBar() {
@ -399,8 +390,8 @@ public class ECUEditor extends AbstractFrame {
public void setSettings(Settings settings) {
this.settings = settings;
for (int i = 0; i < imageRoot.getChildCount(); i++) {
RomTreeNode rtn = (RomTreeNode) imageRoot.getChildAt(i);
rtn.getRom().applyTableColorSettings();
Rom rom = (Rom) imageRoot.getChildAt(i);
rom.applyTableColorSettings();
}
}
@ -414,8 +405,8 @@ public class ECUEditor extends AbstractFrame {
public Vector<Rom> getImages() {
Vector<Rom> images = new Vector<Rom>();
for (int i = 0; i < imageRoot.getChildCount(); i++) {
RomTreeNode rtn = (RomTreeNode) imageRoot.getChildAt(i);
images.add(rtn.getRom());
Rom rom = (Rom) imageRoot.getChildAt(i);
images.add(rom);
}
return images;
}
@ -432,14 +423,21 @@ public class ECUEditor extends AbstractFrame {
{
getToolBar().updateButtons();
getEditorMenuBar().updateMenu();
refreshTableMenus();
imageList.updateUI();
imageList.repaint();
rightPanel.updateUI();
rightPanel.repaint();
}
public void refreshOpenTableMenus() {
for(Object frame : ECUEditorManager.getECUEditor().getRightPanel().getAllFrames()) {
if(frame instanceof TableFrame)
{
((TableFrame)frame).getTableMenuBar().refreshTableMenuBar();
}
}
}
public void openImage(File inputFile) throws Exception {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
openImageWorker = new OpenImageWorker(inputFile);
@ -498,14 +496,6 @@ public class ECUEditor extends AbstractFrame {
public MDIDesktopPane getRightPanel() {
return this.rightPanel;
}
public void refreshTableMenus() {
for(Rom rom : getImages()) {
for(Table table : rom.getTables()) {
table.getFrame().getTableMenuBar().refreshTableMenuBar();
}
}
}
}
class LaunchLoggerWorker extends SwingWorker<Void, Void> {
@ -591,19 +581,15 @@ class CloseImageWorker extends SwingWorker<Void, Void> {
RomTree imageList = editor.getImageList();
for (int i = 0; i < imageRoot.getChildCount(); i++) {
RomTreeNode romTreeNode = (RomTreeNode) imageRoot.getChildAt(i);
Rom rom = romTreeNode.getRom();
Rom rom = (Rom) imageRoot.getChildAt(i);;
if (rom == editor.getLastSelectedRom()) {
for (Table t : rom.getTables()) {
editor.getRightPanel().remove(t.getFrame());
TableUpdateHandler.getInstance().deregisterTable(t);
}
rom.removeAllChildren();
// Cleanup Rom Data
rom.clearData();
Vector<TreePath> path = new Vector<TreePath>();
path.add(new TreePath(romTreeNode.getPath()));
path.add(new TreePath(rom.getPath()));
imageRoot.remove(i);
imageList.removeDescendantToggledPaths(path.elements());
@ -614,7 +600,7 @@ class CloseImageWorker extends SwingWorker<Void, Void> {
}
if (imageRoot.getChildCount() > 0) {
editor.setLastSelectedRom(((RomTreeNode) imageRoot.getChildAt(0)).getRom());
editor.setLastSelectedRom((Rom) imageRoot.getChildAt(0));
} else {
// no other images open
editor.setLastSelectedRom(null);
@ -643,6 +629,10 @@ class OpenImageWorker extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
DOMParser parser = new DOMParser();
Document doc;
FileInputStream fileStream;
try {
Settings settings = editor.getSettings();
@ -650,18 +640,17 @@ class OpenImageWorker extends SwingWorker<Void, Void> {
setProgress(0);
byte[] input = editor.readFile(inputFile);
DOMParser parser = new DOMParser();
editor.getStatusPanel().setStatus("Finding ECU definition...");
setProgress(10);
// parse ecu definition files until result found
for (int i = 0; i < settings.getEcuDefinitionFiles().size(); i++) {
FileInputStream fileStream = new FileInputStream(settings.getEcuDefinitionFiles().get(i));
fileStream = new FileInputStream(settings.getEcuDefinitionFiles().get(i));
InputSource src = new InputSource(fileStream);
parser.parse(src);
Document doc = parser.getDocument();
doc = parser.getDocument();
try {
Rom rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel());
@ -679,20 +668,16 @@ class OpenImageWorker extends SwingWorker<Void, Void> {
editor.getStatusPanel().setStatus("Done loading image...");
setProgress(100);
parser.reset();
try{
fileStream.close();
} catch(IOException ioex) {
;// Do nothing
}
return null;
} catch (RomNotFoundException ex) {
// rom was not found in current file, skip to next
} finally {
parser.reset();
doc.removeChild(doc.getDocumentElement());
doc = null;
fileStream.close();
}
parser = null;
doc.removeChild(doc.getDocumentElement());
doc = null;
}
// if code executes to this point, no ROM was found, report to user

View File

@ -36,46 +36,90 @@ import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultMutableTreeNode;
import org.apache.log4j.Logger;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.swing.CategoryTreeNode;
import com.romraider.swing.JProgressPane;
import com.romraider.swing.TableFrame;
import com.romraider.swing.TableTreeNode;
import com.romraider.xml.TableNotFoundException;
public class Rom implements Serializable {
public class Rom extends DefaultMutableTreeNode implements Serializable {
private static final long serialVersionUID = 7865405179738828128L;
private static final Logger LOGGER = Logger.getLogger(Rom.class);
private RomID romID = new RomID();
private String fileName = "";
private File fullFileName = new File(".");
private final Vector<Table> tables = new Vector<Table>();
private final Vector<TableTreeNode> tableNodes = new Vector<TableTreeNode>();
private byte[] binData;
private String parent = "";
private boolean isAbstract = false;
public Rom() {
}
public void refresh(int userLevel, boolean isDisplayHighTables) {
removeAllChildren();
for (int i = 0; i < tableNodes.size(); i++) {
Table table = tableNodes.get(i).getTable();
String frameTitle = this.getFileName() + " - " + table.getName();
if (isDisplayHighTables || userLevel >= table.getUserLevel()) {
boolean categoryExists = false;
for (int j = 0; j < getChildCount(); j++) {
if (getChildAt(j).toString().equals(table.getCategory())) {
// add to appropriate category
TableTreeNode tableNode = new TableTreeNode(new TableFrame(frameTitle, table));
getChildAt(j).add(tableNode);
categoryExists = true;
break;
}
}
if (!categoryExists) { // if category does not already exist, create it
CategoryTreeNode categoryNode = new CategoryTreeNode(table.getCategory());
TableTreeNode tableNode = new TableTreeNode(new TableFrame(frameTitle, table));
categoryNode.add(tableNode);
this.add(categoryNode);
}
}
}
}
public void addTable(Table table) {
boolean found = false;
for (int i = 0; i < tables.size(); i++) {
if (tables.get(i).getName().equalsIgnoreCase(table.getName())) {
tables.remove(i);
tables.add(i, table);
String frameTitle = this.getFileName()+" - "+table.getName();
for (int i = 0; i < tableNodes.size(); i++) {
if (tableNodes.get(i).getTable().getName().equalsIgnoreCase(table.getName())) {
tableNodes.remove(i);
tableNodes.add(i, new TableTreeNode(new TableFrame(frameTitle, table)));
found = true;
break;
}
}
if (!found) {
tables.add(table);
tableNodes.add(new TableTreeNode(new TableFrame(frameTitle, table)));
}
}
public void removeTable(Table table) {
for(int i = 0; i < tableNodes.size(); i++) {
if(tableNodes.get(i).getTable().getName().equalsIgnoreCase(table.getName())) {
tableNodes.remove(i);
break;
}
}
}
public Table getTable(String tableName) throws TableNotFoundException {
for (Table table : tables) {
if (table.getName().equalsIgnoreCase(tableName)) {
return table;
for (TableTreeNode tableNode : tableNodes) {
if (tableNode.getTable().getName().equalsIgnoreCase(tableName)) {
return tableNode.getTable();
}
}
throw new TableNotFoundException();
@ -83,37 +127,40 @@ public class Rom implements Serializable {
public List<Table> findTables(String regex) {
List<Table> result = new ArrayList<Table>();
for (Table table : tables) {
String name = table.getName();
if (name.matches(regex)) result.add(table);
for (TableTreeNode tableNode : tableNodes) {
String name = tableNode.getTable().getName();
if (name.matches(regex)) result.add(tableNode.getTable());
}
return result;
}
public void removeTable(String tableName) {
for (int i = 0; i < tables.size(); i++) {
if (tables.get(i).getName().equalsIgnoreCase(tableName)) {
tables.remove(i);
public void removeTableFrame(String tableName) {
for (int i = 0; i < tableNodes.size(); i++) {
if (tableNodes.get(i).getTable().getName().equalsIgnoreCase(tableName)) {
tableNodes.remove(i);
}
}
}
public void populateTables(byte[] binData, JProgressPane progress) {
this.binData = binData;
for (int i = 0; i < getTables().size(); i++) {
for (int i = 0; i < tableNodes.size(); i++) {
// update progress
int currProgress = (int) ((double) i / (double) getTables().size() * 40);
int currProgress = (int) (i / (double) tableNodes.size() * 40);
progress.update("Populating tables...", 50 + currProgress);
Table table = tables.get(i);
Table table = tableNodes.get(i).getTable();
try {
// if storageaddress has not been set (or is set to 0) omit table
if (table.getStorageAddress() != 0) {
try {
table.populateTable(binData);
table.populateTable(binData, this.getRomID().getRamOffset());
TableUpdateHandler.getInstance().registerTable(table);
if (table.getName().equalsIgnoreCase("Checksum Fix")) setEditStamp(binData, table.getStorageAddress());
if (table.getName().equalsIgnoreCase("Checksum Fix")){
setEditStamp(binData, table.getStorageAddress());
}
} catch (ArrayIndexOutOfBoundsException ex) {
LOGGER.error(table.getName() +
@ -123,20 +170,20 @@ public class Rom implements Serializable {
// table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "Storage address for table \"" + table.getName() +
"\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE);
tables.removeElementAt(i);
tableNodes.removeElementAt(i);
i--;
}
} else {
tables.remove(i);
tableNodes.removeElementAt(i);
// decrement i because length of vector has changed
i--;
}
} catch (NullPointerException ex) {
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "There was an error loading table " + table.getName(), "ECU Definition Error", JOptionPane.ERROR_MESSAGE);
tables.removeElementAt(i);
tableNodes.removeElementAt(i);
i--;
}
}
}
@ -175,8 +222,8 @@ public class Rom implements Serializable {
public String toString() {
String output = "";
output = output + "\n---- Rom ----" + romID.toString();
for (int i = 0; i < getTables().size(); i++) {
output = output + getTables().get(i);
for (int i = 0; i < tableNodes.size(); i++) {
output = output + tableNodes.get(i).getTable();
}
output = output + "\n---- End Rom ----";
@ -187,28 +234,38 @@ public class Rom implements Serializable {
return fileName;
}
public Vector<Table> getTables() {
Vector<Table> tables = new Vector<Table>();
for(TableTreeNode tableNode : tableNodes) {
tables.add(tableNode.getTable());
}
return tables;
}
public Vector<TableTreeNode> getTableNodes() {
return this.tableNodes;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Vector<Table> getTables() {
return tables;
}
public void applyTableColorSettings() {
for (Table table : tables) {
table.applyColorSettings();
for (TableTreeNode tableNode : tableNodes) {
tableNode.getTable().applyColorSettings();
//tables.get(i).resize();
table.getFrame().pack();
tableNode.getFrame().pack();
}
}
public byte[] saveFile() {
Table checksum = null;
for (Table table : tables) {
table.saveFile(binData);
if (table.getName().equalsIgnoreCase("Checksum Fix"))
checksum = table;
for (TableTreeNode tableNode : tableNodes) {
tableNode.getTable().saveFile(binData);
if (tableNode.getTable().getName().equalsIgnoreCase("Checksum Fix"))
{
checksum = tableNode.getTable();
}
}
if (checksum != null && !checksum.isLocked()) {
calculateRomChecksum(binData, checksum.getStorageAddress(), checksum.getDataSize());
@ -253,7 +310,7 @@ public class Rom implements Serializable {
}
public void clearData() {
tables.clear();
tableNodes.clear();
binData = null;
}
@ -268,19 +325,12 @@ public class Rom implements Serializable {
public void setFullFileName(File fullFileName) {
this.fullFileName = fullFileName;
this.setFileName(fullFileName.getName());
for (Table table : tables) {
table.getFrame().updateFileName();
for (TableTreeNode tableNode : tableNodes) {
String frameTitle = this.getFileName() + " - " + tableNode.getTable().getName();
tableNode.getFrame().setTitle(frameTitle);
}
}
public String getParent() {
return parent;
}
public void setParent(String parent) {
this.parent = parent;
}
public boolean isAbstract() {
return isAbstract;
}
@ -288,4 +338,23 @@ public class Rom implements Serializable {
public void setAbstract(boolean isAbstract) {
this.isAbstract = isAbstract;
}
@Override
public void removeAllChildren() {
// Dispose all table frames.
for(TableTreeNode tableNode : tableNodes) {
tableNode.getFrame().dispose();
}
super.removeAllChildren();
}
@Override
public DefaultMutableTreeNode getChildAt(int i) {
return (DefaultMutableTreeNode) super.getChildAt(i);
}
@Override
public DefaultMutableTreeNode getLastChild() {
return (DefaultMutableTreeNode) super.getLastChild();
}
}

View File

@ -56,7 +56,6 @@ import javax.swing.SwingWorker;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.swing.TableFrame;
import com.romraider.swing.TableToolBar;
import com.romraider.util.JEPUtil;
import com.romraider.xml.RomAttributeParser;
@ -83,7 +82,6 @@ public abstract class Table extends JPanel implements Serializable {
protected BorderLayout borderLayout = new BorderLayout();
protected GridLayout centerLayout = new GridLayout(1, 1, 0, 0);
protected JPanel centerPanel = new JPanel(centerLayout);
protected TableFrame frame;
protected int verticalOverhead = 103;
protected int horizontalOverhead = 2;
protected int cellHeight = 18;
@ -91,7 +89,6 @@ public abstract class Table extends JPanel implements Serializable {
protected int minHeight = 100;
protected int minWidthNoOverlay = 465;
protected int minWidthOverlay = 700;
protected Rom container;
protected int highlightX;
protected int highlightY;
protected boolean highlight = false;
@ -406,7 +403,7 @@ public abstract class Table extends JPanel implements Serializable {
this.data = data;
}
public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException {
if (scales.isEmpty()) {
scales.add(new Scale());
}
@ -417,7 +414,7 @@ public abstract class Table extends JPanel implements Serializable {
if (!isStatic) {
if (!beforeRam) {
ramOffset = container.getRomID().getRamOffset();
this.ramOffset = ramOffset;
}
for (int i = 0; i < data.length; i++) {
@ -783,11 +780,6 @@ public abstract class Table extends JPanel implements Serializable {
repaint();
}
public void setFrame(TableFrame frame) {
this.frame = frame;
frame.pack();
}
public Dimension getFrameSize() {
int height = verticalOverhead + cellHeight;
int width = horizontalOverhead + data.length * cellWidth;
@ -801,10 +793,6 @@ public abstract class Table extends JPanel implements Serializable {
return new Dimension(width, height);
}
public TableFrame getFrame() {
return frame;
}
public void increment(double increment) {
if (!isStatic && !locked && !(userLevel > getSettings().getUserLevel())) {
for (DataCell cell : data) {
@ -853,14 +841,6 @@ public abstract class Table extends JPanel implements Serializable {
colorize();
}
public Rom getRom() {
return container;
}
public void setRom(Rom container) {
this.container = container;
}
public void clearSelection() {
for (DataCell cell : data) {
cell.setSelected(false);
@ -1116,11 +1096,6 @@ public abstract class Table extends JPanel implements Serializable {
}
}
public void resize() {
//frame.setSize(getFrameSize());
frame.pack();
}
public Color getMaxColor() {
return maxColor;
}

View File

@ -35,10 +35,11 @@ public class Table1D extends Table {
}
@Override
public void populateTable(byte[] input) {
public void populateTable(byte[] input, int ramOffset) {
centerLayout.setRows(1);
centerLayout.setColumns(this.getDataSize());
super.populateTable(input);
super.populateTable(input, ramOffset);
// add to table
for (int i = 0; i < this.getDataSize(); i++) {

View File

@ -40,7 +40,6 @@ import javax.swing.SwingWorker;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.swing.TableFrame;
import com.romraider.util.AxisRange;
public class Table2D extends Table {
@ -114,13 +113,6 @@ public class Table2D extends Table {
return output;
}
@Override
public void setFrame(TableFrame frame) {
this.frame = frame;
axis.setFrame(frame);
frame.setSize(getFrameSize());
}
@Override
public Dimension getFrameSize() {
int height = verticalOverhead + cellHeight * 2;
@ -143,14 +135,13 @@ public class Table2D extends Table {
}
@Override
public void populateTable(byte[] input) throws ArrayIndexOutOfBoundsException {
public void populateTable(byte[] input, int ramOffset) throws ArrayIndexOutOfBoundsException {
centerLayout.setRows(2);
centerLayout.setColumns(this.getDataSize());
try {
axis.setRom(container);
axis.populateTable(input);
super.populateTable(input);
axis.populateTable(input, ramOffset);
super.populateTable(input, ramOffset);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new ArrayIndexOutOfBoundsException();
}
@ -369,7 +360,7 @@ public class Table2D extends Table {
@Override
protected void highlightLiveData() {
if (overlayLog && frame.isVisible()) {
if (overlayLog) {
AxisRange range = getLiveDataRangeForAxis(axis);
clearSelection();
boolean first = true;

View File

@ -46,7 +46,6 @@ import javax.swing.SwingWorker;
import com.romraider.Settings;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.logger.ecu.ui.swing.vertical.VerticalLabelUI;
import com.romraider.swing.TableFrame;
import com.romraider.util.AxisRange;
import com.romraider.xml.RomAttributeParser;
@ -130,11 +129,11 @@ public class Table3D extends Table {
}
@Override
public void populateTable(byte[] input) throws NullPointerException, ArrayIndexOutOfBoundsException {
public void populateTable(byte[] input, int ramOffset) throws NullPointerException, ArrayIndexOutOfBoundsException {
// fill first empty cell
centerPanel.add(new JLabel());
if (!beforeRam) {
ramOffset = container.getRomID().getRamOffset();
this.ramOffset = ramOffset;
}
// temporarily remove lock
@ -143,10 +142,8 @@ public class Table3D extends Table {
// populate axiis
try {
xAxis.setRom(container);
xAxis.populateTable(input);
yAxis.setRom(container);
yAxis.populateTable(input);
xAxis.populateTable(input, ramOffset);
yAxis.populateTable(input, ramOffset);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new ArrayIndexOutOfBoundsException();
}
@ -429,15 +426,6 @@ public class Table3D extends Table {
return true;
}
@Override
public void setFrame(TableFrame frame) {
this.frame = frame;
xAxis.setFrame(frame);
yAxis.setFrame(frame);
//frame.setSize(getFrameSize());
frame.pack();
}
@Override
public Dimension getFrameSize() {
int height = verticalOverhead + cellHeight * data[0].length;
@ -874,7 +862,6 @@ public class Table3D extends Table {
cellWidth = (int) getSettings().getCellSize().getWidth();
validateScaling();
resize();
colorize();
}
@ -914,7 +901,7 @@ public class Table3D extends Table {
@Override
protected void highlightLiveData() {
if (overlayLog && frame.isVisible()) {
if (overlayLog) {
AxisRange rangeX = getLiveDataRangeForAxis(xAxis);
AxisRange rangeY = getLiveDataRangeForAxis(yAxis);
clearSelection();

View File

@ -73,7 +73,7 @@ public class TableSwitch extends Table {
}
@Override
public void populateTable(byte[] input) {
public void populateTable(byte[] input, int ramOffset) {
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
radioPanel.add(new JLabel(" " + name));
for (String stateName : switchStates.keySet()) {
@ -117,7 +117,9 @@ public class TableSwitch extends Table {
// Validate XML switch definition data against the ROM data to select
// the appropriate switch setting or throw an error if there is a
// mismatch and disable this table's editing ability.
if (!beforeRam) ramOffset = container.getRomID().getRamOffset();
if (!beforeRam) {
this.ramOffset = ramOffset;
}
Map<String, Integer> sourceStatus = new HashMap<String, Integer>();
for (String stateName : switchStates.keySet()) {
byte[] sourceData = new byte[dataSize];

View File

@ -19,24 +19,13 @@
package com.romraider.swing;
import com.romraider.maps.Rom;
import javax.swing.tree.DefaultMutableTreeNode;
public class CategoryTreeNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = -752423096680196879L;
private Rom rom;
public CategoryTreeNode(String name, Rom rom) {
public CategoryTreeNode(String name) {
super(name);
this.setRom(rom);
}
public Rom getRom() {
return rom;
}
public void setRom(Rom rom) {
this.rom = rom;
}
}

View File

@ -49,11 +49,11 @@ public class CompareImagesForm extends JFrame implements ActionListener {
private static final long serialVersionUID = -8937472127815934398L;
private final Vector<Rom> roms;
private final JPanel contentPane;
private final JComboBox comboBoxImageLeft;
private final JComboBox comboBoxImageRight;
private final JComboBox<Rom> comboBoxImageLeft;
private final JComboBox<Rom> comboBoxImageRight;
private final JButton btnCompare;
private final JList listChanges;
private final DefaultListModel listModelChanges = new DefaultListModel();
private final JList<ListItem> listChanges;
private final DefaultListModel<ListItem> listModelChanges = new DefaultListModel<ListItem>();
private final ChangeListCellRenderer changeRenderer = new ChangeListCellRenderer();
private final JScrollPane scrollPaneResults;
private final JLabel lblImageResultString;
@ -80,13 +80,13 @@ public class CompareImagesForm extends JFrame implements ActionListener {
panelImageSelector.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
panelImageSelector.setLayout(null);
this.comboBoxImageLeft = new JComboBox();
this.comboBoxImageLeft = new JComboBox<Rom>();
this.comboBoxImageLeft.setBounds(10, 7, 554, 20);
this.comboBoxImageLeft.setToolTipText("Select an image to compare.");
this.comboBoxImageLeft.setRenderer( new ComboBoxRenderer() );
panelImageSelector.add(this.comboBoxImageLeft);
this.comboBoxImageRight = new JComboBox();
this.comboBoxImageRight = new JComboBox<Rom>();
this.comboBoxImageRight.setBounds(10, 32, 554, 20);
this.comboBoxImageRight.setToolTipText("Select an image to compare.");
this.comboBoxImageRight.setRenderer( new ComboBoxRenderer() );
@ -110,7 +110,7 @@ public class CompareImagesForm extends JFrame implements ActionListener {
scrollPaneResults.setBounds(10, 166, 574, 245);
contentPane.add(scrollPaneResults);
this.listChanges = new JList(this.listModelChanges);
this.listChanges = new JList<ListItem>(this.listModelChanges);
scrollPaneResults.setViewportView(this.listChanges);
listChanges.setCellRenderer(changeRenderer);
listChanges.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
@ -138,11 +138,14 @@ public class CompareImagesForm extends JFrame implements ActionListener {
int different = 0;
int missing = 0;
for(Table leftTable : left.getTables())
for(TableTreeNode leftNode : left.getTableNodes())
{
Boolean found = false;
for(Table rightTable : right.getTables())
Table leftTable = leftNode.getTable();
for(TableTreeNode rightNode : right.getTableNodes())
{
Table rightTable = rightNode.getTable();
if(leftTable.getName().equalsIgnoreCase(rightTable.getName()))
{
if(leftTable.equals(rightTable)) {
@ -165,10 +168,10 @@ public class CompareImagesForm extends JFrame implements ActionListener {
}
// Check if rightTables has tables that do not exist in left table.
for(Table rightTable : right.getTables()) {
for(TableTreeNode rightFrame : right.getTableNodes()) {
Boolean found = false;
for(Table leftTable : left.getTables()) {
if(leftTable.getName().equalsIgnoreCase(rightTable.getName()))
for(TableTreeNode leftFrame : left.getTableNodes()) {
if(leftFrame.getTable().getName().equalsIgnoreCase(rightFrame.getTable().getName()))
{
found = true;
break;
@ -177,7 +180,7 @@ public class CompareImagesForm extends JFrame implements ActionListener {
if(!found) {
missing++;
listModelChanges.addElement(new ListItem(3, rightTable.getName()));
listModelChanges.addElement(new ListItem(3, rightFrame.getTable().getName()));
}
}

View File

@ -244,7 +244,7 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
refreshImage.setText("Refresh " + file);
closeImage.setText("Close " + file);
romProperties.setText(file + "Properties");
repaint();
revalidate();
}
@Override
@ -438,8 +438,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
}
}
if(save) {
for(Table table : image.getTables())
for(TableTreeNode treeNode : image.getTableNodes())
{
Table table = treeNode.getTable();
String category = table.getCategory();
String tableName = table.getName();
String tableDirString = selectedDir.getAbsolutePath() + separator + category;

View File

@ -116,7 +116,7 @@ public class ECUEditorToolBar extends JToolBar implements ActionListener {
refreshImage.setEnabled(true);
closeImage.setEnabled(true);
}
repaint();
revalidate();
}
@Override

View File

@ -56,8 +56,8 @@ public class JTableChooser extends JOptionPane implements MouseListener {
DefaultMutableTreeNode romNode = new DefaultMutableTreeNode(rom.getFileName());
rootNode.add(romNode);
for (int j = 0; j < rom.getTables().size(); j++) {
Table table = rom.getTables().get(j);
for (TableTreeNode tableTreeNode : rom.getTableNodes()) {
Table table = tableTreeNode.getTable();
// use the length of the table name to set the width of the displayTree
// so the entire name can be read without being cut off on the right
if (table.getName().length() > nameLength) {

View File

@ -63,51 +63,45 @@ public class RomCellRenderer implements TreeCellRenderer {
Component returnValue = null;
if (value != null && value instanceof RomTreeNode) {
if (value != null && value instanceof Rom) {
Rom rom = ((Rom) value);
Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
if (userObject instanceof Rom) {
Rom rom = (Rom) userObject;
if (expanded) {
fileName.setText("- " + rom.getFileName());
} else {
fileName.setText("+ " + rom.getFileName());
}
carInfo.setText(rom.getRomIDString() + ", " +
rom.getRomID().getCaseId() + "; " +
rom.getRomID().getYear() + " " +
rom.getRomID().getMake() + " " +
rom.getRomID().getModel() + " " +
rom.getRomID().getSubModel() + ", " +
rom.getRomID().getTransmission()
);
JPanel renderer = new JPanel(new GridLayout(2, 1));
renderer.add(fileName);
renderer.add(carInfo);
if (selected) {
renderer.setBackground(new Color(220, 220, 255));
renderer.setBorder(createLineBorder(new Color(0, 0, 225)));
} else {
renderer.setBorder(createLineBorder(new Color(220, 0, 0)));
renderer.setBackground(new Color(255, 210, 210));
}
renderer.setPreferredSize(new Dimension(tree.getParent().getWidth(), 30));
renderer.setMaximumSize(new Dimension(tree.getParent().getWidth(), 30));
renderer.setEnabled(tree.isEnabled());
returnValue = renderer;
if (expanded) {
fileName.setText("- " + rom.getFileName());
} else {
fileName.setText("+ " + rom.getFileName());
}
carInfo.setText(rom.getRomIDString() + ", " +
rom.getRomID().getCaseId() + "; " +
rom.getRomID().getYear() + " " +
rom.getRomID().getMake() + " " +
rom.getRomID().getModel() + " " +
rom.getRomID().getSubModel() + ", " +
rom.getRomID().getTransmission()
);
JPanel renderer = new JPanel(new GridLayout(2, 1));
renderer.add(fileName);
renderer.add(carInfo);
if (selected) {
renderer.setBackground(new Color(220, 220, 255));
renderer.setBorder(createLineBorder(new Color(0, 0, 225)));
} else {
renderer.setBorder(createLineBorder(new Color(220, 0, 0)));
renderer.setBackground(new Color(255, 210, 210));
}
renderer.setPreferredSize(new Dimension(tree.getParent().getWidth(), 30));
renderer.setMaximumSize(new Dimension(tree.getParent().getWidth(), 30));
renderer.setEnabled(tree.isEnabled());
returnValue = renderer;
} else if (value != null && value instanceof TableTreeNode) {
Table table = (Table) ((DefaultMutableTreeNode) value).getUserObject();
Table table = ((TableFrame)((DefaultMutableTreeNode) value).getUserObject()).getTable();
JPanel renderer = new JPanel(new GridLayout(1, 1));
renderer.setBorder(createLineBorder(Color.WHITE));
JLabel tableName = new JLabel("");

View File

@ -35,6 +35,7 @@ import javax.swing.tree.TreePath;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.maps.Rom;
public class RomTree extends JTree implements MouseListener {
@ -97,18 +98,12 @@ public class RomTree extends JTree implements MouseListener {
}
private void setLastSelectedRom(Object selectedNode) {
if (selectedNode instanceof TableTreeNode || selectedNode instanceof CategoryTreeNode || selectedNode instanceof RomTreeNode)
if (selectedNode instanceof TableTreeNode || selectedNode instanceof CategoryTreeNode || selectedNode instanceof Rom)
{
Object lastSelectedPathComponent = getLastSelectedPathComponent();
if(lastSelectedPathComponent instanceof TableTreeNode) {
TableTreeNode node = (TableTreeNode) lastSelectedPathComponent;
getEditor().setLastSelectedRom(node.getTable().getRom());
} else if(lastSelectedPathComponent instanceof CategoryTreeNode) {
CategoryTreeNode node = (CategoryTreeNode) lastSelectedPathComponent;
getEditor().setLastSelectedRom(node.getRom());
} else if(lastSelectedPathComponent instanceof RomTreeNode) {
RomTreeNode node = (RomTreeNode) lastSelectedPathComponent;
getEditor().setLastSelectedRom(node.getRom());
if(lastSelectedPathComponent instanceof Rom) {
Rom node = (Rom) lastSelectedPathComponent;
getEditor().setLastSelectedRom(node);
}
}
getEditor().refreshUI();

View File

@ -1,121 +0,0 @@
/*
* 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.util.Enumeration;
import java.util.Vector;
import javax.swing.tree.DefaultMutableTreeNode;
import com.romraider.maps.Rom;
import com.romraider.maps.Table;
public class RomTreeNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = -5534315445738460608L;
private Rom rom = new Rom();
public RomTreeNode(Rom rom, int userLevel, boolean isDisplayHighTables) {
setRom(rom);
refresh(userLevel, isDisplayHighTables);
updateFileName();
}
public void refresh(int userLevel, boolean isDisplayHighTables) {
removeAllChildren();
Vector<Table> tables = rom.getTables();
for (int i = 0; i < tables.size(); i++) {
Table table = tables.get(i);
this.add(table);
if (isDisplayHighTables || userLevel >= table.getUserLevel()) {
boolean categoryExists = false;
for (int j = 0; j < getChildCount(); j++) {
if (getChildAt(j).toString().equals(table.getCategory())) {
// add to appropriate category
TableTreeNode tableNode = new TableTreeNode(table);
getChildAt(j).add(tableNode);
categoryExists = true;
break;
}
}
if (!categoryExists) { // if category does not already exist, create it
add(new CategoryTreeNode(table.getCategory(), table.getRom()));
TableTreeNode tableNode = new TableTreeNode(table);
getLastChild().add(tableNode);
}
}
}
}
@Override
public void removeAllChildren() {
// close all table windows
// loop through categories first
for (int i = 0; i < getChildCount(); i++) {
DefaultMutableTreeNode category = getChildAt(i);
// loop through tables in each category
for (Enumeration<?> j = category.children(); j.hasMoreElements();) {
((TableTreeNode) j.nextElement()).getFrame().dispose();
}
}
// removeAllChildren
super.removeAllChildren();
}
public void updateFileName() {
setUserObject(rom);
}
public void add(Table table) {
TableFrame frame = new TableFrame(table);
table.setFrame(frame);
}
@Override
public DefaultMutableTreeNode getChildAt(int i) {
return (DefaultMutableTreeNode) super.getChildAt(i);
}
@Override
public DefaultMutableTreeNode getLastChild() {
return (DefaultMutableTreeNode) super.getLastChild();
}
public Rom getRom() {
return rom;
}
public void setRom(Rom rom) {
this.rom = rom;
}
}

View File

@ -21,6 +21,8 @@ package com.romraider.swing;
import javax.swing.tree.DefaultMutableTreeNode;
import com.romraider.maps.Rom;
public class RomTreeRootNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = 6810217325725782803L;
@ -31,7 +33,7 @@ public class RomTreeRootNode extends DefaultMutableTreeNode {
public void setUserLevel(int userLevel, boolean isDisplayHighTables) {
for (int i = 0; i < getChildCount(); i++) {
((RomTreeNode) getChildAt(i)).refresh(userLevel, isDisplayHighTables);
((Rom) getChildAt(i)).refresh(userLevel, isDisplayHighTables);
}
}
}

View File

@ -27,16 +27,17 @@ import javax.swing.event.InternalFrameListener;
import com.romraider.editor.ecu.ECUEditor;
import com.romraider.editor.ecu.ECUEditorManager;
import com.romraider.logger.ecu.ui.handler.table.TableUpdateHandler;
import com.romraider.maps.Table;
public class TableFrame extends JInternalFrame implements InternalFrameListener {
private static final long serialVersionUID = -2651279694660392351L;
private Table table;
private final Table table;
private TableMenuBar tableMenuBar = null;
public TableFrame(Table table) {
super(table.getRom().getFileName() + " - " + table.getName(), true, true);
public TableFrame(String title, Table table) {
super(title, true, true);
this.table = table;
add(table);
setFrameIcon(null);
@ -44,18 +45,16 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener
if (System.getProperty("os.name").startsWith("Mac OS"))
putClientProperty("JInternalFrame.isPalette", true);
setVisible(false);
tableMenuBar = new TableMenuBar(table);
tableMenuBar = new TableMenuBar(this);
setJMenuBar(tableMenuBar);
setDefaultCloseOperation(HIDE_ON_CLOSE);
table.setFrame(this);
addInternalFrameListener(this);
}
@Override
public void internalFrameActivated(InternalFrameEvent e) {
ECUEditor parent = getEditor();
parent.setLastSelectedRom(getTable().getRom());
parent.updateTableToolBar(this.table);
parent.updateTableToolBar(getTable());
parent.getToolBar().updateButtons();
parent.getEditorMenuBar().updateMenu();
}
@ -63,11 +62,12 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener
@Override
public void internalFrameOpened(InternalFrameEvent e) {
;
TableUpdateHandler.getInstance().registerTable(this.getTable());
}
@Override
public void internalFrameClosing(InternalFrameEvent e) {
TableUpdateHandler.getInstance().deregisterTable(this.getTable());
getEditor().removeDisplayTable(this);
}
@ -95,18 +95,10 @@ public class TableFrame extends JInternalFrame implements InternalFrameListener
return table;
}
public void setTable(Table table) {
this.table = table;
}
public ECUEditor getEditor() {
return ECUEditorManager.getECUEditor();
}
public void updateFileName() {
setTitle(table.getRom().getFileName() + " - " + table.getName());
}
public TableMenuBar getTableMenuBar() {
return this.tableMenuBar;
}

View File

@ -39,7 +39,7 @@ import com.romraider.maps.Table;
public class TableMenuBar extends JMenuBar implements ActionListener {
private static final long serialVersionUID = -695692646459410510L;
private final Table table;
private final TableFrame tableFrame;
private JMenu fileMenu;
private JMenuItem graph;
//private JRadioButtonMenuItem overlay = new JRadioButtonMenuItem("Overlay Log");
@ -71,8 +71,8 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
private ButtonGroup compareDisplayGroup;
private ButtonGroup compareToGroup;
public TableMenuBar(Table table) {
this.table = table;
public TableMenuBar(TableFrame tableFrame) {
this.tableFrame = tableFrame;
initTableMenuBar();
}
@ -96,7 +96,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
close = new JMenuItem("Close Table");
initCompareMenu();
close.setText("Close " + table.getName());
close.setText("Close " + getTable().getName());
graph.addActionListener(this);
close.addActionListener(this);
@ -242,7 +242,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
private void applyTableTypeRules() {
// Hide items that don't work with a DTC tables.
if(table.getType() == Settings.TABLE_SWITCH) {
if(getTable().getType() == Settings.TABLE_SWITCH) {
editMenu.setEnabled(false);
compareOriginal.setEnabled(false);
comparePercent.setEnabled(false);
@ -254,14 +254,13 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
private void refreshSimilarOpenTables() {
similarOpenTables.removeAll();
String currentTableName = table.getName();
String currentTableName = getTable().getName();
Vector<Rom> roms = ECUEditorManager.getECUEditor().getImages();
for(Rom rom : roms) {
Vector<Table> tables = rom.getTables();
for(Table table : tables) {
if(table.getName().equalsIgnoreCase(currentTableName)) {
JRadioButtonMenuItem similarTable = new TableMenuItem(table);
for(TableTreeNode tableNode : rom.getTableNodes()) {
if(tableNode.getTable().getName().equalsIgnoreCase(currentTableName)) {
JRadioButtonMenuItem similarTable = new TableMenuItem(tableNode.getFrame());
similarTable.addActionListener(this);
similarOpenTables.add(similarTable);
}
@ -272,29 +271,29 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == undoAll) {
table.undoAll();
getTable().undoAll();
} else if (e.getSource() == revert) {
table.setRevertPoint();
getTable().setRevertPoint();
} else if (e.getSource() == undoSel) {
table.undoSelected();
getTable().undoSelected();
} else if (e.getSource() == close) {
ECUEditorManager.getECUEditor().removeDisplayTable(table.getFrame());
ECUEditorManager.getECUEditor().removeDisplayTable(tableFrame);
} else if (e.getSource() == tableProperties) {
JOptionPane.showMessageDialog(table, new TablePropertyPanel(table),
table.getName() + " Table Properties", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(getTable(), new TablePropertyPanel(getTable()),
getTable().getName() + " Table Properties", JOptionPane.INFORMATION_MESSAGE);
} else if (e.getSource() == copySel) {
table.copySelection();
getTable().copySelection();
} else if (e.getSource() == copyTable) {
table.copyTable();
getTable().copyTable();
} else if (e.getSource() == paste) {
table.paste();
getTable().paste();
} else if (e.getSource() == compareOff) {
compareByDisplay(Settings.COMPARE_DISPLAY_OFF);
@ -306,19 +305,19 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
compareByDisplay(Settings.COMPARE_DISPLAY_PERCENT);
} else if (e.getSource() == compareOriginal) {
table.setCompareType(Settings.DATA_TYPE_ORIGINAL);
getTable().setCompareType(Settings.DATA_TYPE_ORIGINAL);
compareToOriginal.setSelected(true);
compareByTable(table);
compareByTable(getTable());
} else if (e.getSource() == compareMap) {
JTableChooser chooser = new JTableChooser();
Table selectedTable = chooser.showChooser(table);
Table selectedTable = chooser.showChooser(getTable());
if(null != selectedTable) {
compareByTable(selectedTable);
}
} else if (e.getSource() instanceof TableMenuItem) {
Table selectedTable = ((TableMenuItem) e.getSource()).getTable();
Table selectedTable = ((TableMenuItem) e.getSource()).getFrame().getTable();
compareByTable(selectedTable);
} else if (e.getSource() == compareToOriginal) {
@ -331,9 +330,9 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
}
private void compareByType(int compareType) {
table.setCompareType(compareType);
if(table.fillCompareValues()) {
table.refreshCellDisplay();
getTable().setCompareType(compareType);
if(getTable().fillCompareValues()) {
getTable().refreshCellDisplay();
}
}
@ -342,22 +341,30 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
return;
}
if(table.getCompareDisplay() == Settings.COMPARE_DISPLAY_OFF) {
if(getTable().getCompareDisplay() == Settings.COMPARE_DISPLAY_OFF) {
// Default to absolute if none selected.
this.compareAbsolute.setSelected(true);
table.setCompareDisplay(Settings.COMPARE_DISPLAY_ABSOLUTE);
getTable().setCompareDisplay(Settings.COMPARE_DISPLAY_ABSOLUTE);
}
selectedTable.addComparedToTable(table);
selectedTable.addComparedToTable(getTable());
table.setCompareTable(selectedTable);
if(table.fillCompareValues()) {
table.refreshCellDisplay();
getTable().setCompareTable(selectedTable);
if(getTable().fillCompareValues()) {
getTable().refreshCellDisplay();
}
}
public void compareByDisplay(int compareDisplay) {
table.setCompareDisplay(compareDisplay);
table.refreshCellDisplay();
getTable().setCompareDisplay(compareDisplay);
getTable().refreshCellDisplay();
}
private Table getTable() {
return this.getTableFrame().getTable();
}
private TableFrame getTableFrame() {
return this.tableFrame;
}
}

View File

@ -2,19 +2,17 @@ package com.romraider.swing;
import javax.swing.JRadioButtonMenuItem;
import com.romraider.maps.Table;
public class TableMenuItem extends JRadioButtonMenuItem{
private static final long serialVersionUID = -3618983591185294967L;
private final Table table;
private final TableFrame tableFrame;
public TableMenuItem(Table table) {
super(table.getFrame().getTitle());
this.table = table;
public TableMenuItem(TableFrame tableFrame) {
super(tableFrame.getTitle());
this.tableFrame = tableFrame;
}
public Table getTable() {
return this.table;
public TableFrame getFrame() {
return this.tableFrame;
}
}

View File

@ -32,16 +32,29 @@ public class TablePropertyPanel extends javax.swing.JPanel {
tableName.setText(table.getName() + " (" + table.getType() + "D)");
category.setText(table.getCategory());
unit.setText(table.getScale().getUnit());
byteToReal.setText(table.getScale().getExpression());
realToByte.setText(table.getScale().getByteExpression());
String intType;
if (table.isSignedData()) {
intType = "int";
}
else {
intType = "uint";
if (Settings.TABLE_SWITCH == table.getType()) {
intType = "DTC";
// TODO: fill out other DTC specific properties.
fine.setText(Settings.INVALID_ATTRIBUTE_TEXT);
coarse.setText(Settings.INVALID_ATTRIBUTE_TEXT);
} else {
if (table.isSignedData()) {
intType = "int";
}
else {
intType = "uint";
}
unit.setText(table.getScale().getUnit());
byteToReal.setText(table.getScale().getExpression());
realToByte.setText(table.getScale().getByteExpression());
fine.setText(table.getScale().getFineIncrement() + "");
coarse.setText(table.getScale().getCoarseIncrement() + "");
}
storageSize.setText(intType + (table.getStorageType() * 8));
storageAddress.setText("0x" + Integer.toHexString(table.getStorageAddress()));
@ -52,8 +65,6 @@ public class TablePropertyPanel extends javax.swing.JPanel {
}
description.setText(table.getDescription());
fine.setText(table.getScale().getFineIncrement() + "");
coarse.setText(table.getScale().getCoarseIncrement() + "");
if (table.getUserLevel() == 1) {
userLevel.setText("Beginner");

View File

@ -287,6 +287,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
setScales(scales);
toggleTableToolBar(true);
revalidate();
}
private void toggleTableToolBar(Boolean enabled) {

View File

@ -19,44 +19,32 @@
package com.romraider.swing;
import com.romraider.maps.Rom;
import com.romraider.maps.Table;
import javax.swing.tree.DefaultMutableTreeNode;
import com.romraider.maps.Table;
public class TableTreeNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = 2824050968863990871L;
private String type;
private Rom rom;
private Table table;
private String toolTip;
private TableFrame frame;
public TableTreeNode(Table table) {
//super(table.getName() + " (" + table.getType() + "D)");
super(table);
this.table = table;
this.frame = table.getFrame();
public TableTreeNode(TableFrame tableFrame) {
super(tableFrame);
}
public String getType() {
return type;
public TableFrame getFrame() {
if(getUserObject() instanceof TableFrame) {
return (TableFrame)getUserObject();
}
return null;
}
public Rom getRom() {
return rom;
}
public void setRom(Rom rom) {
this.rom = rom;
public void setFrame(TableFrame tableFrame) {
this.setUserObject(tableFrame);
}
public Table getTable() {
return table;
}
public void setTable(Table table) {
this.table = table;
return this.getFrame().getTable();
}
public void setToolTipText(String input) {
@ -66,12 +54,4 @@ public class TableTreeNode extends DefaultMutableTreeNode {
public String getToolTipText() {
return toolTip;
}
public TableFrame getFrame() {
return frame;
}
public void setFrame(TableFrame frame) {
this.frame = frame;
}
}

View File

@ -225,12 +225,11 @@ public final class DOMRomUnmarshaller {
try {
table = unmarshallTable(n, table, rom);
table.setRom(rom);
rom.addTable(table);
} catch (TableIsOmittedException ex) {
// table is not supported in inherited def (skip)
if (table != null) {
rom.removeTable(table.getName());
rom.removeTable(table);
}
} catch (XMLParseException ex) {
LOGGER.error("Error unmarshalling rom", ex);