Letzte bugfixe und änderungen an Namen

master
Maximilian 2024-06-20 12:23:30 +02:00
parent e94e6d7bf5
commit 58146c3f5a
29 changed files with 287 additions and 217 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,22 +5,22 @@
<void method="add">
<object class="models.Flight">
<void property="TToF">
<double>1.0</double>
<double>2.0</double>
</void>
<void property="abflugort">
<string>123</string>
<string>ad</string>
</void>
<void property="abflugzeit">
<string>12:00</string>
</void>
<void property="ankunftszeit">
<string>13:00</string>
</void>
<void property="ankunftszeit">
<string>15:00</string>
</void>
<void property="anzahlLandungen">
<int>12</int>
<int>2</int>
</void>
<void property="datumStr">
<string>2024-06-17</string>
<string>2024-06-20</string>
</void>
<void property="kommentar">
<string>asd</string>
@ -29,25 +29,15 @@
<string>asd</string>
</void>
<void property="pilot">
<object class="models.Pilot" id="Pilot0">
<object class="models.Pilot">
<void property="adresse">
<string>asd</string>
</void>
<void property="kontaktinformationen">
<string>asd</string>
</void>
<void property="lizenzen">
<void method="add">
<string>dasd</string>
</void>
</void>
<void property="name">
<string>asdaa</string>
</void>
<void property="zertifikate">
<void method="add">
<string>asdasd</string>
</void>
<string>asd</string>
</void>
</object>
</void>
@ -68,19 +58,19 @@
<string>13:00</string>
</void>
<void property="anzahlLandungen">
<int>15</int>
<int>1</int>
</void>
<void property="datumStr">
<string>2024-06-17</string>
</void>
<void property="kommentar">
<string>asd</string>
<string>asdsss</string>
</void>
<void property="muster">
<string>asdtest</string>
</void>
<void property="pilot">
<object class="models.Pilot" id="Pilot1">
<object class="models.Pilot" id="Pilot0">
<void property="adresse">
<string>asd</string>
</void>
@ -131,7 +121,7 @@
<string>asdtest</string>
</void>
<void property="pilot">
<object class="models.Pilot" id="Pilot2">
<object class="models.Pilot" id="Pilot1">
<void property="adresse">
<string>asd</string>
</void>
@ -155,6 +145,211 @@
</void>
</object>
</void>
<void method="add">
<object class="models.Flight">
<void property="TToF">
<double>1.0</double>
</void>
<void property="abflugort">
<string>Max</string>
</void>
<void property="abflugzeit">
<string>12:00</string>
</void>
<void property="ankunftszeit">
<string>13:00</string>
</void>
<void property="anzahlLandungen">
<int>2</int>
</void>
<void property="datumStr">
<string>2024-06-20</string>
</void>
<void property="kommentar">
<string>t</string>
</void>
<void property="muster">
<string>Max</string>
</void>
<void property="pilot">
<object class="models.Pilot">
<void property="adresse">
<string>asd</string>
</void>
<void property="kontaktinformationen">
<string>asd</string>
</void>
<void property="name">
<string>asd</string>
</void>
</object>
</void>
</object>
</void>
<void method="add">
<object class="models.Flight">
<void property="TToF">
<double>1.0</double>
</void>
<void property="abflugort">
<string>Max</string>
</void>
<void property="abflugzeit">
<string>12:00</string>
</void>
<void property="ankunftszeit">
<string>13:00</string>
</void>
<void property="anzahlLandungen">
<int>2</int>
</void>
<void property="datumStr">
<string>2024-06-20</string>
</void>
<void property="kommentar">
<string>t</string>
</void>
<void property="muster">
<string>Max2</string>
</void>
<void property="pilot">
<object class="models.Pilot">
<void property="adresse">
<string>asd</string>
</void>
<void property="kontaktinformationen">
<string>asd</string>
</void>
<void property="name">
<string>asd</string>
</void>
</object>
</void>
</object>
</void>
<void method="add">
<object class="models.Flight">
<void property="TToF">
<double>1.0</double>
</void>
<void property="abflugort">
<string>asd</string>
</void>
<void property="abflugzeit">
<string>12:00</string>
</void>
<void property="ankunftszeit">
<string>13:00</string>
</void>
<void property="anzahlLandungen">
<int>2</int>
</void>
<void property="datumStr">
<string>2024-06-20</string>
</void>
<void property="kommentar">
<string>asd</string>
</void>
<void property="muster">
<string>asd22222</string>
</void>
<void property="pilot">
<object class="models.Pilot">
<void property="adresse">
<string>asd</string>
</void>
<void property="kontaktinformationen">
<string>asd</string>
</void>
<void property="name">
<string>asd</string>
</void>
</object>
</void>
</object>
</void>
<void method="add">
<object class="models.Flight">
<void property="TToF">
<double>1.0</double>
</void>
<void property="abflugort">
<string>asd</string>
</void>
<void property="abflugzeit">
<string>12:00</string>
</void>
<void property="ankunftszeit">
<string>13:00</string>
</void>
<void property="anzahlLandungen">
<int>2</int>
</void>
<void property="datumStr">
<string>2024-06-20</string>
</void>
<void property="kommentar">
<string>asd</string>
</void>
<void property="muster">
<string>5</string>
</void>
<void property="pilot">
<object class="models.Pilot">
<void property="adresse">
<string>asd</string>
</void>
<void property="kontaktinformationen">
<string>asd</string>
</void>
<void property="name">
<string>asd</string>
</void>
</object>
</void>
</object>
</void>
<void method="add">
<object class="models.Flight">
<void property="TToF">
<double>1.0</double>
</void>
<void property="abflugort">
<string>rr</string>
</void>
<void property="abflugzeit">
<string>14:00</string>
</void>
<void property="ankunftszeit">
<string>15:00</string>
</void>
<void property="anzahlLandungen">
<int>2</int>
</void>
<void property="datumStr">
<string>2024-06-20</string>
</void>
<void property="kommentar">
<string>asd</string>
</void>
<void property="muster">
<string>rrr</string>
</void>
<void property="pilot">
<object class="models.Pilot">
<void property="adresse">
<string>asd</string>
</void>
<void property="kontaktinformationen">
<string>asd</string>
</void>
<void property="name">
<string>asd</string>
</void>
</object>
</void>
</object>
</void>
</void>
</object>
</java>

