Fix für das Datum in XML
parent
dc8c10b552
commit
950a4a9078
Binary file not shown.
Binary file not shown.
260
flights.xml
260
flights.xml
|
@ -8,274 +8,36 @@
|
|||
<double>2.0</double>
|
||||
</void>
|
||||
<void property="abflugort">
|
||||
<string>ea</string>
|
||||
<string>123</string>
|
||||
</void>
|
||||
<void property="abflugzeit">
|
||||
<string>2</string>
|
||||
</void>
|
||||
<void property="ankunftszeit">
|
||||
<string>2</string>
|
||||
</void>
|
||||
<void property="anzahlLandungen">
|
||||
<int>1</int>
|
||||
</void>
|
||||
<void property="kommentar">
|
||||
<string>2</string>
|
||||
</void>
|
||||
<void property="muster">
|
||||
<string>aed</string>
|
||||
</void>
|
||||
<void property="pilot">
|
||||
<object class="models.Pilot" id="Pilot0">
|
||||
<void property="adresse">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="lizenzen">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>ss</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>ddas</string>
|
||||
</void>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="zertifikate">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>eee</string>
|
||||
</void>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Flight">
|
||||
<void property="TToF">
|
||||
<double>2.0</double>
|
||||
</void>
|
||||
<void property="abflugort">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="abflugzeit">
|
||||
<string>11:00</string>
|
||||
</void>
|
||||
<void property="ankunftszeit">
|
||||
<string>12:00</string>
|
||||
</void>
|
||||
<void property="anzahlLandungen">
|
||||
<int>2</int>
|
||||
</void>
|
||||
<void property="kommentar">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="muster">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="pilot">
|
||||
<object class="models.Pilot" id="Pilot1">
|
||||
<void property="adresse">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="lizenzen">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>ss</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>ddas</string>
|
||||
</void>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="zertifikate">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>eee</string>
|
||||
</void>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Flight">
|
||||
<void property="TToF">
|
||||
<double>123.0</double>
|
||||
</void>
|
||||
<void property="abflugort">
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="abflugzeit">
|
||||
<string>123</string>
|
||||
</void>
|
||||
<void property="ankunftszeit">
|
||||
<string>123</string>
|
||||
</void>
|
||||
<void property="anzahlLandungen">
|
||||
<int>123</int>
|
||||
</void>
|
||||
<void property="kommentar">
|
||||
<string>123</string>
|
||||
</void>
|
||||
<void property="muster">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="nachtflug">
|
||||
<boolean>true</boolean>
|
||||
</void>
|
||||
<void property="pilot">
|
||||
<object class="models.Pilot" id="Pilot2">
|
||||
<void property="adresse">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="lizenzen">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>ss</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>ddas</string>
|
||||
</void>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="zertifikate">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>eee</string>
|
||||
</void>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Flight">
|
||||
<void property="TToF">
|
||||
<double>123.0</double>
|
||||
</void>
|
||||
<void property="abflugort">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="abflugzeit">
|
||||
<string>dsa</string>
|
||||
</void>
|
||||
<void property="ankunftszeit">
|
||||
<string>asda</string>
|
||||
</void>
|
||||
<void property="anzahlLandungen">
|
||||
<int>12</int>
|
||||
</void>
|
||||
<void property="kommentar">
|
||||
<string>123</string>
|
||||
</void>
|
||||
<void property="muster">
|
||||
<string>asda</string>
|
||||
</void>
|
||||
<void property="pilot">
|
||||
<object class="models.Pilot" id="Pilot3">
|
||||
<void property="adresse">
|
||||
<string>asdasdasd</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="lizenzen">
|
||||
<void method="add">
|
||||
<string>124312</string>
|
||||
</void>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="zertifikate">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Flight">
|
||||
<void property="TToF">
|
||||
<double>1.0</double>
|
||||
</void>
|
||||
<void property="abflugort">
|
||||
<string>ea</string>
|
||||
</void>
|
||||
<void property="abflugzeit">
|
||||
<string>11:00</string>
|
||||
</void>
|
||||
<void property="ankunftszeit">
|
||||
<string>12:30</string>
|
||||
<string>14:00</string>
|
||||
</void>
|
||||
<void property="anzahlLandungen">
|
||||
<int>2</int>
|
||||
</void>
|
||||
<void property="datumStr">
|
||||
<string>2024-06-10</string>
|
||||
</void>
|
||||
<void property="kommentar">
|
||||
<string>lol</string>
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<void property="muster">
|
||||
<string>test</string>
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="pilot">
|
||||
<object class="models.Pilot" id="Pilot4">
|
||||
<object class="models.Pilot">
|
||||
<void property="adresse">
|
||||
<string>asdasdasd</string>
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="lizenzen">
|
||||
<void method="add">
|
||||
<string>124312</string>
|
||||
</void>
|
||||
<string>ads</string>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="zertifikate">
|
||||
<void method="add">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
<string>sad</string>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
|
|
26
pilots.xml
26
pilots.xml
|
@ -15,6 +15,32 @@
|
|||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Pilot">
|
||||
<void property="adresse">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>sad</string>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Pilot">
|
||||
<void property="adresse">
|
||||
<string>asdasd</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>23</string>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>adsasd</string>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
|
|
|
@ -11,8 +11,8 @@ import javafx.beans.property.*;
|
|||
public class Flight implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient ObjectProperty<LocalDate> datum;
|
||||
private String datumStr;
|
||||
private String datumStr; // String zur Speicherung des Datums in XML
|
||||
private transient ObjectProperty<LocalDate> datum; // transient, um die direkte Serialization zu vermeiden
|
||||
private StringProperty muster;
|
||||
private StringProperty abflugort;
|
||||
private StringProperty abflugzeit;
|
||||
|
@ -23,6 +23,8 @@ public class Flight implements Serializable {
|
|||
private BooleanProperty nachtflug;
|
||||
private StringProperty kommentar;
|
||||
|
||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
|
||||
// Standardkonstruktor
|
||||
public Flight() {
|
||||
this.datum = new SimpleObjectProperty<>();
|
||||
|
@ -38,17 +40,17 @@ public class Flight implements Serializable {
|
|||
}
|
||||
|
||||
public Flight(LocalDate datum, String muster, String abflugort, String abflugzeit, String ankunftszeit, double tToF, int anzahlLandungen, Pilot pilot, boolean nachtflug, String kommentar) {
|
||||
this.datum = new SimpleObjectProperty<>(datum);
|
||||
this.datumStr = datum.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
this.muster = new SimpleStringProperty(muster);
|
||||
this.abflugort = new SimpleStringProperty(abflugort);
|
||||
this.abflugzeit = new SimpleStringProperty(abflugzeit);
|
||||
this.ankunftszeit = new SimpleStringProperty(ankunftszeit);
|
||||
this.tToF = new SimpleDoubleProperty(tToF);
|
||||
this.anzahlLandungen = new SimpleIntegerProperty(anzahlLandungen);
|
||||
this.pilot = new SimpleObjectProperty<>(pilot);
|
||||
this.nachtflug = new SimpleBooleanProperty(nachtflug);
|
||||
this.kommentar = new SimpleStringProperty(kommentar);
|
||||
this();
|
||||
this.setDatum(datum);
|
||||
this.muster.set(muster);
|
||||
this.abflugort.set(abflugort);
|
||||
this.abflugzeit.set(abflugzeit);
|
||||
this.ankunftszeit.set(ankunftszeit);
|
||||
this.tToF.set(tToF);
|
||||
this.anzahlLandungen.set(anzahlLandungen);
|
||||
this.pilot.set(pilot);
|
||||
this.nachtflug.set(nachtflug);
|
||||
this.kommentar.set(kommentar);
|
||||
}
|
||||
|
||||
public LocalDate getDatum() {
|
||||
|
@ -57,13 +59,22 @@ public class Flight implements Serializable {
|
|||
|
||||
public void setDatum(LocalDate datum) {
|
||||
this.datum.set(datum);
|
||||
this.datumStr = datum.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
this.datumStr = datum != null ? datum.format(formatter) : null;
|
||||
}
|
||||
|
||||
public ObjectProperty<LocalDate> datumProperty() {
|
||||
return datum;
|
||||
}
|
||||
|
||||
public String getDatumStr() {
|
||||
return datumStr;
|
||||
}
|
||||
|
||||
public void setDatumStr(String datumStr) {
|
||||
this.datumStr = datumStr;
|
||||
this.datum.set(datumStr != null ? LocalDate.parse(datumStr, formatter) : null);
|
||||
}
|
||||
|
||||
public String getMuster() {
|
||||
return muster.get();
|
||||
}
|
||||
|
@ -180,5 +191,20 @@ public class Flight implements Serializable {
|
|||
return "Keine Pilotinformationen verfügbar";
|
||||
}
|
||||
|
||||
|
||||
// Custom Serialization
|
||||
private void writeObject(ObjectOutputStream oos) throws IOException {
|
||||
oos.defaultWriteObject();
|
||||
oos.writeObject(datum.get() != null ? datum.get().format(formatter) : null);
|
||||
}
|
||||
|
||||
// Custom Deserialization
|
||||
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
|
||||
ois.defaultReadObject();
|
||||
String datumStr = (String) ois.readObject();
|
||||
if (datumStr != null) {
|
||||
this.datum = new SimpleObjectProperty<>(LocalDate.parse(datumStr, formatter));
|
||||
} else {
|
||||
this.datum = new SimpleObjectProperty<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,15 @@ import models.Pilots;
|
|||
import utils.XMLHelper;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AddFlightScreen {
|
||||
private Stage stage;
|
||||
private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
|
||||
|
||||
public AddFlightScreen(Stage stage) {
|
||||
this.stage = stage;
|
||||
|
@ -42,25 +46,43 @@ public class AddFlightScreen {
|
|||
datumField.setPromptText("YYYY-MM-DD");
|
||||
musterField.setPromptText("Muster");
|
||||
abflugortField.setPromptText("Abflugort");
|
||||
abflugzeitField.setPromptText("HH:MM");
|
||||
ankunftszeitField.setPromptText("HH:MM");
|
||||
abflugzeitField.setPromptText("HH:mm");
|
||||
ankunftszeitField.setPromptText("HH:mm");
|
||||
tToFField.setPromptText("Flugdauer (Stunden)");
|
||||
anzahlLandungenField.setPromptText("Anzahl der Landungen");
|
||||
kommentarField.setPromptText("Kommentar");
|
||||
|
||||
// Nur numerische Eingaben für Flugdauer und Anzahl der Landungen zulassen
|
||||
tToFField.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue.matches("\\d*\\.?\\d*")) {
|
||||
tToFField.setText(oldValue);
|
||||
}
|
||||
});
|
||||
|
||||
tToFField.setEditable(false);
|
||||
anzahlLandungenField.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue.matches("\\d*")) {
|
||||
anzahlLandungenField.setText(oldValue);
|
||||
}
|
||||
});
|
||||
|
||||
// Validierung und Berechnung der Flugdauer
|
||||
abflugzeitField.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue) {
|
||||
if (!isValidTime(abflugzeitField.getText())) {
|
||||
abflugzeitField.setStyle("-fx-border-color: red;");
|
||||
} else {
|
||||
abflugzeitField.setStyle(null);
|
||||
calculateFlightDuration(abflugzeitField, ankunftszeitField, tToFField);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ankunftszeitField.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue) {
|
||||
if (!isValidTime(ankunftszeitField.getText())) {
|
||||
ankunftszeitField.setStyle("-fx-border-color: red;");
|
||||
} else {
|
||||
ankunftszeitField.setStyle(null);
|
||||
calculateFlightDuration(abflugzeitField, ankunftszeitField, tToFField);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Laden der Piloten für die Auswahlbox
|
||||
Pilots pilotsData = (Pilots) XMLHelper.loadFromXML("pilots.xml");
|
||||
List<Pilot> pilotList = pilotsData != null ? pilotsData.getPilots() : new ArrayList<>();
|
||||
|
@ -71,8 +93,9 @@ public class AddFlightScreen {
|
|||
|
||||
Button submitBtn = new Button("Hinzufügen");
|
||||
submitBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
submitBtn.setOnAction(e -> handleAddFlight(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
tToFField, anzahlLandungenField, nachtflugBox.isSelected(), kommentarField, pilotComboBox));
|
||||
submitBtn.setOnAction(
|
||||
e -> handleAddFlight(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
tToFField, anzahlLandungenField, nachtflugBox.isSelected(), kommentarField, pilotComboBox));
|
||||
|
||||
Button backButton = new Button("Zurück");
|
||||
backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
|
@ -104,51 +127,84 @@ public class AddFlightScreen {
|
|||
stage.show();
|
||||
}
|
||||
|
||||
private void handleAddFlight(DatePicker datumField, TextField musterField, TextField abflugortField, TextField abflugzeitField,
|
||||
TextField ankunftszeitField, TextField tToFField, TextField anzahlLandungenField, boolean isNachtflug,
|
||||
TextField kommentarField, ComboBox<Pilot> pilotComboBox) {
|
||||
clearFieldStyles(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, tToFField, anzahlLandungenField, pilotComboBox);
|
||||
|
||||
private void calculateFlightDuration(TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField) {
|
||||
try {
|
||||
if (datumField.getValue() == null) {
|
||||
setErrorStyle(datumField);
|
||||
throw new IllegalArgumentException("Datum ist erforderlich.");
|
||||
LocalTime abflugzeit = LocalTime.parse(abflugzeitField.getText(), timeFormatter);
|
||||
LocalTime ankunftszeit = LocalTime.parse(ankunftszeitField.getText(), timeFormatter);
|
||||
long durationInMinutes = java.time.Duration.between(abflugzeit, ankunftszeit).toMinutes();
|
||||
if (durationInMinutes < 0) {
|
||||
durationInMinutes += 24 * 60; // Falls über Mitternacht
|
||||
}
|
||||
if (musterField.getText().isEmpty()) {
|
||||
setErrorStyle(musterField);
|
||||
throw new IllegalArgumentException("Muster ist erforderlich.");
|
||||
}
|
||||
if (abflugortField.getText().isEmpty()) {
|
||||
setErrorStyle(abflugortField);
|
||||
throw new IllegalArgumentException("Abflugort ist erforderlich.");
|
||||
}
|
||||
if (abflugzeitField.getText().isEmpty()) {
|
||||
setErrorStyle(abflugzeitField);
|
||||
throw new IllegalArgumentException("Abflugzeit ist erforderlich.");
|
||||
}
|
||||
if (ankunftszeitField.getText().isEmpty()) {
|
||||
setErrorStyle(ankunftszeitField);
|
||||
throw new IllegalArgumentException("Ankunftszeit ist erforderlich.");
|
||||
}
|
||||
if (tToFField.getText().isEmpty()) {
|
||||
setErrorStyle(tToFField);
|
||||
throw new IllegalArgumentException("Flugdauer ist erforderlich.");
|
||||
}
|
||||
if (anzahlLandungenField.getText().isEmpty()) {
|
||||
setErrorStyle(anzahlLandungenField);
|
||||
throw new IllegalArgumentException("Anzahl der Landungen ist erforderlich.");
|
||||
}
|
||||
if (pilotComboBox.getValue() == null) {
|
||||
setErrorStyle(pilotComboBox);
|
||||
throw new IllegalArgumentException("Pilot ist erforderlich.");
|
||||
double durationInHours = durationInMinutes / 60.0;
|
||||
String formattedDuration = String.format("%.2f", durationInHours);
|
||||
|
||||
tToFField.setText(formattedDuration);
|
||||
} catch (DateTimeParseException e) {
|
||||
tToFField.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidTime(String time) {
|
||||
try {
|
||||
LocalTime.parse(time, timeFormatter);
|
||||
return true;
|
||||
} catch (DateTimeParseException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAddFlight(DatePicker datumField, TextField musterField, TextField abflugortField,
|
||||
TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField,
|
||||
TextField anzahlLandungenField, boolean isNachtflug, TextField kommentarField,
|
||||
ComboBox<Pilot> pilotComboBox) {
|
||||
try {
|
||||
clearFieldStyles(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
tToFField, anzahlLandungenField, kommentarField, pilotComboBox);
|
||||
|
||||
if (datumField.getValue() == null || musterField.getText().isEmpty() || abflugortField.getText().isEmpty()
|
||||
||
|
||||
abflugzeitField.getText().isEmpty() || ankunftszeitField.getText().isEmpty()
|
||||
|| tToFField.getText().isEmpty() ||
|
||||
anzahlLandungenField.getText().isEmpty() || pilotComboBox.getValue() == null) {
|
||||
throw new IllegalArgumentException("Bitte füllen Sie alle Felder aus.");
|
||||
}
|
||||
|
||||
if (!isValidTime(abflugzeitField.getText())) {
|
||||
setErrorStyle(abflugzeitField);
|
||||
throw new IllegalArgumentException("Ungültige Abflugzeit.");
|
||||
}
|
||||
|
||||
if (!isValidTime(ankunftszeitField.getText())) {
|
||||
setErrorStyle(ankunftszeitField);
|
||||
throw new IllegalArgumentException("Ungültige Ankunftszeit.");
|
||||
}
|
||||
|
||||
System.out.println("Flugdauer vor dem Parsen: " + tToFField.getText()); // Debug-Ausgabe
|
||||
double flightDuration;
|
||||
try {
|
||||
// Ersetzen des Kommas durch einen Punkt
|
||||
String flightDurationText = tToFField.getText().replace(",", ".");
|
||||
flightDuration = Double.parseDouble(flightDurationText);
|
||||
} catch (NumberFormatException e) {
|
||||
setErrorStyle(tToFField);
|
||||
throw new IllegalArgumentException("Flugdauer muss eine gültige Zahl sein.");
|
||||
}
|
||||
|
||||
double flightDuration = Double.parseDouble(tToFField.getText());
|
||||
int landings = Integer.parseInt(anzahlLandungenField.getText());
|
||||
|
||||
Flight newFlight = new Flight(datumField.getValue(), musterField.getText(), abflugortField.getText(),
|
||||
abflugzeitField.getText(), ankunftszeitField.getText(), flightDuration, landings,
|
||||
pilotComboBox.getValue(), isNachtflug, kommentarField.getText());
|
||||
Flight newFlight = new Flight();
|
||||
newFlight.setDatum(datumField.getValue()); // Setzen des Datums als LocalDate
|
||||
newFlight.setMuster(musterField.getText());
|
||||
newFlight.setAbflugort(abflugortField.getText());
|
||||
newFlight.setAbflugzeit(abflugzeitField.getText());
|
||||
newFlight.setAnkunftszeit(ankunftszeitField.getText());
|
||||
newFlight.setTToF(flightDuration);
|
||||
newFlight.setAnzahlLandungen(landings);
|
||||
newFlight.setPilot(pilotComboBox.getValue());
|
||||
newFlight.setNachtflug(isNachtflug);
|
||||
newFlight.setKommentar(kommentarField.getText());
|
||||
newFlight.setDatumStr(datumField.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE)); // Setzen des DatumStr
|
||||
|
||||
|
||||
Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml");
|
||||
if (flights == null) {
|
||||
|
@ -159,7 +215,8 @@ public class AddFlightScreen {
|
|||
|
||||
new HomeScreen(stage).display();
|
||||
} catch (NumberFormatException e) {
|
||||
showAlert("Ungültige Eingabe", "Bitte stellen Sie sicher, dass die Flugdauer und die Anzahl der Landungen numerisch sind.");
|
||||
showAlert("Ungültige Eingabe",
|
||||
"Bitte stellen Sie sicher, dass die Flugdauer und die Anzahl der Landungen numerisch sind.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
showAlert("Fehlende Eingabe", e.getMessage());
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue