fixed a bug is the DataEditor

This commit is contained in:
hneemann 2018-02-27 20:39:34 +01:00
parent 0674855221
commit b970f07b04
4 changed files with 25 additions and 11 deletions

View File

@ -205,13 +205,23 @@ public class DataField {
*
* @param addr the address which value has changed
*/
public void fireChanged(int addr) {
private void fireChanged(int addr) {
synchronized (listeners) {
for (DataListener l : listeners)
l.valueChanged(addr);
}
}
/**
* Sets the data from the given data field
*
* @param dataField the data to set to this data field
*/
public void setDataFrom(DataField dataField) {
data = Arrays.copyOf(dataField.data, size);
fireChanged(-1);
}
/**
* The listener interface
*/

View File

@ -59,11 +59,7 @@ public class DataEditor extends JDialog {
else
localDataField = new DataField(dataField, size);
int cols = 16;
if (size <= 16) cols = 1;
else if (size <= 128) cols = 8;
if (dataBits > 20 && cols == 16) cols = 8;
final int cols = calcCols(size, dataBits);
int tableWidth = 0;
MyTableModel dm = new MyTableModel(this.localDataField, cols, modelSync);
@ -115,7 +111,7 @@ public class DataEditor extends JDialog {
getContentPane().add(buttons, BorderLayout.SOUTH);
JMenuBar menuBar = new JMenuBar();
JMenu data = new JMenu(Lang.get("menu_data"));
JMenu data = new JMenu(Lang.get("menu_file"));
data.add(new ToolTipAction(Lang.get("btn_clearData")) {
@Override
@ -134,7 +130,8 @@ public class DataEditor extends JDialog {
if (fc.showOpenDialog(DataEditor.this) == JFileChooser.APPROVE_OPTION) {
fileName = fc.getSelectedFile();
try {
localDataField = new DataField(fc.getSelectedFile());
localDataField.setDataFrom(new DataField(fc.getSelectedFile()));
dm.fireEvent(new TableModelEvent(dm));
} catch (IOException e1) {
new ErrorMessage(Lang.get("msg_errorReadingFile")).addCause(e1).show(DataEditor.this);
}
@ -170,6 +167,15 @@ public class DataEditor extends JDialog {
setLocationRelativeTo(parent);
}
private int calcCols(int size, int dataBits) {
int cols = 16;
if (size <= 16) cols = 1;
else if (size <= 128) cols = 8;
if (dataBits > 20 && cols == 16) cols = 8;
return cols;
}
/**
* @return the data field
*/

View File

@ -1243,7 +1243,6 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
Die ZIP-Datei enthält damit alle Dateien, die für den Betrieb der Schaltung erforderlich sind.</string>
<string name="menu_labelPins">Ein- und Ausgänge benennen</string>
<string name="menu_labelPins_tt">Für alle unbenannten Ein- und Ausgänge eine Bezeichnung setzen.</string>
<string name="menu_data">Daten</string>
<string name="msg_errorOpeningDocumentation">Fehler beim Öffnen einer PDF-Datei!</string>

View File

@ -1234,7 +1234,6 @@ The names of the variables may not be unique.</string>
The ZIP file thus contains all the files that are necessary for the operation of the circuit.</string>
<string name="menu_labelPins">Label Inputs and Outputs</string>
<string name="menu_labelPins_tt">Set a label to all inputs and outputs without a label.</string>
<string name="menu_data">Data</string>
<string name="message">&lt;h1&gt;Digital&lt;/h1&gt;A simple simulator for digital circuits.
@ -1322,7 +1321,7 @@ an &lt;a href=&quot;https://github.com/hneemann/Digital/issues/new?labels=enhanc
Start export anyway?</string>
<string name="msg_circuitIsRequired">To create a hardware description, a circuit must first be created and analyzed.
A standalone truth table can not be used to generate a hardware description.</string>
<string name="win_romDialog">Used ROM's</string>
<string name="win_romDialog">Included ROM's</string>
<string name="msg_noData">no data</string>
<string name="ok">Ok</string>