Step in Button zum refresehen der Table
This commit is contained in:
@ -13,23 +13,71 @@ import java.io.BufferedReader;
|
||||
|
||||
import java.io.FileReader;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextArea;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class Controller_FileSelect {
|
||||
|
||||
private int [] prog;
|
||||
|
||||
|
||||
@FXML
|
||||
private Button stepintoButton;
|
||||
|
||||
|
||||
@FXML
|
||||
private TableView<Table.DataEntry> tableView;
|
||||
|
||||
@FXML
|
||||
private TextArea lstContentLabel;
|
||||
|
||||
@FXML
|
||||
private Label pclLabel;
|
||||
|
||||
@FXML
|
||||
private Label statusLabel;
|
||||
|
||||
@FXML
|
||||
private Label fsrLabel;
|
||||
|
||||
@FXML
|
||||
private Label pclathLabel;
|
||||
|
||||
@FXML
|
||||
private Label intconLabel;
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private void stepintoButton(ActionEvent event) throws IOException {
|
||||
Commands.decode(prog[DataRegister.getPC()]);
|
||||
DataRegister.increasePC();
|
||||
Table.refresh();
|
||||
Stage stage = (Stage) stepintoButton.getScene().getWindow();
|
||||
CreateWindow.refreshTable(stage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
protected void selectFileLST(ActionEvent event){
|
||||
File selectedFile = chooseLSTFile();
|
||||
if(selectedFile != null){
|
||||
prog = ParseFile.parseDatei(selectedFile.getAbsolutePath());
|
||||
System.out.println(Arrays.toString(Arrays.stream(prog).toArray()));
|
||||
displayLSTFileContent(selectedFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private File chooseLSTFile() {
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
@ -17,96 +14,46 @@ import java.io.IOException;
|
||||
|
||||
public class CreateWindow extends Application {
|
||||
|
||||
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten
|
||||
private static VBox table;
|
||||
public static GridPane grid = new GridPane();
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
// Erstelle eine Instanz der DataRegister-Klasse
|
||||
|
||||
public void start(Stage primaryStage) throws IOException{
|
||||
DataRegister.initDataRegister();
|
||||
|
||||
// Erstelle eine TableView für die Datenanzeige
|
||||
TableView<DataEntry[]> tableView = new TableView<>();
|
||||
|
||||
// Erstelle Spalten für die TableView
|
||||
for (int i = 0; i < NUM_COLUMNS; i++) {
|
||||
TableColumn<DataEntry[], String> column = new TableColumn<>("0" + (i + 1));
|
||||
final int columnIndex = i;
|
||||
column.setCellValueFactory(cellData -> {
|
||||
if (cellData.getValue() != null && cellData.getValue().length > columnIndex) {
|
||||
return new SimpleStringProperty(cellData.getValue()[columnIndex].getValue());
|
||||
} else {
|
||||
return new SimpleStringProperty("");
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
}
|
||||
|
||||
// Fülle die TableView mit Daten aus dem Array
|
||||
int numRows = (int) Math.ceil((double) DataRegister.getDataRegister().length / NUM_COLUMNS);
|
||||
for (int row = 0; row < numRows; row++) {
|
||||
DataEntry[] rowData = new DataEntry[NUM_COLUMNS];
|
||||
for (int col = 0; col < NUM_COLUMNS; col++) {
|
||||
int index = row * NUM_COLUMNS + col;
|
||||
if (index < DataRegister.getDataRegister().length) {
|
||||
String address = "0x" + Integer.toHexString(index).toUpperCase();
|
||||
String value = "0x" + Integer.toHexString(DataRegister.getDataRegister()[index]).toUpperCase();
|
||||
rowData[col] = new DataEntry(address, value);
|
||||
} else {
|
||||
rowData[col] = new DataEntry("", "");
|
||||
}
|
||||
}
|
||||
tableView.getItems().add(rowData);
|
||||
}
|
||||
|
||||
// Erstelle Labels für die Spezialregister
|
||||
Label pclLabel = new Label("PCL: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getPCL())).toUpperCase());
|
||||
Label statusLabel = new Label("STATUS: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getSTATUS())).toUpperCase());
|
||||
Label fsrLabel = new Label("FSR: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getFSR())).toUpperCase());
|
||||
Label pclathLabel = new Label("PCLATH: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getPCLATH())).toUpperCase());
|
||||
Label intconLabel = new Label("INTCON: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getINTCON())).toUpperCase());
|
||||
table = Table.refresh();
|
||||
|
||||
FXMLLoader codewindow = new FXMLLoader(CreateWindow.class.getResource("frontend.fxml"));
|
||||
Parent code = codewindow.load();
|
||||
|
||||
|
||||
|
||||
// Erstelle einen VBox, um die TableView und Labels anzuzeigen
|
||||
VBox table = new VBox();
|
||||
table.getChildren().addAll(tableView, pclLabel, statusLabel, fsrLabel, pclathLabel, intconLabel);
|
||||
|
||||
GridPane grid = new GridPane();
|
||||
|
||||
grid.add(table, 0, 1);
|
||||
grid.add(code, 1, 1);
|
||||
grid.add(table, 1, 1);
|
||||
grid.add(code, 0, 1);
|
||||
|
||||
grid.relocate(0, 0);
|
||||
|
||||
Scene scene = new Scene(grid, 1600, 800);
|
||||
Scene scene = new Scene(grid, 1800, 800);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setTitle("Simulator");
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
static void main(String[] args) {
|
||||
|
||||
launch(args);
|
||||
|
||||
}
|
||||
|
||||
// Hilfsklasse für die Datenanzeige in der TableView
|
||||
public static class DataEntry {
|
||||
private final String address;
|
||||
private final String value;
|
||||
|
||||
public DataEntry(String address, String value) {
|
||||
this.address = address;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public static void refreshTable(Stage stage) throws IOException {
|
||||
grid.getChildren().remove(table);
|
||||
table= Table.refresh();
|
||||
grid.add(table, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
114
src/main/java/fabrik/simulator/pic16f84/Table.java
Normal file
114
src/main/java/fabrik/simulator/pic16f84/Table.java
Normal file
@ -0,0 +1,114 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static javafx.application.Application.launch;
|
||||
|
||||
public class Table {
|
||||
|
||||
|
||||
//Hier wird die Tabelle aktualisiert
|
||||
//Tabelle aktualisieren
|
||||
|
||||
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten
|
||||
private static final double TABLE_WIDTH = 310; // Breite der TableView
|
||||
|
||||
|
||||
|
||||
public static VBox refresh(){
|
||||
// Erstelle eine Instanz der DataRegister-Klasse
|
||||
|
||||
|
||||
// Erstelle eine TableView für die Datenanzeige
|
||||
TableView<DataEntry[]> tableView = new TableView<>();
|
||||
tableView.setPrefWidth(TABLE_WIDTH);
|
||||
|
||||
|
||||
|
||||
|
||||
// Erstelle Spalten für die TableView
|
||||
for (int i = 0; i < NUM_COLUMNS; i++) {
|
||||
TableColumn<DataEntry[], String> column = new TableColumn<>("0" + (i));
|
||||
final int columnIndex = i;
|
||||
column.setCellValueFactory(cellData -> {
|
||||
if (cellData.getValue() != null && cellData.getValue().length > columnIndex) {
|
||||
return new SimpleStringProperty(cellData.getValue()[columnIndex].getValue());
|
||||
} else {
|
||||
return new SimpleStringProperty("");
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
}
|
||||
|
||||
// Fülle die TableView mit Daten aus dem Array
|
||||
int numRows = (int) Math.ceil((double) DataRegister.getDataRegister().length / NUM_COLUMNS);
|
||||
for (int row = 0; row < numRows; row++) {
|
||||
DataEntry[] rowData = new DataEntry[NUM_COLUMNS];
|
||||
for (int col = 0; col < NUM_COLUMNS; col++) {
|
||||
int index = row * NUM_COLUMNS + col;
|
||||
if (index < DataRegister.getDataRegister().length) {
|
||||
String address = "0x" + Integer.toHexString(index).toUpperCase();
|
||||
String value = "0x" + Integer.toHexString(DataRegister.getDataRegister()[index]).toUpperCase();
|
||||
rowData[col] = new DataEntry(address, value);
|
||||
} else {
|
||||
rowData[col] = new DataEntry("", "");
|
||||
}
|
||||
}
|
||||
tableView.getItems().add(rowData);
|
||||
}
|
||||
|
||||
// Erstelle Labels für die Spezialregister
|
||||
Label pclLabel = new Label("PCL: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getPCL())).toUpperCase());
|
||||
Label statusLabel = new Label("STATUS: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getSTATUS())).toUpperCase());
|
||||
Label fsrLabel = new Label("FSR: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getFSR())).toUpperCase());
|
||||
Label pclathLabel = new Label("PCLATH: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getPCLATH())).toUpperCase());
|
||||
Label intconLabel = new Label("INTCON: 0x" + Integer.toHexString(DataRegister.getRegister(DataRegister.getINTCON())).toUpperCase());
|
||||
|
||||
|
||||
|
||||
|
||||
// Erstelle einen VBox, um die TableView und Labels anzuzeigen
|
||||
VBox table = new VBox();
|
||||
table.getChildren().addAll(tableView, pclLabel, statusLabel, fsrLabel, pclathLabel, intconLabel);
|
||||
VBox.setMargin(tableView, new Insets(0, 0, 0, 0));
|
||||
|
||||
return table;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
// Hilfsklasse für die Datenanzeige in der TableView
|
||||
public static class DataEntry {
|
||||
private final String address;
|
||||
private final String value;
|
||||
|
||||
public DataEntry(String address, String value) {
|
||||
this.address = address;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -15,7 +15,7 @@
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Close" />
|
||||
<MenuItem mnemonicParsing="false" text="Save" />
|
||||
<MenuItem mnemonicParsing="false" text="Save As...." />
|
||||
<MenuItem mnemonicParsing="false" text="Save As...." />
|
||||
<MenuItem mnemonicParsing="false" text="Revert" />
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Preferences…" />
|
||||
@ -48,11 +48,20 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
|
||||
<TextArea fx:id="lstContentLabel" editable="false" layoutX="684.0" layoutY="27.0" wrapText="true" />
|
||||
<TextArea fx:id="lstContentLabel" editable="false" layoutX="282.0" layoutY="498.0" prefHeight="189.0" prefWidth="547.0" wrapText="true"/>
|
||||
<Button fx:id="stepintoButton" layoutX="111.0" layoutY="321.0" mnemonicParsing="false" text="Step IN" onAction="#stepintoButton" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
|
||||
</VBox>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user