Zeilen
This commit is contained in:
@ -31,6 +31,8 @@ import java.util.Objects;
|
||||
public class Controller_Frontend {
|
||||
|
||||
private int [] prog;
|
||||
private int [][] read;
|
||||
private int [] ind;
|
||||
|
||||
|
||||
@FXML
|
||||
@ -74,57 +76,14 @@ public class Controller_Frontend {
|
||||
|
||||
@FXML
|
||||
private void autoRun(ActionEvent event) throws IOException {
|
||||
if (lstContentListView.getItems().isEmpty()) {
|
||||
// Datei ist nicht geladen oder leer
|
||||
return;
|
||||
}
|
||||
|
||||
// Aktuelle Zeile abrufen
|
||||
int currentIndex = lstContentListView.getSelectionModel().getSelectedIndex();
|
||||
currentIndex = (currentIndex == -1) ? 0 : currentIndex + 1;
|
||||
|
||||
// Durch das gesamte Programm laufen
|
||||
while (currentIndex < lstContentListView.getItems().size()) {
|
||||
// Scrollen zur ausgewählten Zeile
|
||||
lstContentListView.scrollTo(currentIndex);
|
||||
|
||||
// CSS-Stil nur auf die Zellen der ausgewählten Zeile anwenden
|
||||
String selectedRowStyle = "-fx-control-inner-background: red;";
|
||||
int finalCurrentIndex = currentIndex;
|
||||
lstContentListView.setCellFactory(column -> {
|
||||
return new ListCell<String>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
setText(item);
|
||||
if (getIndex() == finalCurrentIndex) {
|
||||
setStyle(selectedRowStyle);
|
||||
} else {
|
||||
setStyle(""); // Zurücksetzen des Stils für andere Zellen
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// Befehle ausführen
|
||||
Commands.decode(prog[DataRegister.getPC()]);
|
||||
DataRegister.increasePC();
|
||||
Table.refresh();
|
||||
Stage stage = (Stage) autoRunButton.getScene().getWindow();
|
||||
CreateWindow.refreshTable(stage);
|
||||
|
||||
|
||||
while (DataRegister.getPC() < prog.length) {
|
||||
stepintoButton(event);
|
||||
try {
|
||||
Thread.sleep(500); // Millisekunden
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
currentIndex++;
|
||||
}
|
||||
|
||||
// Wenn das Ende der Datei erreicht ist, zeige eine Meldung an
|
||||
System.out.println("End of file reached.");
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -135,45 +94,27 @@ public class Controller_Frontend {
|
||||
}
|
||||
|
||||
// Aktuelle Zeile abrufen
|
||||
int currentIndex = lstContentListView.getSelectionModel().getSelectedIndex();
|
||||
|
||||
// Wenn keine Zeile ausgewählt ist, starte von der ersten Zeile
|
||||
if (currentIndex == -1) {
|
||||
currentIndex = 1;
|
||||
} else {
|
||||
// Gehe zur nächsten Zeile
|
||||
currentIndex++;
|
||||
}
|
||||
|
||||
// Überprüfen, ob currentIndex innerhalb der Grenzen liegt
|
||||
if (currentIndex >= lstContentListView.getItems().size()) {
|
||||
// Wenn das Ende der Datei erreicht ist, zeige eine Meldung an
|
||||
System.out.println("End of file reached.");
|
||||
return;
|
||||
}
|
||||
int currentIndex = ind[DataRegister.getPC()];
|
||||
|
||||
// Scrollen zur ausgewählten Zeile
|
||||
lstContentListView.scrollTo(currentIndex);
|
||||
lstContentListView.scrollTo(currentIndex -2);
|
||||
|
||||
// Zeile auswählen
|
||||
lstContentListView.getSelectionModel().clearSelection();
|
||||
lstContentListView.getSelectionModel().select(currentIndex);
|
||||
|
||||
String selectedRowStyle = "-fx-control-inner-background: red;";
|
||||
int finalCurrentIndex = currentIndex + 1;
|
||||
lstContentListView.setCellFactory(column -> {
|
||||
return new ListCell<String>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
setText(item);
|
||||
if (getIndex() == finalCurrentIndex) {
|
||||
setStyle(selectedRowStyle);
|
||||
} else {
|
||||
setStyle("");
|
||||
}
|
||||
lstContentListView.setCellFactory(column -> new ListCell<String>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
setText(item);
|
||||
if (getIndex() == currentIndex) {
|
||||
setStyle(selectedRowStyle);
|
||||
} else {
|
||||
setStyle("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Befehle ausführen
|
||||
@ -182,6 +123,7 @@ public class Controller_Frontend {
|
||||
Table.refresh();
|
||||
Stage stage = (Stage) stepintoButton.getScene().getWindow();
|
||||
CreateWindow.refreshTable(stage);
|
||||
IOPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
|
||||
}
|
||||
|
||||
|
||||
@ -189,7 +131,9 @@ public class Controller_Frontend {
|
||||
protected void selectFileLST(ActionEvent event){
|
||||
File selectedFile = chooseLSTFile();
|
||||
if(selectedFile != null){
|
||||
prog = ParseFile.parseDatei(selectedFile.getAbsolutePath());
|
||||
read = ParseFile.parseDatei(selectedFile.getAbsolutePath());
|
||||
prog = read [0];
|
||||
ind = read[1];
|
||||
System.out.println(Arrays.toString(Arrays.stream(prog).toArray()));
|
||||
displayLSTFileContent(selectedFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user