View File

@ -15,42 +15,6 @@
</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>dasd</string>
</void>
</void>
<void property="name">
<string>asdaa</string>
</void>
<void property="zertifikate">
<void method="add">
<string>asdasd</string>
</void>
</void>
</object>
</void>
<void method="add">
<object class="models.Pilot">
<void property="adresse">
<string>s</string>
</void>
<void property="kontaktinformationen">
<string>d</string>
</void>
<void property="name">
<string>a</string>
</void>
</object>
</void>
</void>
</object>
</java>

View File

@ -3,13 +3,12 @@ package controllers;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.*;
import javafx.stage.Stage;
import models.Flight;
import models.Flights;
import models.Pilot;
import models.Pilots;
import utils.XMLHelper;
import views.HomeScreen;
import java.time.Duration;
import java.time.LocalTime;
@ -20,11 +19,10 @@ import java.util.List;
public class AddFlightController {
private Flights flights;
private Stage stage;
private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
public AddFlightController(Stage stage) {
this.stage = stage;
public AddFlightController() {
loadFlights();
}
@ -38,44 +36,6 @@ public class AddFlightController {
return pilotList;
}
public void saveFlight(Flight newFlight, DatePicker datumField, TextField musterField, TextField abflugortField,
TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField, TextField anzahlLandungenField,
ComboBox<Pilot> pilotComboBox, CheckBox nachtflugBox, TextField kommentarField) {
try {
double flightDuration = Double.parseDouble(tToFField.getText().replace(',', '.'));
int landings = Integer.parseInt(anzahlLandungenField.getText());
boolean isNachtflug = nachtflugBox.isSelected();
newFlight.setDatum(datumField.getValue());
newFlight.setMuster(musterField.getText());
newFlight.setAbflugort(abflugortField.getText());
newFlight.setAbflugzeit(abflugzeitField.getText());
newFlight.setAnkunftszeit(ankunftszeitField.getText());
newFlight.setTToF(flightDuration);
newFlight.setAnzahlLandungen(landings);
newFlight.setPilot(pilotComboBox.getValue());
newFlight.setNachtflug(isNachtflug);
newFlight.setKommentar(kommentarField.getText());
newFlight.setDatumStr(datumField.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE));
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();
}
}
public void saveFlight(Flight flight){
if(flights == null){
flights = new Flights(new ArrayList<>());

View File

@ -27,13 +27,9 @@ public class DeletePilotController {
public boolean deletePilot(Pilot pilot) {
if (pilot != null) {
// Create a new list to avoid modifying the observable list directly
List<Pilot> updatedList = new java.util.ArrayList<>(pilotsList);
// Remove the selected pilot from the list
updatedList.remove(pilot);
// Save the updated list back to the XML file
XMLHelper.saveToXML(new Pilots(updatedList), "pilots.xml");
// Reload the pilots list to update the observable list
loadPilots();
return true;
}

View File

@ -6,8 +6,7 @@ import javafx.stage.Stage;
import models.Flight;
import models.Flights;
import utils.XMLHelper;
import views.HomeScreen;
import views.ViewLogbookScreen;
import views.HomeScreenView;
public class LogbookController {
private Stage stage;
@ -31,12 +30,6 @@ public class LogbookController {
}
}
/* public void editFlight(Flight flight) {
if (flight != null) {
new EditFlightScreen(stage, flight, this).display();
}
} */
public void updateFlight(Flight updatedFlight) {
for (int i = 0; i < flightList.size(); i++) {
if (flightList.get(i).getId().equals(updatedFlight.getId())) {
@ -53,6 +46,6 @@ public class LogbookController {
}
public void goBack() {
new HomeScreen(stage).display();
new HomeScreenView(stage).display();
}
}

View File

@ -1,8 +1,5 @@
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;
@ -12,9 +9,9 @@ import javafx.beans.property.*;
public class Flight implements Serializable {
private static final long serialVersionUID = 1L;
private String id; // Neue ID für jeden Flug
private String datumStr; // String zur Speicherung des Datums in XML
private transient ObjectProperty<LocalDate> datum; // transient, um die direkte Serialization zu vermeiden
private String id;
private String datumStr;
private transient ObjectProperty<LocalDate> datum;
private StringProperty muster;
private StringProperty abflugort;
private StringProperty abflugzeit;
@ -27,9 +24,8 @@ public class Flight implements Serializable {
private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
// Standardkonstruktor
public Flight() {
this.id = UUID.randomUUID().toString(); // Generiere eine eindeutige ID
this.id = UUID.randomUUID().toString();
this.datum = new SimpleObjectProperty<>();
this.muster = new SimpleStringProperty();
this.abflugort = new SimpleStringProperty();
@ -42,8 +38,6 @@ public class Flight implements Serializable {
this.kommentar = new SimpleStringProperty();
}
// Getter und Setter Methoden
public String getId() {
return id;
}
@ -63,7 +57,8 @@ public class Flight implements Serializable {
public void setDatumStr(String datumStr) {
this.datumStr = datumStr;
this.datum = datumStr != null ? new SimpleObjectProperty<>(LocalDate.parse(datumStr, formatter)) : new SimpleObjectProperty<>();
this.datum = datumStr != null ? new SimpleObjectProperty<>(LocalDate.parse(datumStr, formatter))
: new SimpleObjectProperty<>();
}
public ObjectProperty<LocalDate> datumProperty() {
@ -181,21 +176,11 @@ public class Flight implements Serializable {
public String getPilotInformationen() {
Pilot pilot = getPilot();
if (pilot != null) {
return "Name: " + pilot.getName() + ", Adresse: " + pilot.getAdresse() + ", Kontaktinformationen: " + pilot.getKontaktinformationen();
return "Name: " + pilot.getName() + ", Adresse: " + pilot.getAdresse() + ", Kontaktinformationen: "
+ pilot.getKontaktinformationen();
}
return "Keine Pilotinformationen verfügbar";
}
// Custom Serialization
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
oos.writeObject(datumStr);
}
// Custom Deserialization
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
datumStr = (String) ois.readObject();
datum = datumStr != null ? new SimpleObjectProperty<>(LocalDate.parse(datumStr, formatter)) : new SimpleObjectProperty<>();
}
}

View File

@ -15,7 +15,7 @@ public class Pilot implements Serializable {
private List<String> lizenzen;
private List<String> zertifikate;
// Standardkonstruktor
public Pilot() {
this.name = new SimpleStringProperty();
this.adresse = new SimpleStringProperty();

View File

@ -2,12 +2,12 @@ package program;
import javafx.application.Application;
import javafx.stage.Stage;
import views.HomeScreen;
import views.HomeScreenView;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
HomeScreen homeScreen = new HomeScreen(primaryStage);
HomeScreenView homeScreen = new HomeScreenView(primaryStage);
homeScreen.display();
}
@ -15,3 +15,4 @@ public class Main extends Application {
launch(args);
}
}

View File

@ -4,21 +4,8 @@ import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.*;
import models.Flight;
import models.Flights;
public class XMLHelper {
private static final String FLIGHTS_XML = "flights.xml";
/* public static Flights loadFlights() {
// Implement loading flights from XML
return (Flights) loadFromXML(FLIGHTS_XML);
}
public static void saveFlights(Flights flights) {
saveToXML(flights, FLIGHTS_XML);
} */
public static void saveToXML(Object obj, String filePath) {
try (XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(filePath)))) {

View File

@ -11,15 +11,14 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import models.Flight;
import models.Flights;
import models.Pilot;
import utils.XMLHelper;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
public class AddFlightScreen {
public class AddFlightView {
private Stage stage;
private AddFlightController controller;
private Flight flight;
@ -35,10 +34,10 @@ public class AddFlightScreen {
private TextField kommentarField;
private ComboBox<Pilot> pilotComboBox;
public AddFlightScreen(Stage stage, Flight flight) {
public AddFlightView(Stage stage, Flight flight) {
this.stage = stage;
this.flight = flight;
this.controller = new AddFlightController(stage);
this.controller = new AddFlightController();
}
public void display() {
@ -67,8 +66,8 @@ public class AddFlightScreen {
Label tToFLabel = new Label("Flugdauer (Stunden):");
tToFField = new TextField();
tToFField.setPromptText("Flugdauer (Stunden)");
tToFField.setEditable(false); // Make the field read-only
tToFField.setStyle("-fx-control-inner-background: #E0E0E0;"); // Gray out the field
tToFField.setEditable(false);
tToFField.setStyle("-fx-control-inner-background: #E0E0E0;");
Label anzahlLandungenLabel = new Label("Anzahl der Landungen:");
anzahlLandungenField = new TextField();
@ -87,14 +86,13 @@ public class AddFlightScreen {
Button saveBtn = new Button("Speichern");
saveBtn.setOnAction(e -> saveFlight(flight, datumField, musterField, abflugortField, abflugzeitField,
ankunftszeitField, tToFField, anzahlLandungenField, pilotComboBox, nachtflugBox, kommentarField));//todo: saveFlight in Controller
saveBtn.setOnAction(e -> saveFlight());
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());
backButton.setOnAction(e -> new HomeScreenView(stage).display());
// Add listeners to the time fields to update the flight duration automatically
abflugzeitField.textProperty().addListener((observable, oldValue, newValue) -> updateFlightDuration(abflugzeitField, ankunftszeitField, tToFField));
ankunftszeitField.textProperty().addListener((observable, oldValue, newValue) -> updateFlightDuration(abflugzeitField, ankunftszeitField, tToFField));
@ -177,10 +175,9 @@ public class AddFlightScreen {
pilotComboBox.setValue(flight.getPilot());
}
private void saveFlight(Flight newFlight, DatePicker datumField, TextField musterField, TextField abflugortField,
TextField abflugzeitField, TextField ankunftszeitField, TextField tToFField, TextField anzahlLandungenField,
ComboBox<Pilot> pilotComboBox, CheckBox nachtflugBox, TextField kommentarField) {
private void saveFlight() {
try {
Flight newFlight = (flight != null) ? flight : new Flight();
double flightDuration = Double.parseDouble(tToFField.getText().replace(',', '.'));
int landings = Integer.parseInt(anzahlLandungenField.getText());
boolean isNachtflug = nachtflugBox.isSelected();
@ -199,7 +196,7 @@ public class AddFlightScreen {
controller.saveFlight(newFlight);
new HomeScreen(stage).display();
new HomeScreenView(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) {
@ -209,6 +206,7 @@ public class AddFlightScreen {
e.printStackTrace();
}
}
private void showAlert(String title, String message) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);

View File

@ -13,11 +13,11 @@ import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import models.Pilot;
public class DeletePilotScreen {
public class DeletePilotView {
private Stage stage;
private DeletePilotController controller;
public DeletePilotScreen(Stage stage) {
public DeletePilotView(Stage stage) {
this.stage = stage;
this.controller = new DeletePilotController();
}
@ -43,7 +43,7 @@ public class DeletePilotScreen {
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());
backButton.setOnAction(e -> new HomeScreenView(stage).display());
VBox vbox = new VBox(10, label, pilotComboBox, deleteBtn);
vbox.setAlignment(Pos.CENTER);

View File

@ -9,10 +9,10 @@ import javafx.scene.control.TextArea;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class HelpScreen {
public class HelpView {
private Stage stage;
public HelpScreen(Stage stage) {
public HelpView(Stage stage) {
this.stage = stage;
}
@ -27,7 +27,7 @@ public class HelpScreen {
Button backBtn = new Button("Zurück");
backBtn.setOnAction(e -> new HomeScreen(stage).display());
backBtn.setOnAction(e -> new HomeScreenView(stage).display());
VBox vbox = new VBox(10, label, helpText, backBtn);
vbox.setAlignment(Pos.CENTER);

View File

@ -17,10 +17,10 @@ import javafx.stage.Stage;
import models.Pilots;
import utils.XMLHelper;
public class HomeScreen {
public class HomeScreenView {
private Stage stage;
public HomeScreen(Stage stage) {
public HomeScreenView(Stage stage) {
this.stage = stage;
}
@ -36,15 +36,15 @@ public class HomeScreen {
Button helpBtn = createHelpButton("/resources/icons/help_icon.png", "Hilfe anzeigen");
Button editPilotsBtn = createButton("Pilot bearbeiten", "/resources/icons/manage_pilot_icon.png", "Bearbeiten Sie ein Pilotenprofil");
btn1.setOnAction(e -> new AddFlightScreen(stage, null).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());
btn1.setOnAction(e -> new AddFlightView(stage, null).display());
btn2.setOnAction(e -> new ViewLogbookView(stage).display());
btn3.setOnAction(e -> new ManagePilotProfileView(stage).display());
btn4.setOnAction(e -> new DeletePilotView(stage).display());
helpBtn.setOnAction(e -> new HelpView(stage).display());
editPilotsBtn.setOnAction(e -> {
Pilots pilots = (Pilots) XMLHelper.loadFromXML("pilots.xml");
if (pilots != null && !pilots.getPilots().isEmpty()) {
new ManagePilotProfileScreen(stage).displayEditSelection(); // Aufruf mit Pilotenliste
new ManagePilotProfileView(stage).displayEditSelection(); // Aufruf mit Pilotenliste
} else {
showAlert("Keine Piloten", "Es sind keine Piloten zum Bearbeiten verfügbar.");
}
@ -103,9 +103,9 @@ public class HomeScreen {
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
button.setShape(new Circle(25));
button.setMinSize(50, 50);
button.setMaxSize(50, 50);
return button;
}

View File

@ -6,18 +6,17 @@ 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 java.util.ArrayList;
public class ManagePilotProfileScreen {
public class ManagePilotProfileView {
private Stage stage;
private ManagePilotProfileController controller;
public ManagePilotProfileScreen(Stage stage) {
public ManagePilotProfileView(Stage stage) {
this.stage = stage;
this.controller = new ManagePilotProfileController();
}
@ -43,7 +42,7 @@ public class ManagePilotProfileScreen {
});
Button backButton = new Button("Zurück");
backButton.setOnAction(e -> new HomeScreen(stage).display());
backButton.setOnAction(e -> new HomeScreenView(stage).display());
VBox vbox = new VBox(10, label, pilotComboBox, selectBtn);
vbox.setAlignment(Pos.CENTER);
@ -108,17 +107,20 @@ public class ManagePilotProfileScreen {
});
Button saveBtn = new Button("Speichern");
saveBtn.setOnAction(e -> savePilot(pilot, nameField, adresseField, kontaktinformationenField, lizenzListView, zertifikatListView));
saveBtn.setOnAction(e -> savePilot(pilot, nameField, adresseField, kontaktinformationenField, lizenzListView,
zertifikatListView));
Button backButton = new Button("Zurück");
backButton.setOnAction(e -> new HomeScreen(stage).display());
backButton.setOnAction(e -> new HomeScreenView(stage).display());
VBox lizenzBox = new VBox(10, new Label("Lizenzen"), lizenzListView, lizenzField, addLizenzButton);
lizenzBox.setAlignment(Pos.CENTER);
VBox zertifikatBox = new VBox(10, new Label("Zertifikate"), zertifikatListView, zertifikatField, addZertifikatButton);
VBox zertifikatBox = new VBox(10, new Label("Zertifikate"), zertifikatListView, zertifikatField,
addZertifikatButton);
zertifikatBox.setAlignment(Pos.CENTER);
VBox vbox = new VBox(10, label, nameField, adresseField, kontaktinformationenField, lizenzBox, zertifikatBox, saveBtn);
VBox vbox = new VBox(10, label, nameField, adresseField, kontaktinformationenField, lizenzBox, zertifikatBox,
saveBtn);
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(20));
@ -135,7 +137,8 @@ public class ManagePilotProfileScreen {
stage.show();
}
private void savePilot(Pilot pilot, TextField nameField, TextField adresseField, TextField kontaktinformationenField,
private void savePilot(Pilot pilot, TextField nameField, TextField adresseField,
TextField kontaktinformationenField,
ListView<String> lizenzListView, ListView<String> zertifikatListView) {
clearFieldStyles(nameField, adresseField, kontaktinformationenField);
@ -166,7 +169,7 @@ public class ManagePilotProfileScreen {
controller.savePilot(pilot);
new HomeScreen(stage).display();
new HomeScreenView(stage).display();
} catch (IllegalArgumentException e) {
showAlert("Fehlende Eingabe", e.getMessage());
} catch (Exception e) {

View File

@ -1,6 +1,5 @@
package views;
import controllers.AddFlightController;
import controllers.LogbookController;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ObservableList;
@ -8,7 +7,7 @@ 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;
@ -16,16 +15,16 @@ import models.Flight;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class ViewLogbookScreen {
public class ViewLogbookView {
private Stage stage;
private LogbookController controller;
private AddFlightController addFlightController;
public ViewLogbookScreen(Stage stage) {
public ViewLogbookView(Stage stage) {
this.stage = stage;
this.controller = new LogbookController(stage);
}
@SuppressWarnings("unchecked")
public void display() {
Label label = new Label("Fluglogbuch Pegasus");
label.setStyle(
@ -74,23 +73,12 @@ public class ViewLogbookScreen {
ObservableList<Flight> flightList = controller.getFlightList();
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();
* controller.editFlight(selectedFlight);
* });
*/
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) {
AddFlightScreen addFlightScreen = new AddFlightScreen(stage, selectedFlight);
AddFlightView addFlightScreen = new AddFlightView(stage, selectedFlight);
addFlightScreen.display();
}
});