mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-19 01:44:44 -04:00
fixed a bug is the DataEditor
This commit is contained in:
parent
0674855221
commit
b970f07b04
@ -205,13 +205,23 @@ public class DataField {
|
|||||||
*
|
*
|
||||||
* @param addr the address which value has changed
|
* @param addr the address which value has changed
|
||||||
*/
|
*/
|
||||||
public void fireChanged(int addr) {
|
private void fireChanged(int addr) {
|
||||||
synchronized (listeners) {
|
synchronized (listeners) {
|
||||||
for (DataListener l : listeners)
|
for (DataListener l : listeners)
|
||||||
l.valueChanged(addr);
|
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
|
* The listener interface
|
||||||
*/
|
*/
|
||||||
|
@ -59,11 +59,7 @@ public class DataEditor extends JDialog {
|
|||||||
else
|
else
|
||||||
localDataField = new DataField(dataField, size);
|
localDataField = new DataField(dataField, size);
|
||||||
|
|
||||||
int cols = 16;
|
final int cols = calcCols(size, dataBits);
|
||||||
if (size <= 16) cols = 1;
|
|
||||||
else if (size <= 128) cols = 8;
|
|
||||||
|
|
||||||
if (dataBits > 20 && cols == 16) cols = 8;
|
|
||||||
|
|
||||||
int tableWidth = 0;
|
int tableWidth = 0;
|
||||||
MyTableModel dm = new MyTableModel(this.localDataField, cols, modelSync);
|
MyTableModel dm = new MyTableModel(this.localDataField, cols, modelSync);
|
||||||
@ -115,7 +111,7 @@ public class DataEditor extends JDialog {
|
|||||||
getContentPane().add(buttons, BorderLayout.SOUTH);
|
getContentPane().add(buttons, BorderLayout.SOUTH);
|
||||||
|
|
||||||
JMenuBar menuBar = new JMenuBar();
|
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")) {
|
data.add(new ToolTipAction(Lang.get("btn_clearData")) {
|
||||||
@Override
|
@Override
|
||||||
@ -134,7 +130,8 @@ public class DataEditor extends JDialog {
|
|||||||
if (fc.showOpenDialog(DataEditor.this) == JFileChooser.APPROVE_OPTION) {
|
if (fc.showOpenDialog(DataEditor.this) == JFileChooser.APPROVE_OPTION) {
|
||||||
fileName = fc.getSelectedFile();
|
fileName = fc.getSelectedFile();
|
||||||
try {
|
try {
|
||||||
localDataField = new DataField(fc.getSelectedFile());
|
localDataField.setDataFrom(new DataField(fc.getSelectedFile()));
|
||||||
|
dm.fireEvent(new TableModelEvent(dm));
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
new ErrorMessage(Lang.get("msg_errorReadingFile")).addCause(e1).show(DataEditor.this);
|
new ErrorMessage(Lang.get("msg_errorReadingFile")).addCause(e1).show(DataEditor.this);
|
||||||
}
|
}
|
||||||
@ -170,6 +167,15 @@ public class DataEditor extends JDialog {
|
|||||||
setLocationRelativeTo(parent);
|
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
|
* @return the data field
|
||||||
*/
|
*/
|
||||||
|
@ -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>
|
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">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_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>
|
<string name="msg_errorOpeningDocumentation">Fehler beim Öffnen einer PDF-Datei!</string>
|
||||||
|
|
||||||
|
@ -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>
|
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">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_labelPins_tt">Set a label to all inputs and outputs without a label.</string>
|
||||||
<string name="menu_data">Data</string>
|
|
||||||
|
|
||||||
|
|
||||||
<string name="message"><h1>Digital</h1>A simple simulator for digital circuits.
|
<string name="message"><h1>Digital</h1>A simple simulator for digital circuits.
|
||||||
@ -1322,7 +1321,7 @@ an <a href="https://github.com/hneemann/Digital/issues/new?labels=enhanc
|
|||||||
Start export anyway?</string>
|
Start export anyway?</string>
|
||||||
<string name="msg_circuitIsRequired">To create a hardware description, a circuit must first be created and analyzed.
|
<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>
|
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="msg_noData">no data</string>
|
||||||
|
|
||||||
<string name="ok">Ok</string>
|
<string name="ok">Ok</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user