mirror of https://github.com/rusefi/RomRaider.git
Editor Comparison Updates:
- Resolved issue where missing TableSwitch getType() method breaks table rendering. - Added ability to compare DTC's. Differences will change the DTC radio button text to Red. - Unsupported DTC menu options are now disabled. - Wrapped all table compare functions in try catch returning false on errors. - Added Override equals() method to axis tables (Table1D).
This commit is contained in:
parent
a49e03a24e
commit
1c9ce70774
|
@ -121,6 +121,10 @@ public class Settings implements Serializable {
|
||||||
public static Color TABLE_DIFFERENT_COLOR = new Color(193, 27, 23);
|
public static Color TABLE_DIFFERENT_COLOR = new Color(193, 27, 23);
|
||||||
public static Color TABLE_MISSING_COLOR = new Color(251,185,23);
|
public static Color TABLE_MISSING_COLOR = new Color(251,185,23);
|
||||||
|
|
||||||
|
/* Compare DTC Foreground Colors */
|
||||||
|
public static Color TABLESWITCH_DEFAULT_COLOR = Color.black;
|
||||||
|
public static Color TABLESWITCH_DIFFERENT_COLOR = new Color(193, 27, 23);
|
||||||
|
|
||||||
/* MDI Desktop Settings*/
|
/* MDI Desktop Settings*/
|
||||||
public static int FRAME_OFFSET = 20;
|
public static int FRAME_OFFSET = 20;
|
||||||
|
|
||||||
|
|
|
@ -607,6 +607,7 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
|
try {
|
||||||
if(null == other) {
|
if(null == other) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -621,6 +622,16 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
|
|
||||||
Table otherTable = (Table)other;
|
Table otherTable = (Table)other;
|
||||||
|
|
||||||
|
if( (null == this.getName() && null == otherTable.getName())
|
||||||
|
|| (this.getName().isEmpty() && otherTable.getName().isEmpty()) ) {
|
||||||
|
;// Skip name compare if name is null or empty. This typically happens with
|
||||||
|
// a table axis. A table axis should be handled by Table1D.
|
||||||
|
} else {
|
||||||
|
if(!this.getName().equalsIgnoreCase(otherTable.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(this.data.length != otherTable.data.length)
|
if(this.data.length != otherTable.data.length)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -639,6 +650,10 @@ public abstract class Table extends JPanel implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// TODO: Log Exception.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
|
|
|
@ -185,4 +185,61 @@ public class Table1D extends Table {
|
||||||
public boolean isButtonSelected() {
|
public boolean isButtonSelected() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
try {
|
||||||
|
if(null == other) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(other == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(other instanceof Table1D)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Table1D otherTable = (Table1D)other;
|
||||||
|
|
||||||
|
if(this.isIsAxis()) {
|
||||||
|
if(!otherTable.isIsAxis()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! this.isStatic() == otherTable.isStatic()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: Possibly Log Error. It appears that Table1D is always an Axis.
|
||||||
|
if(!this.getName().equalsIgnoreCase(otherTable.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(this.data.length != otherTable.data.length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.data.equals(otherTable.data))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare Bin Values
|
||||||
|
for(int i=0 ; i < this.data.length ; i++) {
|
||||||
|
if(this.data[i].getBinValue() != otherTable.data[i].getBinValue()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// TODO: Log Exception.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -456,6 +456,7 @@ public class Table2D extends Table {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
|
try {
|
||||||
if(null == other) {
|
if(null == other) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -470,6 +471,10 @@ public class Table2D extends Table {
|
||||||
|
|
||||||
Table2D otherTable = (Table2D)other;
|
Table2D otherTable = (Table2D)other;
|
||||||
|
|
||||||
|
if(!this.getName().equalsIgnoreCase(otherTable.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!this.axis.equals(otherTable.axis)) {
|
if(!this.axis.equals(otherTable.axis)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -492,6 +497,10 @@ public class Table2D extends Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// TODO: Log Exception.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1079,6 +1079,7 @@ public class Table3D extends Table {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
|
try {
|
||||||
if(null == other) {
|
if(null == other) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1093,6 +1094,10 @@ public class Table3D extends Table {
|
||||||
|
|
||||||
Table3D otherTable = (Table3D)other;
|
Table3D otherTable = (Table3D)other;
|
||||||
|
|
||||||
|
if(!this.getName().equalsIgnoreCase(otherTable.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(! this.xAxis.equals(otherTable.xAxis)) {
|
if(! this.xAxis.equals(otherTable.xAxis)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1121,6 +1126,10 @@ public class Table3D extends Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// TODO: Log Exception.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,9 @@ import java.awt.GridLayout;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.ButtonGroup;
|
import javax.swing.ButtonGroup;
|
||||||
|
@ -157,6 +159,11 @@ public class TableSwitch extends Table {
|
||||||
super.setName(name);
|
super.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return Settings.TABLE_SWITCH;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
super.setDescription(description);
|
super.setDescription(description);
|
||||||
|
@ -208,6 +215,14 @@ public class TableSwitch extends Table {
|
||||||
return new Dimension(width, height);
|
return new Dimension(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ButtonGroup getButtonGroup() {
|
||||||
|
return this.buttonGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, byte[]> getSwitchStates() {
|
||||||
|
return this.switchStates;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void colorize() {
|
public void colorize() {
|
||||||
}
|
}
|
||||||
|
@ -247,6 +262,100 @@ public class TableSwitch extends Table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
// TODO: Validate DTC equals.
|
||||||
|
try {
|
||||||
|
if(null == other) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(other == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(other instanceof TableSwitch)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TableSwitch otherTable = (TableSwitch)other;
|
||||||
|
|
||||||
|
if(!this.getName().equalsIgnoreCase(otherTable.getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.getDataSize() != otherTable.getDataSize()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.getSwitchStates() == otherTable.getSwitchStates()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare Map Keys
|
||||||
|
Set<String> keys = new HashSet<String>(this.getSwitchStates().keySet());
|
||||||
|
Set<String> otherKeys = new HashSet<String>(otherTable.getSwitchStates().keySet());
|
||||||
|
|
||||||
|
if(keys.size() != otherKeys.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!keys.containsAll(otherKeys)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare Map Values.
|
||||||
|
Set<byte[]> values = new HashSet<byte[]>(this.getSwitchStates().values());
|
||||||
|
Set<byte[]> otherValues = new HashSet<byte[]>(otherTable.getSwitchStates().values());
|
||||||
|
if(values.equals(otherValues)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare DTC. Is there a better way to compare the DTC?
|
||||||
|
for(String key : keys) {
|
||||||
|
JRadioButton button = getButtonByText(this.getButtonGroup(), key);
|
||||||
|
JRadioButton otherButton = getButtonByText(otherTable.getButtonGroup(), key);
|
||||||
|
|
||||||
|
if(button.isSelected() != otherButton.isSelected()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// TODO: Log Exception.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean fillCompareValues() {
|
||||||
|
return true; // Do Nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshCellDisplay() {
|
||||||
|
if(!(compareTable instanceof TableSwitch)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TableSwitch otherTable = (TableSwitch)compareTable;
|
||||||
|
|
||||||
|
Set<String> keys = new HashSet<String>(this.getSwitchStates().keySet());
|
||||||
|
|
||||||
|
// Compare DTC.
|
||||||
|
for(String key : keys) {
|
||||||
|
JRadioButton button = getButtonByText(this.getButtonGroup(), key);
|
||||||
|
JRadioButton otherButton = getButtonByText(otherTable.getButtonGroup(), key);
|
||||||
|
|
||||||
|
if(compareDisplay == Settings.COMPARE_DISPLAY_OFF || button.isSelected() == otherButton.isSelected()) {
|
||||||
|
button.setForeground(Settings.TABLESWITCH_DEFAULT_COLOR);
|
||||||
|
} else {
|
||||||
|
button.setForeground(Settings.TABLESWITCH_DIFFERENT_COLOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// returns the selected radio button in the specified group
|
// returns the selected radio button in the specified group
|
||||||
private static JRadioButton getSelectedButton(ButtonGroup group) {
|
private static JRadioButton getSelectedButton(ButtonGroup group) {
|
||||||
for (Enumeration<AbstractButton> e = group.getElements(); e.hasMoreElements(); ) {
|
for (Enumeration<AbstractButton> e = group.getElements(); e.hasMoreElements(); ) {
|
||||||
|
|
|
@ -80,6 +80,7 @@ public class TableMenuBar extends JMenuBar implements ActionListener {
|
||||||
initFileMenu();
|
initFileMenu();
|
||||||
initEditMenu();
|
initEditMenu();
|
||||||
initViewMenu();
|
initViewMenu();
|
||||||
|
applyTableTypeRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshTableMenuBar() {
|
public void refreshTableMenuBar() {
|
||||||
|
@ -239,6 +240,18 @@ 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) {
|
||||||
|
editMenu.setEnabled(false);
|
||||||
|
compareOriginal.setEnabled(false);
|
||||||
|
comparePercent.setEnabled(false);
|
||||||
|
compareAbsolute.setEnabled(false);
|
||||||
|
compareToOriginal.setEnabled(false);
|
||||||
|
compareToBin.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshSimilarOpenTables() {
|
private void refreshSimilarOpenTables() {
|
||||||
similarOpenTables.removeAll();
|
similarOpenTables.removeAll();
|
||||||
String currentTableName = table.getName();
|
String currentTableName = table.getName();
|
||||||
|
|
Loading…
Reference in New Issue