Initial commit
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Current File",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "${file}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Main",
|
||||||
|
"request": "launch",
|
||||||
|
"vmArgs": "--module-path C:/Sources/javafx-sdk-22.0.1/lib --add-modules javafx.controls,javafx.fxml",
|
||||||
|
"mainClass": "program.Main",
|
||||||
|
"projectName": "Pegasus_606a3a68"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"java.project.sourcePaths": ["src"],
|
||||||
|
"java.project.outputPath": "bin",
|
||||||
|
"java.project.referencedLibraries": [
|
||||||
|
"lib/**/*.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.base.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.controls.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.fxml.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.graphics.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.media.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.swing.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx.web.jar",
|
||||||
|
"c:\\Sources\\javafx-sdk-22.0.1\\lib\\javafx-swt.jar"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
|
@ -0,0 +1,190 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<java version="21.0.1" class="java.beans.XMLDecoder">
|
||||||
|
<object class="models.Flights" id="Flights0">
|
||||||
|
<void property="flights">
|
||||||
|
<void method="add">
|
||||||
|
<object class="models.Flight">
|
||||||
|
<void property="TToF">
|
||||||
|
<double>2.0</double>
|
||||||
|
</void>
|
||||||
|
<void property="abflugort">
|
||||||
|
<string>ea</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>
|
||||||
|
</object>
|
||||||
|
</java>
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<java version="21.0.1" class="java.beans.XMLDecoder">
|
||||||
|
<object class="models.Pilots" id="Pilots0">
|
||||||
|
<void property="pilots">
|
||||||
|
<void method="add">
|
||||||
|
<object class="models.Pilot">
|
||||||
|
<void property="adresse">
|
||||||
|
<string>asd</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>
|
||||||
|
</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>
|
||||||
|
</object>
|
||||||
|
</java>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package controllers;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import models.Flight;
|
||||||
|
import views.FlightView;
|
||||||
|
|
||||||
|
public class FlightController {
|
||||||
|
private Flight model;
|
||||||
|
private FlightView view;
|
||||||
|
|
||||||
|
public FlightController(Flight model, FlightView view) {
|
||||||
|
this.model = model;
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlightDatum(LocalDate datum) {
|
||||||
|
model.setDatum(datum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getFlightDatum() {
|
||||||
|
return model.getDatum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateView() {
|
||||||
|
view.displayFlightDetails(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package controllers;
|
||||||
|
|
||||||
|
import models.Pilot;
|
||||||
|
import views.PilotView;
|
||||||
|
|
||||||
|
public class PilotController {
|
||||||
|
private Pilot model;
|
||||||
|
private PilotView view;
|
||||||
|
|
||||||
|
public PilotController(Pilot model, PilotView view) {
|
||||||
|
this.model = model;
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPilotName(String name) {
|
||||||
|
model.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPilotName() {
|
||||||
|
return model.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateView() {
|
||||||
|
view.displayPilotDetails(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
package models;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public Flight() {
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter und Setter für alle Felder
|
||||||
|
public LocalDate getDatum() {
|
||||||
|
return datum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatum(LocalDate datum) {
|
||||||
|
this.datum = datum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMuster() {
|
||||||
|
return muster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMuster(String muster) {
|
||||||
|
this.muster = muster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbflugort() {
|
||||||
|
return abflugort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbflugort(String abflugort) {
|
||||||
|
this.abflugort = abflugort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbflugzeit() {
|
||||||
|
return abflugzeit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbflugzeit(String abflugzeit) {
|
||||||
|
this.abflugzeit = abflugzeit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnkunftszeit() {
|
||||||
|
return ankunftszeit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnkunftszeit(String ankunftszeit) {
|
||||||
|
this.ankunftszeit = ankunftszeit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTToF() {
|
||||||
|
return tToF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTToF(double tToF) {
|
||||||
|
this.tToF = tToF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAnzahlLandungen() {
|
||||||
|
return anzahlLandungen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnzahlLandungen(int anzahlLandungen) {
|
||||||
|
this.anzahlLandungen = anzahlLandungen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pilot getPilot() {
|
||||||
|
return pilot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPilot(Pilot pilot) {
|
||||||
|
this.pilot = pilot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNachtflug() {
|
||||||
|
return isNachtflug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNachtflug(boolean nachtflug) {
|
||||||
|
isNachtflug = nachtflug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKommentar() {
|
||||||
|
return kommentar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKommentar(String kommentar) {
|
||||||
|
this.kommentar = kommentar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPilotInformationen() {
|
||||||
|
return pilot != null ? pilot.getInformationen() : "Kein Pilot zugewiesen";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package models;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Flights implements Serializable {
|
||||||
|
private List<Flight> flights;
|
||||||
|
|
||||||
|
public Flights() {
|
||||||
|
this.flights = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flights(List<Flight> flights) {
|
||||||
|
this.flights = flights;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Flight> getFlights() {
|
||||||
|
return flights;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlights(List<Flight> flights) {
|
||||||
|
this.flights = flights;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
package models;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Pilot implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String adresse;
|
||||||
|
private String kontaktinformationen;
|
||||||
|
private List<String> lizenzen;
|
||||||
|
private List<String> zertifikate;
|
||||||
|
|
||||||
|
public Pilot() {
|
||||||
|
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.lizenzen = new ArrayList<>();
|
||||||
|
this.zertifikate = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdresse() {
|
||||||
|
return adresse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdresse(String adresse) {
|
||||||
|
this.adresse = adresse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKontaktinformationen() {
|
||||||
|
return kontaktinformationen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKontaktinformationen(String kontaktinformationen) {
|
||||||
|
this.kontaktinformationen = kontaktinformationen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLizenzen() {
|
||||||
|
return lizenzen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLizenzen(List<String> lizenzen) {
|
||||||
|
this.lizenzen = lizenzen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getZertifikate() {
|
||||||
|
return zertifikate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZertifikate(List<String> zertifikate) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package models;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Pilots implements Serializable {
|
||||||
|
private List<Pilot> pilots;
|
||||||
|
|
||||||
|
public Pilots() {
|
||||||
|
this.pilots = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pilots(List<Pilot> pilots) {
|
||||||
|
this.pilots = pilots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Pilot> getPilots() {
|
||||||
|
return pilots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPilots(List<Pilot> pilots) {
|
||||||
|
this.pilots = pilots;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package program;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import views.HomeScreen;
|
||||||
|
|
||||||
|
public class Main extends Application {
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) {
|
||||||
|
HomeScreen homeScreen = new HomeScreen(primaryStage);
|
||||||
|
homeScreen.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
|
@ -0,0 +1,30 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class XMLHelper {
|
||||||
|
|
||||||
|
public static void saveToXML(Object data, String filename) {
|
||||||
|
try (XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(filename)))) {
|
||||||
|
encoder.writeObject(data);
|
||||||
|
encoder.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object loadFromXML(String filename) {
|
||||||
|
try (XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(filename)))) {
|
||||||
|
return decoder.readObject();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
package views;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
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 models.Pilot;
|
||||||
|
import models.Pilots;
|
||||||
|
import utils.XMLHelper;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AddFlightScreen {
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
|
public AddFlightScreen(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
Label label = new Label("Flugdaten eingeben:");
|
||||||
|
label.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
|
||||||
|
DatePicker datumField = new DatePicker();
|
||||||
|
TextField musterField = new TextField();
|
||||||
|
TextField abflugortField = new TextField();
|
||||||
|
TextField abflugzeitField = new TextField();
|
||||||
|
TextField ankunftszeitField = new TextField();
|
||||||
|
TextField tToFField = new TextField();
|
||||||
|
TextField anzahlLandungenField = new TextField();
|
||||||
|
CheckBox nachtflugBox = new CheckBox("Nachtflug");
|
||||||
|
TextField kommentarField = new TextField();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Laden der Piloten für die Auswahlbox
|
||||||
|
Pilots pilotsData = (Pilots) XMLHelper.loadFromXML("pilots.xml");
|
||||||
|
List<Pilot> pilotList = pilotsData != null ? pilotsData.getPilots() : new ArrayList<>();
|
||||||
|
ObservableList<Pilot> pilots = FXCollections.observableArrayList(pilotList);
|
||||||
|
|
||||||
|
ComboBox<Pilot> pilotComboBox = new ComboBox<>(pilots);
|
||||||
|
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));
|
||||||
|
|
||||||
|
Button backButton = new Button("Zurück");
|
||||||
|
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
VBox vbox = new VBox(10, label, datumField, musterField, abflugortField, abflugzeitField, ankunftszeitField,
|
||||||
|
tToFField, anzahlLandungenField, nachtflugBox, kommentarField, pilotComboBox, submitBtn);
|
||||||
|
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, 600, 700);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
if (pilotComboBox.getValue() == null) {
|
||||||
|
setErrorStyle(pilotComboBox);
|
||||||
|
throw new IllegalArgumentException("Pilot ist erforderlich.");
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
Flights flights = (Flights) XMLHelper.loadFromXML("flights.xml");
|
||||||
|
if (flights == null) {
|
||||||
|
flights = new Flights(new ArrayList<>());
|
||||||
|
}
|
||||||
|
flights.getFlights().add(newFlight);
|
||||||
|
XMLHelper.saveToXML(flights, "flights.xml");
|
||||||
|
|
||||||
|
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.");
|
||||||
|
} 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package views;
|
||||||
|
|
||||||
|
import models.Flight;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FlightView {
|
||||||
|
public void displayFlightDetails(Flight flight) {
|
||||||
|
System.out.println("Flight Details: ");
|
||||||
|
System.out.println("Datum: " + flight.getDatum());
|
||||||
|
System.out.println("Muster: " + flight.getMuster());
|
||||||
|
System.out.println("Abflugort: " + flight.getAbflugort());
|
||||||
|
System.out.println("Abflugzeit: " + flight.getAbflugzeit());
|
||||||
|
System.out.println("Ankunftszeit: " + flight.getAnkunftszeit());
|
||||||
|
System.out.println("Flugdauer: " + flight.getTToF());
|
||||||
|
System.out.println("Anzahl der Landungen: " + flight.getAnzahlLandungen());
|
||||||
|
System.out.println("Pilotinformationen: " + flight.getPilotInformationen());
|
||||||
|
System.out.println("Nachtflug: " + (flight.isNachtflug() ? "Ja" : "Nein"));
|
||||||
|
System.out.println("Kommentar: " + flight.getKommentar());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayAllFlights(List<Flight> flights) {
|
||||||
|
for (Flight flight : flights) {
|
||||||
|
displayFlightDetails(flight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package views;
|
||||||
|
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class HelpScreen {
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
|
public HelpScreen(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
Label label = new Label("Hilfe");
|
||||||
|
TextArea helpText = new TextArea();
|
||||||
|
helpText.setText("Flug erfassen: Hier können Sie einen neuen Flug hinzufügen.\n" +
|
||||||
|
"Logbuch einsehen: Hier können Sie das Fluglogbuch einsehen.\n" +
|
||||||
|
"Pilotenprofil verwalten: Hier können Sie Ihr Pilotenprofil verwalten.\n" +
|
||||||
|
"Hilfe: Zeigt diese Hilfeseite an.");
|
||||||
|
helpText.setEditable(false);
|
||||||
|
|
||||||
|
Button backBtn = new Button("Zurück");
|
||||||
|
backBtn.setStyle("-fx-background-color: #431EB9; -fx-text-fill: #FFFFFF;");
|
||||||
|
backBtn.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
VBox vbox = new VBox(10, label, helpText, backBtn);
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
vbox.setPadding(new Insets(20));
|
||||||
|
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||||
|
|
||||||
|
Scene scene = new Scene(vbox, 400, 300);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
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.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import models.Pilots;
|
||||||
|
import utils.XMLHelper;
|
||||||
|
|
||||||
|
public class HomeScreen {
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
|
public HomeScreen(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
btn1.setOnAction(e -> new AddFlightScreen(stage).display());
|
||||||
|
btn2.setOnAction(e -> new ViewLogbookScreen(stage).display());
|
||||||
|
btn3.setOnAction(e -> new ManagePilotProfileScreen(stage).display());
|
||||||
|
helpBtn.setOnAction(e -> new HelpScreen(stage).display());
|
||||||
|
pilotsBtn.setOnAction(e -> new PilotView(stage).displayAllPilots());
|
||||||
|
editPilotsBtn.setOnAction(e -> {
|
||||||
|
Pilots pilots = (Pilots) XMLHelper.loadFromXML("pilots.xml");
|
||||||
|
if (pilots != null && !pilots.getPilots().isEmpty()) {
|
||||||
|
new ManagePilotProfileScreen(stage).displayEditSelection(pilots); // Aufruf mit Pilotenliste
|
||||||
|
} else {
|
||||||
|
showAlert("Keine Piloten", "Es sind keine Piloten zum Bearbeiten verfügbar.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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;");
|
||||||
|
|
||||||
|
Scene scene = new Scene(vbox, 600, 400);
|
||||||
|
scene.getStylesheets().add(getClass().getResource("/resources/style.css").toExternalForm());
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("Fluglogbuch");
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button createButton(String text, String iconPath) {
|
||||||
|
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.setPrefSize(250, 50);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAlert(String title, String message) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
|
alert.setTitle(title);
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.setContentText(message);
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
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.HBox;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import models.Pilot;
|
||||||
|
import models.Pilots;
|
||||||
|
import utils.XMLHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ManagePilotProfileScreen {
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
|
public ManagePilotProfileScreen(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
display(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayEditSelection(Pilots pilots) {
|
||||||
|
Label label = new Label("Wählen Sie einen Piloten zum Bearbeiten aus:");
|
||||||
|
ComboBox<Pilot> pilotComboBox = new ComboBox<>();
|
||||||
|
pilotComboBox.getItems().addAll(pilots.getPilots());
|
||||||
|
pilotComboBox.setPromptText("Pilot auswählen");
|
||||||
|
|
||||||
|
Button selectBtn = new Button("Auswählen");
|
||||||
|
selectBtn.setOnAction(e -> {
|
||||||
|
Pilot selectedPilot = pilotComboBox.getValue();
|
||||||
|
if (selectedPilot != null) {
|
||||||
|
display(selectedPilot);
|
||||||
|
} else {
|
||||||
|
showAlert("Keine Auswahl", "Bitte wählen Sie einen Piloten aus der Liste aus.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button backButton = new Button("Zurück");
|
||||||
|
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
VBox vbox = new VBox(10, label, pilotComboBox, selectBtn);
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
vbox.setPadding(new Insets(20));
|
||||||
|
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||||
|
|
||||||
|
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, 400, 300);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display(Pilot pilot) {
|
||||||
|
Label label = new Label(pilot == null ? "Pilotendaten eingeben:" : "Pilotendaten bearbeiten:");
|
||||||
|
TextField nameField = new TextField(pilot != null ? pilot.getName() : "");
|
||||||
|
TextField adresseField = new TextField(pilot != null ? pilot.getAdresse() : "");
|
||||||
|
TextField kontaktinformationenField = new TextField(pilot != null ? pilot.getKontaktinformationen() : "");
|
||||||
|
TextField lizenzField = new TextField();
|
||||||
|
TextField zertifikatField = new TextField();
|
||||||
|
|
||||||
|
nameField.setPromptText("Name");
|
||||||
|
adresseField.setPromptText("Adresse");
|
||||||
|
kontaktinformationenField.setPromptText("Kontaktinformationen");
|
||||||
|
lizenzField.setPromptText("Neue Lizenz");
|
||||||
|
zertifikatField.setPromptText("Neues Zertifikat");
|
||||||
|
|
||||||
|
ListView<String> lizenzListView = new ListView<>();
|
||||||
|
ListView<String> zertifikatListView = new ListView<>();
|
||||||
|
|
||||||
|
if (pilot != null) {
|
||||||
|
lizenzListView.getItems().addAll(pilot.getLizenzen());
|
||||||
|
zertifikatListView.getItems().addAll(pilot.getZertifikate());
|
||||||
|
}
|
||||||
|
|
||||||
|
Button addLizenzBtn = new Button("Lizenz hinzufügen");
|
||||||
|
addLizenzBtn.setOnAction(e -> {
|
||||||
|
if (!lizenzField.getText().isEmpty()) {
|
||||||
|
lizenzListView.getItems().add(lizenzField.getText());
|
||||||
|
lizenzField.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button addZertifikatBtn = new Button("Zertifikat hinzufügen");
|
||||||
|
addZertifikatBtn.setOnAction(e -> {
|
||||||
|
if (!zertifikatField.getText().isEmpty()) {
|
||||||
|
zertifikatListView.getItems().add(zertifikatField.getText());
|
||||||
|
zertifikatField.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button submitBtn = new Button(pilot == null ? "Hinzufügen" : "Speichern");
|
||||||
|
submitBtn.setStyle("-fx-background-color: #431EB9; -fx-text-fill: #FFFFFF;");
|
||||||
|
submitBtn.setOnAction(e -> handleSaveProfile(pilot, nameField, adresseField, kontaktinformationenField,
|
||||||
|
lizenzListView, zertifikatListView));
|
||||||
|
|
||||||
|
Button viewPilotsBtn = new Button("Alle Piloten anzeigen");
|
||||||
|
viewPilotsBtn.setOnAction(e -> new PilotView(stage).displayAllPilots());
|
||||||
|
|
||||||
|
Button backButton = new Button("Zurück");
|
||||||
|
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
VBox vbox = new VBox(10, label, nameField, adresseField, kontaktinformationenField, lizenzField, addLizenzBtn,
|
||||||
|
lizenzListView, zertifikatField, addZertifikatBtn, zertifikatListView, submitBtn, viewPilotsBtn);
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
vbox.setPadding(new Insets(20));
|
||||||
|
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||||
|
|
||||||
|
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, 400, 600);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleSaveProfile(Pilot pilot, TextField nameField, TextField adresseField,
|
||||||
|
TextField kontaktinformationenField, ListView<String> lizenzListView, ListView<String> zertifikatListView) {
|
||||||
|
clearFieldStyles(nameField, adresseField, kontaktinformationenField);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (nameField.getText().isEmpty()) {
|
||||||
|
setErrorStyle(nameField);
|
||||||
|
throw new IllegalArgumentException("Name ist erforderlich.");
|
||||||
|
}
|
||||||
|
if (adresseField.getText().isEmpty()) {
|
||||||
|
setErrorStyle(adresseField);
|
||||||
|
throw new IllegalArgumentException("Adresse ist erforderlich.");
|
||||||
|
}
|
||||||
|
if (kontaktinformationenField.getText().isEmpty()) {
|
||||||
|
setErrorStyle(kontaktinformationenField);
|
||||||
|
throw new IllegalArgumentException("Kontaktinformationen sind erforderlich.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pilot == null) {
|
||||||
|
pilot = new Pilot(nameField.getText(), adresseField.getText(), kontaktinformationenField.getText());
|
||||||
|
} else {
|
||||||
|
pilot.setName(nameField.getText());
|
||||||
|
pilot.setAdresse(adresseField.getText());
|
||||||
|
pilot.setKontaktinformationen(kontaktinformationenField.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
pilot.setLizenzen(new ArrayList<>(lizenzListView.getItems()));
|
||||||
|
pilot.setZertifikate(new ArrayList<>(zertifikatListView.getItems()));
|
||||||
|
|
||||||
|
Pilots pilots = (Pilots) XMLHelper.loadFromXML("pilots.xml");
|
||||||
|
if (pilots == null) {
|
||||||
|
pilots = new Pilots(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pilots.getPilots().contains(pilot)) {
|
||||||
|
pilots.getPilots().add(pilot);
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLHelper.saveToXML(pilots, "pilots.xml");
|
||||||
|
|
||||||
|
new HomeScreen(stage).display();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
showAlert("Fehlende Eingabe", e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
showAlert("Fehler", "Es ist ein Fehler beim Speichern des Piloten aufgetreten.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
package views;
|
||||||
|
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
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 PilotView {
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
|
public PilotView(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayPilotDetails(Pilot pilot) {
|
||||||
|
Label nameLabel = new Label("Name: " + pilot.getName());
|
||||||
|
Label adresseLabel = new Label("Adresse: " + pilot.getAdresse());
|
||||||
|
Label kontaktLabel = new Label("Kontaktinformationen: " + pilot.getKontaktinformationen());
|
||||||
|
Label lizenzenLabel = new Label("Lizenzen: " + String.join(", ", pilot.getLizenzen()));
|
||||||
|
Label zertifikateLabel = new Label("Zertifikate: " + String.join(", ", pilot.getZertifikate()));
|
||||||
|
|
||||||
|
VBox vbox = new VBox(10, nameLabel, adresseLabel, kontaktLabel, lizenzenLabel, zertifikateLabel);
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
vbox.setPadding(new Insets(20));
|
||||||
|
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||||
|
|
||||||
|
Button backButton = new Button("Zurück");
|
||||||
|
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
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, 400, 300);
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("Pilot Details");
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayAllPilots() {
|
||||||
|
Pilots pilotsData = (Pilots) XMLHelper.loadFromXML("pilots.xml");
|
||||||
|
List<Pilot> pilots = pilotsData != null ? pilotsData.getPilots() : List.of();
|
||||||
|
|
||||||
|
VBox vbox = new VBox(10);
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
vbox.setPadding(new Insets(20));
|
||||||
|
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||||
|
|
||||||
|
for (Pilot pilot : pilots) {
|
||||||
|
Label nameLabel = new Label("Name: " + pilot.getName());
|
||||||
|
vbox.getChildren().add(nameLabel);
|
||||||
|
|
||||||
|
Button detailButton = new Button("Details anzeigen");
|
||||||
|
detailButton.setOnAction(e -> displayPilotDetails(pilot));
|
||||||
|
vbox.getChildren().add(detailButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
Button backButton = new Button("Zurück");
|
||||||
|
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
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, 400, 300);
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("Alle Piloten");
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package views;
|
||||||
|
|
||||||
|
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.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import models.Flight;
|
||||||
|
import models.Flights;
|
||||||
|
import utils.XMLHelper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ViewLogbookScreen {
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
|
public ViewLogbookScreen(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
Flights flightsData = (Flights) XMLHelper.loadFromXML("flights.xml");
|
||||||
|
List<Flight> flightList = flightsData != null ? flightsData.getFlights() : List.of();
|
||||||
|
|
||||||
|
ObservableList<Flight> flights = FXCollections.observableArrayList(flightList);
|
||||||
|
|
||||||
|
TableView<Flight> tableView = new TableView<>(flights);
|
||||||
|
|
||||||
|
TableColumn<Flight, String> dateColumn = new TableColumn<>("Datum");
|
||||||
|
dateColumn.setCellValueFactory(new PropertyValueFactory<>("datum"));
|
||||||
|
|
||||||
|
TableColumn<Flight, String> modelColumn = new TableColumn<>("Muster");
|
||||||
|
modelColumn.setCellValueFactory(new PropertyValueFactory<>("muster"));
|
||||||
|
|
||||||
|
TableColumn<Flight, String> departureColumn = new TableColumn<>("Abflugort");
|
||||||
|
departureColumn.setCellValueFactory(new PropertyValueFactory<>("abflugort"));
|
||||||
|
|
||||||
|
TableColumn<Flight, String> departureTimeColumn = new TableColumn<>("Abflugzeit");
|
||||||
|
departureTimeColumn.setCellValueFactory(new PropertyValueFactory<>("abflugzeit"));
|
||||||
|
|
||||||
|
TableColumn<Flight, String> arrivalTimeColumn = new TableColumn<>("Ankunftszeit");
|
||||||
|
arrivalTimeColumn.setCellValueFactory(new PropertyValueFactory<>("ankunftszeit"));
|
||||||
|
|
||||||
|
TableColumn<Flight, Double> durationColumn = new TableColumn<>("Flugdauer");
|
||||||
|
durationColumn.setCellValueFactory(new PropertyValueFactory<>("tToF"));
|
||||||
|
|
||||||
|
TableColumn<Flight, Integer> landingsColumn = new TableColumn<>("Anzahl der Landungen");
|
||||||
|
landingsColumn.setCellValueFactory(new PropertyValueFactory<>("anzahlLandungen"));
|
||||||
|
|
||||||
|
TableColumn<Flight, Boolean> nightFlightColumn = new TableColumn<>("Nachtflug");
|
||||||
|
nightFlightColumn.setCellValueFactory(new PropertyValueFactory<>("isNachtflug"));
|
||||||
|
|
||||||
|
TableColumn<Flight, String> commentColumn = new TableColumn<>("Kommentar");
|
||||||
|
commentColumn.setCellValueFactory(new PropertyValueFactory<>("kommentar"));
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
Button backButton = new Button("Zurück");
|
||||||
|
backButton.setOnAction(e -> new HomeScreen(stage).display());
|
||||||
|
|
||||||
|
VBox vbox = new VBox(tableView);
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
vbox.setPadding(new Insets(20));
|
||||||
|
vbox.setStyle("-fx-background-color: #FFFFFF;");
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("Fluglogbuch einsehen");
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
}
|
||||||