Fixed BitwiseSwitch not closing. Added better error messages for logger definition

This commit is contained in:
Robin 2021-10-01 19:12:23 +02:00
parent b500baf100
commit c20afa585b
9 changed files with 50 additions and 41 deletions

View File

@ -16,6 +16,7 @@ COMPLETE = Complete ...
READY = Ready ...
YES = Yes
NO = No
LOGGERDEFERROR = Error loading definition:
LOGGERDEFNOTCFG = Logger definition not configured.\nGo online to download the latest definition file?
LOGGERCONFIG = Logger Configuration
CFGEDFSMENU = The Logger definition file needs to be configured before connecting to the ECU.\nMenu: Settings > Logger Definition Location ...\nOnce configured, restart the Logger application.

View File

@ -593,14 +593,26 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
LOGGER.info(loadResult);
} catch (ConfigurationException cfe) {
reportError(cfe);
showMissingConfigDialog();
showErrorConfigDialog(cfe);
}
catch (Exception e) {
reportError(e);
}
}
}
private void showErrorConfigDialog(Exception e) {
Object[] options = {"OK"};
showOptionDialog(this,
rb.getString("LOGGERDEFERROR") + e.getMessage(),
rb.getString("LOGGERCONFIG"),
DEFAULT_OPTION,
ERROR_MESSAGE,
null,
options,
options[0]);
}
private void showMissingConfigDialog() {
Object[] options = {rb.getString("YES"), rb.getString("NO")};
int answer = showOptionDialog(this,

View File

@ -136,7 +136,7 @@ public final class EcuDataLoaderImpl implements EcuDataLoader {
} finally {
inputStream.close();
}
} catch (FileNotFoundException fnfe) {
}/* catch (FileNotFoundException fnfe) {
throw new ConfigurationException(MessageFormat.format(
rb.getString("LOGFNF"), loggerConfigFilePath));
} catch (SAXParseException spe) {
@ -144,7 +144,7 @@ public final class EcuDataLoaderImpl implements EcuDataLoader {
// unzip the defs that a better error message is in order
throw new ConfigurationException(MessageFormat.format(
rb.getString("UNZIPLOG"), loggerConfigFilePath));
} catch (Exception e) {
} */catch (Exception e) {
throw new ConfigurationException(e);
}

View File

@ -66,7 +66,6 @@ public class DataCell {
if (st.hasMoreTokens()) {
this.staticText = st.nextToken();
}
table.setStaticDataTable(true);
}
public DataCell(Table table, int index, Rom rom) {

View File

@ -103,7 +103,19 @@ public abstract class Table implements Serializable {
public DataCell[] getData() {
return data;
}
public void addStaticDataCell(String s) {
setStaticDataTable(true);
DataCell c = new DataCell(this, s, null);
for(int i = 0; i < data.length; i++) {
if(data[i] == null) {
data[i] = c;
break;
}
}
}
//Cleans up all references to avoid data leaks
public void clearData() {

View File

@ -55,18 +55,7 @@ public class Table1D extends Table {
public byte[] saveFile(byte[] binData) {
return binData;
}
public void addStaticDataCell(String s) {
DataCell c = new DataCell(this, s, null);
for(int i = 0; i < data.length; i++) {
if(data[i] == null) {
data[i] = c;
break;
}
}
}
@Override
public StringBuffer getTableAsString() {
if(isStaticDataTable()) {

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2020 RomRaider.com
* Copyright (C) 2006-2021 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
@ -19,7 +19,6 @@
package com.romraider.maps;
import java.awt.GridLayout;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@ -30,9 +29,6 @@ import java.util.Map;
import java.util.Map.Entry;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.romraider.util.ByteUtil;
public class TableBitwiseSwitch extends Table {
@ -58,11 +54,13 @@ public class TableBitwiseSwitch extends Table {
bits_array[((dataSize - 1 - i) *8)+ j] = byte_values[7-j];
}
}
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
radioPanel.add(new JLabel(" " + getName()));
}
//Cleans up all references to avoid data leaks
public void clearData() {
controlBits.clear();
}
public Map<String, Integer> getControlBits() {
return controlBits;
}

View File

@ -1,6 +1,6 @@
/*
* RomRaider Open-Source Tuning, Logging and Reflashing
* Copyright (C) 2006-2020 RomRaider.com
* Copyright (C) 2006-2021 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
@ -45,7 +45,6 @@ public class TableBitwiseSwitchView extends TableView {
private ArrayList<JCheckBox> checkboxes;
private TableBitwiseSwitch table;
public TableBitwiseSwitchView(TableBitwiseSwitch table) {
super(table);
this.table = table;
@ -56,8 +55,7 @@ public class TableBitwiseSwitchView extends TableView {
}
@Override
public void populateTableVisual()
throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
public void populateTableVisual() {
int maxBitPosition = ((table.getDataSize() * 8) - 1);
JPanel radioPanel = new JPanel(new GridLayout(0, 1));
radioPanel.add(new JLabel(" " + getName()));
@ -65,7 +63,7 @@ public class TableBitwiseSwitchView extends TableView {
for (Entry<String, Integer> entry : TableBitwiseSwitch.sortByValue(table.getControlBits()).entrySet()) {
if (entry.getValue() > maxBitPosition) {
String mismatch = MessageFormat.format(
rb.getString("OUTOFRANGE"), super.getName());
rb.getString("OUTOFRANGE"), table.getName());
showMessageDialog(this, mismatch,
rb.getString("DEFERROR"), ERROR_MESSAGE);
break;

View File

@ -601,8 +601,6 @@ public abstract class TableView extends JPanel implements Serializable {
return new Dimension(width, height);
}
public void startHighlight(int x, int y) {
this.highlightBeginY = y;
this.highlightBeginX = x;
@ -896,14 +894,16 @@ public abstract class TableView extends JPanel implements Serializable {
public void updateTableLabel() {
if(null == table.name || table.name.isEmpty()) {
;// Do not update label.
} else if(null == table.getCurrentScale () || "0x" == table.getCurrentScale().getUnit()) {
// static or no scale exists.
tableLabel.setText(getName());
} else {
tableLabel.setText(getName() + " (" + table.getCurrentScale().getUnit() + ")");
}
if(tableLabel != null) {
if(null == table.name || table.name.isEmpty()) {
;// Do not update label.
} else if(null == table.getCurrentScale () || "0x" == table.getCurrentScale().getUnit()) {
// static or no scale exists.
tableLabel.setText(getName());
} else {
tableLabel.setText(getName() + " (" + table.getCurrentScale().getUnit() + ")");
}
}
}
public String getName() {