Einige änderungen am aussehen und Funktionen
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,22 @@
|
|||
.root {
|
||||
-fx-font-family: 'Arial';
|
||||
}
|
||||
|
||||
.button {
|
||||
-fx-background-color: #000000;
|
||||
-fx-text-fill: #FFFFFF;
|
||||
-fx-font-size: 14px;
|
||||
-fx-font-weight: bold;
|
||||
-fx-pref-height: 40px;
|
||||
-fx-pref-width: 200px;
|
||||
}
|
||||
|
||||
.label {
|
||||
-fx-font-size: 14px;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.text-field, .date-picker, .combo-box {
|
||||
-fx-pref-height: 30px;
|
||||
-fx-pref-width: 250px;
|
||||
}
|
96
flights.xml
|
@ -185,6 +185,102 @@
|
|||
</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>
|
||||
</void>
|
||||
<void property="anzahlLandungen">
|
||||
<int>2</int>
|
||||
</void>
|
||||
<void property="kommentar">
|
||||
<string>lol</string>
|
||||
</void>
|
||||
<void property="muster">
|
||||
<string>test</string>
|
||||
</void>
|
||||
<void property="pilot">
|
||||
<object class="models.Pilot" id="Pilot4">
|
||||
<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>
|
||||
</object>
|
||||
</java>
|
||||
|
|
39
pilots.xml
|
@ -5,49 +5,14 @@
|
|||
<void method="add">
|
||||
<object class="models.Pilot">
|
||||
<void property="adresse">
|
||||
<string>asd</string>
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>23</string>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>asd</string>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<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>
|
||||
<string>ads</string>
|
||||
</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>
|
||||
</void>
|
||||
|
|
|
@ -1,121 +1,184 @@
|
|||
package models;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import javafx.beans.property.*;
|
||||
|
||||
public class Flight implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private LocalDate datum;
|
||||
private String muster;
|
||||
private String abflugort;
|
||||
private String abflugzeit;
|
||||
private String ankunftszeit;
|
||||
private double tToF; // Flugdauer in Stunden
|
||||
private int anzahlLandungen;
|
||||
private Pilot pilot;
|
||||
private boolean isNachtflug;
|
||||
private String kommentar;
|
||||
private transient ObjectProperty<LocalDate> datum;
|
||||
private String datumStr;
|
||||
private StringProperty muster;
|
||||
private StringProperty abflugort;
|
||||
private StringProperty abflugzeit;
|
||||
private StringProperty ankunftszeit;
|
||||
private DoubleProperty tToF;
|
||||
private IntegerProperty anzahlLandungen;
|
||||
private ObjectProperty<Pilot> pilot;
|
||||
private BooleanProperty nachtflug;
|
||||
private StringProperty kommentar;
|
||||
|
||||
// Standardkonstruktor
|
||||
public Flight() {
|
||||
this.datum = new SimpleObjectProperty<>();
|
||||
this.muster = new SimpleStringProperty();
|
||||
this.abflugort = new SimpleStringProperty();
|
||||
this.abflugzeit = new SimpleStringProperty();
|
||||
this.ankunftszeit = new SimpleStringProperty();
|
||||
this.tToF = new SimpleDoubleProperty();
|
||||
this.anzahlLandungen = new SimpleIntegerProperty();
|
||||
this.pilot = new SimpleObjectProperty<>();
|
||||
this.nachtflug = new SimpleBooleanProperty();
|
||||
this.kommentar = new SimpleStringProperty();
|
||||
}
|
||||
|
||||
public Flight(LocalDate datum, String muster, String abflugort, String abflugzeit, String ankunftszeit, double tToF,
|
||||
int anzahlLandungen, Pilot pilot, boolean isNachtflug, String kommentar) {
|
||||
this.datum = datum;
|
||||
this.muster = muster;
|
||||
this.abflugort = abflugort;
|
||||
this.abflugzeit = abflugzeit;
|
||||
this.ankunftszeit = ankunftszeit;
|
||||
this.tToF = tToF;
|
||||
this.anzahlLandungen = anzahlLandungen;
|
||||
this.pilot = pilot;
|
||||
this.isNachtflug = isNachtflug;
|
||||
this.kommentar = kommentar;
|
||||
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);
|
||||
}
|
||||
|
||||
// Getter und Setter für alle Felder
|
||||
public LocalDate getDatum() {
|
||||
return datum;
|
||||
return datum.get();
|
||||
}
|
||||
|
||||
public void setDatum(LocalDate datum) {
|
||||
this.datum = datum;
|
||||
this.datum.set(datum);
|
||||
this.datumStr = datum.format(DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
}
|
||||
|
||||
public ObjectProperty<LocalDate> datumProperty() {
|
||||
return datum;
|
||||
}
|
||||
|
||||
public String getMuster() {
|
||||
return muster;
|
||||
return muster.get();
|
||||
}
|
||||
|
||||
public void setMuster(String muster) {
|
||||
this.muster = muster;
|
||||
this.muster.set(muster);
|
||||
}
|
||||
|
||||
public StringProperty musterProperty() {
|
||||
return muster;
|
||||
}
|
||||
|
||||
public String getAbflugort() {
|
||||
return abflugort;
|
||||
return abflugort.get();
|
||||
}
|
||||
|
||||
public void setAbflugort(String abflugort) {
|
||||
this.abflugort = abflugort;
|
||||
this.abflugort.set(abflugort);
|
||||
}
|
||||
|
||||
public StringProperty abflugortProperty() {
|
||||
return abflugort;
|
||||
}
|
||||
|
||||
public String getAbflugzeit() {
|
||||
return abflugzeit;
|
||||
return abflugzeit.get();
|
||||
}
|
||||
|
||||
public void setAbflugzeit(String abflugzeit) {
|
||||
this.abflugzeit = abflugzeit;
|
||||
this.abflugzeit.set(abflugzeit);
|
||||
}
|
||||
|
||||
public StringProperty abflugzeitProperty() {
|
||||
return abflugzeit;
|
||||
}
|
||||
|
||||
public String getAnkunftszeit() {
|
||||
return ankunftszeit;
|
||||
return ankunftszeit.get();
|
||||
}
|
||||
|
||||
public void setAnkunftszeit(String ankunftszeit) {
|
||||
this.ankunftszeit = ankunftszeit;
|
||||
this.ankunftszeit.set(ankunftszeit);
|
||||
}
|
||||
|
||||
public StringProperty ankunftszeitProperty() {
|
||||
return ankunftszeit;
|
||||
}
|
||||
|
||||
public double getTToF() {
|
||||
return tToF;
|
||||
return tToF.get();
|
||||
}
|
||||
|
||||
public void setTToF(double tToF) {
|
||||
this.tToF = tToF;
|
||||
this.tToF.set(tToF);
|
||||
}
|
||||
|
||||
public DoubleProperty tToFProperty() {
|
||||
return tToF;
|
||||
}
|
||||
|
||||
public int getAnzahlLandungen() {
|
||||
return anzahlLandungen;
|
||||
return anzahlLandungen.get();
|
||||
}
|
||||
|
||||
public void setAnzahlLandungen(int anzahlLandungen) {
|
||||
this.anzahlLandungen = anzahlLandungen;
|
||||
this.anzahlLandungen.set(anzahlLandungen);
|
||||
}
|
||||
|
||||
public IntegerProperty anzahlLandungenProperty() {
|
||||
return anzahlLandungen;
|
||||
}
|
||||
|
||||
public Pilot getPilot() {
|
||||
return pilot;
|
||||
return pilot.get();
|
||||
}
|
||||
|
||||
public void setPilot(Pilot pilot) {
|
||||
this.pilot = pilot;
|
||||
this.pilot.set(pilot);
|
||||
}
|
||||
|
||||
public ObjectProperty<Pilot> pilotProperty() {
|
||||
return pilot;
|
||||
}
|
||||
|
||||
public boolean isNachtflug() {
|
||||
return isNachtflug;
|
||||
return nachtflug.get();
|
||||
}
|
||||
|
||||
public void setNachtflug(boolean nachtflug) {
|
||||
isNachtflug = nachtflug;
|
||||
this.nachtflug.set(nachtflug);
|
||||
}
|
||||
|
||||
public BooleanProperty nachtflugProperty() {
|
||||
return nachtflug;
|
||||
}
|
||||
|
||||
public String getKommentar() {
|
||||
return kommentar;
|
||||
return kommentar.get();
|
||||
}
|
||||
|
||||
public void setKommentar(String kommentar) {
|
||||
this.kommentar = kommentar;
|
||||
this.kommentar.set(kommentar);
|
||||
}
|
||||
|
||||
public StringProperty kommentarProperty() {
|
||||
return kommentar;
|
||||
}
|
||||
|
||||
public String getPilotInformationen() {
|
||||
return pilot != null ? pilot.getInformationen() : "Kein Pilot zugewiesen";
|
||||
Pilot pilot = getPilot();
|
||||
if (pilot != null) {
|
||||
return "Name: " + pilot.getName() + ", Adresse: " + pilot.getAdresse() + ", Kontaktinformationen: " + pilot.getKontaktinformationen();
|
||||
}
|
||||
return "Keine Pilotinformationen verfügbar";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,51 +3,69 @@ package models;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class Pilot implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private String adresse;
|
||||
private String kontaktinformationen;
|
||||
private StringProperty name;
|
||||
private StringProperty adresse;
|
||||
private StringProperty kontaktinformationen;
|
||||
private List<String> lizenzen;
|
||||
private List<String> zertifikate;
|
||||
|
||||
// Standardkonstruktor
|
||||
public Pilot() {
|
||||
this.name = new SimpleStringProperty();
|
||||
this.adresse = new SimpleStringProperty();
|
||||
this.kontaktinformationen = new SimpleStringProperty();
|
||||
this.lizenzen = new ArrayList<>();
|
||||
this.zertifikate = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Pilot(String name, String adresse, String kontaktinformationen) {
|
||||
this.name = name;
|
||||
this.adresse = adresse;
|
||||
this.kontaktinformationen = kontaktinformationen;
|
||||
this.name = new SimpleStringProperty(name);
|
||||
this.adresse = new SimpleStringProperty(adresse);
|
||||
this.kontaktinformationen = new SimpleStringProperty(kontaktinformationen);
|
||||
this.lizenzen = new ArrayList<>();
|
||||
this.zertifikate = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return name.get();
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
this.name.set(name);
|
||||
}
|
||||
|
||||
public StringProperty nameProperty() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
return adresse.get();
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
this.adresse.set(adresse);
|
||||
}
|
||||
|
||||
public StringProperty adresseProperty() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public String getKontaktinformationen() {
|
||||
return kontaktinformationen;
|
||||
return kontaktinformationen.get();
|
||||
}
|
||||
|
||||
public void setKontaktinformationen(String kontaktinformationen) {
|
||||
this.kontaktinformationen = kontaktinformationen;
|
||||
this.kontaktinformationen.set(kontaktinformationen);
|
||||
}
|
||||
|
||||
public StringProperty kontaktinformationenProperty() {
|
||||
return kontaktinformationen;
|
||||
}
|
||||
|
||||
public List<String> getLizenzen() {
|
||||
|
@ -58,6 +76,10 @@ public class Pilot implements Serializable {
|
|||
this.lizenzen = lizenzen;
|
||||
}
|
||||
|
||||
public void addLizenz(String lizenz) {
|
||||
this.lizenzen.add(lizenz);
|
||||
}
|
||||
|
||||
public List<String> getZertifikate() {
|
||||
return zertifikate;
|
||||
}
|
||||
|
@ -66,20 +88,12 @@ public class Pilot implements Serializable {
|
|||
this.zertifikate = zertifikate;
|
||||
}
|
||||
|
||||
public void addLizenz(String lizenz) {
|
||||
this.lizenzen.add(lizenz);
|
||||
}
|
||||
|
||||
public void addZertifikat(String zertifikat) {
|
||||
this.zertifikate.add(zertifikat);
|
||||
}
|
||||
|
||||
public String getInformationen() {
|
||||
return "Name: " + name + ", Adresse: " + adresse + ", Kontaktinformationen: " + kontaktinformationen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,22 @@
|
|||
.root {
|
||||
-fx-font-family: 'Arial';
|
||||
}
|
||||
|
||||
.button {
|
||||
-fx-background-color: #000000;
|
||||
-fx-text-fill: #FFFFFF;
|
||||
-fx-font-size: 14px;
|
||||
-fx-font-weight: bold;
|
||||
-fx-pref-height: 40px;
|
||||
-fx-pref-width: 200px;
|
||||
}
|
||||
|
||||
.label {
|
||||
-fx-font-size: 14px;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.text-field, .date-picker, .combo-box {
|
||||
-fx-pref-height: 30px;
|
||||
-fx-pref-width: 250px;
|
||||
}
|
|
@ -2,28 +2,24 @@ package utils;
|
|||
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
|
||||
public class XMLHelper {
|
||||
|
||||
public static void saveToXML(Object data, String filename) {
|
||||
try (XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(filename)))) {
|
||||
encoder.writeObject(data);
|
||||
public static void saveToXML(Object obj, String filePath) {
|
||||
try (XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(filePath)))) {
|
||||
encoder.writeObject(obj);
|
||||
encoder.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Object loadFromXML(String filename) {
|
||||
try (XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(filename)))) {
|
||||
public static Object loadFromXML(String filePath) {
|
||||
try (XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(filePath)))) {
|
||||
return decoder.readObject();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("File not found: " + filePath);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,12 +70,12 @@ public class AddFlightScreen {
|
|||
pilotComboBox.setPromptText("Pilot auswählen");
|
||||
|
||||
Button submitBtn = new Button("Hinzufügen");
|
||||
submitBtn.setStyle("-fx-background-color: #431EB9; -fx-text-fill: #FFFFFF;");
|
||||
submitBtn.setOnAction(
|
||||
e -> handleAddFlight(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
tToFField, anzahlLandungenField, nachtflugBox.isSelected(), kommentarField, pilotComboBox));
|
||||
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));
|
||||
|
||||
Button backButton = new Button("Zurück");
|
||||
backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||
|
||||
VBox vbox = new VBox(10, label, datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
|
@ -90,18 +90,24 @@ public class AddFlightScreen {
|
|||
BorderPane.setAlignment(backButton, Pos.TOP_LEFT);
|
||||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 600, 700);
|
||||
if (pilots.isEmpty()) {
|
||||
Button addPilotBtn = new Button("Pilot hinzufügen");
|
||||
addPilotBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
addPilotBtn.setOnAction(e -> new ManagePilotProfileScreen(stage).display());
|
||||
vbox.getChildren().add(addPilotBtn);
|
||||
}
|
||||
|
||||
Scene scene = new Scene(borderPane, 800, 700);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
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 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);
|
||||
|
||||
try {
|
||||
if (datumField.getValue() == null) {
|
||||
|
@ -153,8 +159,7 @@ 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) {
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package views;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import models.Pilot;
|
||||
import models.Pilots;
|
||||
import utils.XMLHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeletePilotScreen {
|
||||
private Stage stage;
|
||||
|
||||
public DeletePilotScreen(Stage stage) {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public void display() {
|
||||
Label label = new Label("Piloten löschen");
|
||||
label.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
|
||||
|
||||
Pilots pilotsData = (Pilots) XMLHelper.loadFromXML("pilots.xml");
|
||||
List<Pilot> pilotList = pilotsData != null ? pilotsData.getPilots() : new java.util.ArrayList<>();
|
||||
ComboBox<Pilot> pilotComboBox = new ComboBox<>(javafx.collections.FXCollections.observableArrayList(pilotList));
|
||||
pilotComboBox.setPromptText("Pilot auswählen");
|
||||
|
||||
Button deleteBtn = new Button("Löschen");
|
||||
deleteBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
deleteBtn.setOnAction(e -> {
|
||||
Pilot selectedPilot = pilotComboBox.getValue();
|
||||
if (selectedPilot != null) {
|
||||
pilotList.remove(selectedPilot);
|
||||
XMLHelper.saveToXML(new Pilots(pilotList), "pilots.xml");
|
||||
new HomeScreen(stage).display();
|
||||
} else {
|
||||
showAlert("Fehler", "Bitte wählen Sie einen Piloten aus.");
|
||||
}
|
||||
});
|
||||
|
||||
Button backButton = new Button("Zurück");
|
||||
backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||
|
||||
VBox vbox = new VBox(10, label, pilotComboBox, deleteBtn);
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
vbox.setPadding(new Insets(20));
|
||||
vbox.setStyle("-fx-background-color: #E6F2FF;");
|
||||
|
||||
BorderPane borderPane = new BorderPane();
|
||||
borderPane.setTop(backButton);
|
||||
borderPane.setCenter(vbox);
|
||||
BorderPane.setAlignment(backButton, Pos.TOP_LEFT);
|
||||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 800, 600);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
private void showAlert(String title, String message) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(message);
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
package views;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import models.Flight;
|
||||
import models.Flights;
|
||||
import utils.XMLHelper;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public class EditFlightScreen {
|
||||
private Stage stage;
|
||||
private Flight flight;
|
||||
|
||||
public EditFlightScreen(Stage stage, Flight flight) {
|
||||
this.stage = stage;
|
||||
this.flight = flight;
|
||||
}
|
||||
|
||||
public void display() {
|
||||
Label label = new Label("Flugdaten bearbeiten:");
|
||||
label.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
|
||||
DatePicker datumField = new DatePicker(flight.getDatum());
|
||||
TextField musterField = new TextField(flight.getMuster());
|
||||
TextField abflugortField = new TextField(flight.getAbflugort());
|
||||
TextField abflugzeitField = new TextField(flight.getAbflugzeit());
|
||||
TextField ankunftszeitField = new TextField(flight.getAnkunftszeit());
|
||||
TextField tToFField = new TextField(String.valueOf(flight.getTToF()));
|
||||
TextField anzahlLandungenField = new TextField(String.valueOf(flight.getAnzahlLandungen()));
|
||||
CheckBox nachtflugBox = new CheckBox("Nachtflug");
|
||||
nachtflugBox.setSelected(flight.isNachtflug());
|
||||
TextField kommentarField = new TextField(flight.getKommentar());
|
||||
|
||||
datumField.setPromptText("YYYY-MM-DD");
|
||||
musterField.setPromptText("Muster");
|
||||
abflugortField.setPromptText("Abflugort");
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
anzahlLandungenField.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue.matches("\\d*")) {
|
||||
anzahlLandungenField.setText(oldValue);
|
||||
}
|
||||
});
|
||||
|
||||
Button saveBtn = new Button("Speichern");
|
||||
saveBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
saveBtn.setOnAction(e -> handleSaveFlight(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
tToFField, anzahlLandungenField, nachtflugBox.isSelected(), kommentarField));
|
||||
|
||||
Button backButton = new Button("Zurück");
|
||||
backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
backButton.setOnAction(e -> new ViewLogbookScreen(stage).display());
|
||||
|
||||
VBox vbox = new VBox(10, label, datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||
tToFField, anzahlLandungenField, nachtflugBox, kommentarField, saveBtn);
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
vbox.setPadding(new Insets(20));
|
||||
vbox.setStyle("-fx-background-color: #E6F2FF;");
|
||||
|
||||
BorderPane borderPane = new BorderPane();
|
||||
borderPane.setTop(backButton);
|
||||
borderPane.setCenter(vbox);
|
||||
BorderPane.setAlignment(backButton, Pos.TOP_LEFT);
|
||||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 800, 700);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
private void handleSaveFlight(DatePicker datumField, TextField musterField, TextField abflugortField, TextField abflugzeitField,
|
||||
TextField ankunftszeitField, TextField tToFField, TextField anzahlLandungenField, boolean isNachtflug,
|
||||
TextField kommentarField) {
|
||||
clearFieldStyles(datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField, tToFField, anzahlLandungenField);
|
||||
|
||||
try {
|
||||
if (datumField.getValue() == null) {
|
||||
setErrorStyle(datumField);
|
||||
throw new IllegalArgumentException("Datum ist erforderlich.");
|
||||
}
|
||||
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.");
|
||||
}
|
||||
|
||||
double flightDuration = Double.parseDouble(tToFField.getText());
|
||||
int landings = Integer.parseInt(anzahlLandungenField.getText());
|
||||
|
||||
flight.setDatum(datumField.getValue());
|
||||
flight.setMuster(musterField.getText());
|
||||
flight.setAbflugort(abflugortField.getText());
|
||||
flight.setAbflugzeit(abflugzeitField.getText());
|
||||
flight.setAnkunftszeit(ankunftszeitField.getText());
|
||||
flight.setTToF(flightDuration);
|
||||
flight.setAnzahlLandungen(landings);
|
||||
flight.setNachtflug(isNachtflug);
|
||||
flight.setKommentar(kommentarField.getText());
|
||||
|
||||
Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml");
|
||||
if (flights != null) {
|
||||
List<Flight> flightEntries = flights.getFlights();
|
||||
for (int i = 0; i < flightEntries.size(); i++) {
|
||||
if (flightEntries.get(i).equals(flight)) {
|
||||
flightEntries.set(i, flight);
|
||||
break;
|
||||
}
|
||||
}
|
||||
XMLHelper.saveToXML(flights, "flights.xml");
|
||||
}
|
||||
|
||||
new ViewLogbookScreen(stage).display();
|
||||
} catch (NumberFormatException e) {
|
||||
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) {
|
||||
showAlert("Fehler", "Es ist ein Fehler beim Speichern des Flugs aufgetreten.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setErrorStyle(Control field) {
|
||||
field.setStyle("-fx-border-color: red;");
|
||||
}
|
||||
|
||||
private void clearFieldStyles(Control... fields) {
|
||||
for (Control field : fields) {
|
||||
field.setStyle(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void showAlert(String title, String message) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(message);
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ public class HelpScreen {
|
|||
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||
|
||||
Scene scene = new Scene(vbox, 400, 300);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
|
|
@ -5,9 +5,14 @@ import javafx.geometry.Pos;
|
|||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.stage.Stage;
|
||||
import models.Pilots;
|
||||
import utils.XMLHelper;
|
||||
|
@ -20,16 +25,22 @@ public class HomeScreen {
|
|||
}
|
||||
|
||||
public void display() {
|
||||
Button btn1 = createButton("Flug erfassen", "/resources/icons/add_flight_icon.png");
|
||||
Button btn2 = createButton("Logbuch einsehen", "/resources/icons/view_logbook_icon.png");
|
||||
Button btn3 = createButton("Pilotenprofil verwalten", "/resources/icons/manage_pilot_icon.png");
|
||||
Button helpBtn = createButton("Hilfe", "/resources/icons/help_icon.png");
|
||||
Button pilotsBtn = createButton("Alle Piloten anzeigen", "/resources/icons/view_pilot_icon.png");
|
||||
Button editPilotsBtn = createButton("Pilot bearbeiten", "/resources/icons/edit_pilot_icon.png");
|
||||
// Titel des Projekts
|
||||
Label title = new Label("Fluglogbuch Pegasus");
|
||||
title.setStyle("-fx-font-size: 32px; -fx-font-weight: bold; -fx-text-fill: #000000; -fx-font-family: 'Arial Black';");
|
||||
|
||||
Button btn1 = createButton("Flug erfassen", "/resources/icons/add_flight_icon.png", "Erfassen Sie einen neuen Flug");
|
||||
Button btn2 = createButton("Logbuch einsehen", "/resources/icons/view_logbook_icon.png", "Sehen Sie das Fluglogbuch ein");
|
||||
Button btn3 = createButton("Pilotenprofil verwalten", "/resources/icons/manage_pilot_icon.png", "Verwalten Sie das Profil eines Piloten");
|
||||
Button btn4 = createButton("Piloten löschen", "/resources/icons/delete_pilot_icon.png", "Löschen Sie einen Piloten");
|
||||
Button helpBtn = createHelpButton("/resources/icons/help_icon.png", "Hilfe anzeigen");
|
||||
Button pilotsBtn = createButton("Alle Piloten anzeigen", "/resources/icons/view_pilot_icon.png", "Alle Piloten anzeigen");
|
||||
Button editPilotsBtn = createButton("Pilot bearbeiten", "/resources/icons/edit_pilot_icon.png", "Bearbeiten Sie ein Pilotenprofil");
|
||||
|
||||
btn1.setOnAction(e -> new AddFlightScreen(stage).display());
|
||||
btn2.setOnAction(e -> new ViewLogbookScreen(stage).display());
|
||||
btn3.setOnAction(e -> new ManagePilotProfileScreen(stage).display());
|
||||
btn4.setOnAction(e -> new DeletePilotScreen(stage).display());
|
||||
helpBtn.setOnAction(e -> new HelpScreen(stage).display());
|
||||
pilotsBtn.setOnAction(e -> new PilotView(stage).displayAllPilots());
|
||||
editPilotsBtn.setOnAction(e -> {
|
||||
|
@ -41,33 +52,63 @@ public class HomeScreen {
|
|||
}
|
||||
});
|
||||
|
||||
VBox vbox = new VBox(20, btn1, btn2, btn3, helpBtn, pilotsBtn, editPilotsBtn);
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
vbox.setPadding(new Insets(30));
|
||||
vbox.setStyle("-fx-background-color: #E6F2FF;");
|
||||
GridPane gridPane = new GridPane();
|
||||
gridPane.setPadding(new Insets(20));
|
||||
gridPane.setHgap(20);
|
||||
gridPane.setVgap(20);
|
||||
gridPane.setAlignment(Pos.CENTER);
|
||||
gridPane.add(btn1, 0, 0);
|
||||
gridPane.add(btn2, 1, 0);
|
||||
gridPane.add(btn3, 0, 1);
|
||||
gridPane.add(pilotsBtn, 1, 1);
|
||||
gridPane.add(editPilotsBtn, 0, 2);
|
||||
gridPane.add(btn4, 1, 2);
|
||||
|
||||
Scene scene = new Scene(vbox, 600, 400);
|
||||
VBox vbox = new VBox(20, title, gridPane);
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
|
||||
BorderPane borderPane = new BorderPane();
|
||||
borderPane.setCenter(vbox);
|
||||
borderPane.setRight(helpBtn);
|
||||
BorderPane.setAlignment(helpBtn, Pos.TOP_RIGHT);
|
||||
BorderPane.setMargin(helpBtn, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 800, 600);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Fluglogbuch");
|
||||
stage.setTitle("Fluglogbuch Pegasus");
|
||||
stage.show();
|
||||
}
|
||||
|
||||
private Button createButton(String text, String iconPath) {
|
||||
private Button createButton(String text, String iconPath, String tooltipText) {
|
||||
Image icon = new Image(getClass().getResourceAsStream(iconPath));
|
||||
if (icon.isError()) {
|
||||
System.out.println("Fehler beim Laden des Icons: " + iconPath);
|
||||
}
|
||||
ImageView iconView = new ImageView(icon);
|
||||
iconView.setFitHeight(20);
|
||||
iconView.setFitWidth(20);
|
||||
|
||||
Button button = new Button(text, iconView);
|
||||
button.setStyle("-fx-background-color: #431EB9; -fx-text-fill: #FFFFFF;");
|
||||
button.setTooltip(new Tooltip(tooltipText));
|
||||
button.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
button.setPrefSize(250, 50);
|
||||
return button;
|
||||
}
|
||||
|
||||
private Button createHelpButton(String iconPath, String tooltipText) {
|
||||
Image icon = new Image(getClass().getResourceAsStream(iconPath));
|
||||
ImageView iconView = new ImageView(icon);
|
||||
iconView.setFitHeight(30);
|
||||
iconView.setFitWidth(30);
|
||||
|
||||
Button button = new Button("", iconView);
|
||||
button.setTooltip(new Tooltip(tooltipText));
|
||||
button.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
button.setShape(new Circle(25)); // Set button shape to circle
|
||||
button.setMinSize(50, 50); // Set the min size to ensure it remains circular
|
||||
button.setMaxSize(50, 50); // Set the max size to ensure it remains circular
|
||||
return button;
|
||||
}
|
||||
|
||||
private void showAlert(String title, String message) {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle(title);
|
||||
|
|
|
@ -5,7 +5,6 @@ import javafx.geometry.Pos;
|
|||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import models.Pilot;
|
||||
|
@ -56,6 +55,8 @@ public class ManagePilotProfileScreen {
|
|||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 400, 300);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
@ -123,6 +124,7 @@ public class ManagePilotProfileScreen {
|
|||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 400, 600);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
|
|
@ -76,6 +76,8 @@ public class PilotView {
|
|||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 400, 300);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Alle Piloten");
|
||||
stage.show();
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package views;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
@ -16,6 +14,8 @@ import models.Flight;
|
|||
import models.Flights;
|
||||
import utils.XMLHelper;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
public class ViewLogbookScreen {
|
||||
|
@ -26,68 +26,88 @@ public class ViewLogbookScreen {
|
|||
}
|
||||
|
||||
public void display() {
|
||||
Flights flightsData = (Flights) XMLHelper.loadFromXML("flights.xml");
|
||||
List<Flight> flightList = flightsData != null ? flightsData.getFlights() : List.of();
|
||||
Label label = new Label("Fluglogbuch Pegasus");
|
||||
label.setStyle("-fx-font-size: 32px; -fx-font-weight: bold; -fx-text-fill: #431EB9; -fx-font-family: 'Arial Black';");
|
||||
|
||||
ObservableList<Flight> flights = FXCollections.observableArrayList(flightList);
|
||||
TableView<Flight> table = new TableView<>();
|
||||
table.setStyle("-fx-font-weight: bold;");
|
||||
|
||||
TableView<Flight> tableView = new TableView<>(flights);
|
||||
TableColumn<Flight, String> datumCol = new TableColumn<>("Datum");
|
||||
datumCol.setCellValueFactory(cellData -> {
|
||||
LocalDate date = cellData.getValue().getDatum();
|
||||
String formattedDate = date != null ? date.format(DateTimeFormatter.ISO_LOCAL_DATE) : "";
|
||||
return new SimpleStringProperty(formattedDate);
|
||||
});
|
||||
|
||||
TableColumn<Flight, String> dateColumn = new TableColumn<>("Datum");
|
||||
dateColumn.setCellValueFactory(new PropertyValueFactory<>("datum"));
|
||||
TableColumn<Flight, String> musterCol = new TableColumn<>("Muster");
|
||||
musterCol.setCellValueFactory(cellData -> cellData.getValue().musterProperty());
|
||||
|
||||
TableColumn<Flight, String> modelColumn = new TableColumn<>("Muster");
|
||||
modelColumn.setCellValueFactory(new PropertyValueFactory<>("muster"));
|
||||
TableColumn<Flight, String> abflugortCol = new TableColumn<>("Abflugort");
|
||||
abflugortCol.setCellValueFactory(cellData -> cellData.getValue().abflugortProperty());
|
||||
|
||||
TableColumn<Flight, String> departureColumn = new TableColumn<>("Abflugort");
|
||||
departureColumn.setCellValueFactory(new PropertyValueFactory<>("abflugort"));
|
||||
TableColumn<Flight, String> abflugzeitCol = new TableColumn<>("Abflugzeit");
|
||||
abflugzeitCol.setCellValueFactory(cellData -> cellData.getValue().abflugzeitProperty());
|
||||
|
||||
TableColumn<Flight, String> departureTimeColumn = new TableColumn<>("Abflugzeit");
|
||||
departureTimeColumn.setCellValueFactory(new PropertyValueFactory<>("abflugzeit"));
|
||||
TableColumn<Flight, String> ankunftszeitCol = new TableColumn<>("Ankunftszeit");
|
||||
ankunftszeitCol.setCellValueFactory(cellData -> cellData.getValue().ankunftszeitProperty());
|
||||
|
||||
TableColumn<Flight, String> arrivalTimeColumn = new TableColumn<>("Ankunftszeit");
|
||||
arrivalTimeColumn.setCellValueFactory(new PropertyValueFactory<>("ankunftszeit"));
|
||||
TableColumn<Flight, Double> tToFCol = new TableColumn<>("Flugdauer");
|
||||
tToFCol.setCellValueFactory(cellData -> cellData.getValue().tToFProperty().asObject());
|
||||
|
||||
TableColumn<Flight, Double> durationColumn = new TableColumn<>("Flugdauer");
|
||||
durationColumn.setCellValueFactory(new PropertyValueFactory<>("tToF"));
|
||||
TableColumn<Flight, Integer> anzahlLandungenCol = new TableColumn<>("Landungen");
|
||||
anzahlLandungenCol.setCellValueFactory(cellData -> cellData.getValue().anzahlLandungenProperty().asObject());
|
||||
|
||||
TableColumn<Flight, Integer> landingsColumn = new TableColumn<>("Anzahl der Landungen");
|
||||
landingsColumn.setCellValueFactory(new PropertyValueFactory<>("anzahlLandungen"));
|
||||
TableColumn<Flight, String> pilotCol = new TableColumn<>("Pilot");
|
||||
pilotCol.setCellValueFactory(cellData -> cellData.getValue().pilotProperty().get().nameProperty());
|
||||
|
||||
TableColumn<Flight, Boolean> nightFlightColumn = new TableColumn<>("Nachtflug");
|
||||
nightFlightColumn.setCellValueFactory(new PropertyValueFactory<>("isNachtflug"));
|
||||
TableColumn<Flight, Boolean> nachtflugCol = new TableColumn<>("Nachtflug");
|
||||
nachtflugCol.setCellValueFactory(cellData -> cellData.getValue().nachtflugProperty().asObject());
|
||||
|
||||
TableColumn<Flight, String> commentColumn = new TableColumn<>("Kommentar");
|
||||
commentColumn.setCellValueFactory(new PropertyValueFactory<>("kommentar"));
|
||||
TableColumn<Flight, String> kommentarCol = new TableColumn<>("Kommentar");
|
||||
kommentarCol.setCellValueFactory(cellData -> cellData.getValue().kommentarProperty());
|
||||
|
||||
tableView.getColumns().add(dateColumn);
|
||||
tableView.getColumns().add(modelColumn);
|
||||
tableView.getColumns().add(departureColumn);
|
||||
tableView.getColumns().add(departureTimeColumn);
|
||||
tableView.getColumns().add(arrivalTimeColumn);
|
||||
tableView.getColumns().add(durationColumn);
|
||||
tableView.getColumns().add(landingsColumn);
|
||||
tableView.getColumns().add(nightFlightColumn);
|
||||
tableView.getColumns().add(commentColumn);
|
||||
table.getColumns().addAll(datumCol, musterCol, abflugortCol, abflugzeitCol, ankunftszeitCol, tToFCol, anzahlLandungenCol, pilotCol, nachtflugCol, kommentarCol);
|
||||
|
||||
ObservableList<Flight> flightList = FXCollections.observableArrayList();
|
||||
Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml");
|
||||
if (flights != null) {
|
||||
List<Flight> flightEntries = flights.getFlights();
|
||||
flightList.addAll(flightEntries);
|
||||
}
|
||||
table.setItems(flightList);
|
||||
|
||||
Button editBtn = new Button("Bearbeiten");
|
||||
editBtn.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
editBtn.setOnAction(e -> {
|
||||
Flight selectedFlight = table.getSelectionModel().getSelectedItem();
|
||||
if (selectedFlight != null) {
|
||||
new EditFlightScreen(stage, selectedFlight).display();
|
||||
} else {
|
||||
showAlert("Fehler", "Bitte wählen Sie einen Flug aus.");
|
||||
}
|
||||
});
|
||||
|
||||
Button backButton = new Button("Zurück");
|
||||
backButton.setStyle("-fx-background-color: #000000; -fx-text-fill: #FFFFFF; -fx-font-weight: bold;");
|
||||
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||
|
||||
VBox vbox = new VBox(tableView);
|
||||
VBox vbox = new VBox(20, label, table, editBtn, backButton);
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
vbox.setPadding(new Insets(20));
|
||||
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||
vbox.setStyle("-fx-background-color: #E6F2FF;");
|
||||
|
||||
BorderPane borderPane = new BorderPane();
|
||||
borderPane.setTop(backButton);
|
||||
borderPane.setCenter(vbox);
|
||||
BorderPane.setAlignment(backButton, Pos.TOP_LEFT);
|
||||
BorderPane.setMargin(backButton, new Insets(10));
|
||||
|
||||
Scene scene = new Scene(borderPane, 800, 600);
|
||||
Scene scene = new Scene(vbox, 800, 600);
|
||||
scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm());
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Fluglogbuch einsehen");
|
||||
stage.show();
|
||||
}
|
||||
|
||||
private void showAlert(String title, String message) {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(message);
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
|