diff --git a/bin/controllers/FlightController.class b/bin/controllers/FlightController.class index 520767c..43dc06a 100644 Binary files a/bin/controllers/FlightController.class and b/bin/controllers/FlightController.class differ diff --git a/bin/resources/icons/exit_icon.png b/bin/resources/icons/exit_icon.png new file mode 100644 index 0000000..57ce87c Binary files /dev/null and b/bin/resources/icons/exit_icon.png differ diff --git a/bin/views/AddFlightScreen.class b/bin/views/AddFlightScreen.class index 009fef8..5e67197 100644 Binary files a/bin/views/AddFlightScreen.class and b/bin/views/AddFlightScreen.class differ diff --git a/bin/views/DeletePilotScreen.class b/bin/views/DeletePilotScreen.class index 53c2289..e660159 100644 Binary files a/bin/views/DeletePilotScreen.class and b/bin/views/DeletePilotScreen.class differ diff --git a/bin/views/EditFlightScreen.class b/bin/views/EditFlightScreen.class index 0e6714b..1de65f9 100644 Binary files a/bin/views/EditFlightScreen.class and b/bin/views/EditFlightScreen.class differ diff --git a/bin/views/HelpScreen.class b/bin/views/HelpScreen.class index 9e6b3ab..1befc0f 100644 Binary files a/bin/views/HelpScreen.class and b/bin/views/HelpScreen.class differ diff --git a/bin/views/HomeScreen.class b/bin/views/HomeScreen.class index 6ba4a86..91a52f9 100644 Binary files a/bin/views/HomeScreen.class and b/bin/views/HomeScreen.class differ diff --git a/bin/views/ManagePilotProfileScreen.class b/bin/views/ManagePilotProfileScreen.class index 656ab6a..943f243 100644 Binary files a/bin/views/ManagePilotProfileScreen.class and b/bin/views/ManagePilotProfileScreen.class differ diff --git a/bin/views/PilotView.class b/bin/views/PilotView.class index db9216a..40c74d6 100644 Binary files a/bin/views/PilotView.class and b/bin/views/PilotView.class differ diff --git a/pilots.xml b/pilots.xml index efef9b4..09938fb 100644 --- a/pilots.xml +++ b/pilots.xml @@ -29,15 +29,23 @@ - + - asdasd + sad - 23 + ads + + + + äää + + + äää + - adsasd + sad diff --git a/src/controllers/FlightController.java b/src/controllers/FlightController.java index 47fd6d4..c640bf5 100644 --- a/src/controllers/FlightController.java +++ b/src/controllers/FlightController.java @@ -1,28 +1,46 @@ package controllers; -import java.time.LocalDate; +import java.time.Duration; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; -import models.Flight; -import views.FlightView; +import javafx.scene.control.Alert; +import javafx.scene.control.Control; public class FlightController { - private Flight model; - private FlightView view; + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); - public FlightController(Flight model, FlightView view) { - this.model = model; - this.view = view; + public double calculateFlightDuration(String abflugzeit, String ankunftszeit) throws DateTimeParseException { + LocalTime start = LocalTime.parse(abflugzeit, timeFormatter); + LocalTime end = LocalTime.parse(ankunftszeit, timeFormatter); + return (double) Duration.between(start, end).toMinutes() / 60; } - public void setFlightDatum(LocalDate datum) { - model.setDatum(datum); + public boolean isValidTime(String time) { + try { + LocalTime.parse(time, timeFormatter); + return true; + } catch (DateTimeParseException e) { + return false; + } } - public LocalDate getFlightDatum() { - return model.getDatum(); + public void setErrorStyle(Control field) { + field.setStyle("-fx-border-color: red;"); } - public void updateView() { - view.displayFlightDetails(model); + public void clearFieldStyles(Control... fields) { + for (Control field : fields) { + field.setStyle(null); + } + } + + public void showAlert(String title, String message) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(message); + alert.showAndWait(); } } diff --git a/src/resources/icons/exit_icon.png b/src/resources/icons/exit_icon.png new file mode 100644 index 0000000..57ce87c Binary files /dev/null and b/src/resources/icons/exit_icon.png differ diff --git a/src/views/AddFlightScreen.java b/src/views/AddFlightScreen.java index b01e383..64b9552 100644 --- a/src/views/AddFlightScreen.java +++ b/src/views/AddFlightScreen.java @@ -120,7 +120,7 @@ public class AddFlightScreen { vbox.getChildren().add(addPilotBtn); } - Scene scene = new Scene(borderPane, 800, 700); + Scene scene = new Scene(borderPane, 800, 600); scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); stage.setScene(scene); diff --git a/src/views/DeletePilotScreen.java b/src/views/DeletePilotScreen.java index 6866599..baf69fd 100644 --- a/src/views/DeletePilotScreen.java +++ b/src/views/DeletePilotScreen.java @@ -52,7 +52,7 @@ public class DeletePilotScreen { 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); diff --git a/src/views/EditFlightScreen.java b/src/views/EditFlightScreen.java index 95efa8b..0c3b638 100644 --- a/src/views/EditFlightScreen.java +++ b/src/views/EditFlightScreen.java @@ -72,7 +72,7 @@ public class EditFlightScreen { 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); @@ -80,7 +80,7 @@ public class EditFlightScreen { BorderPane.setAlignment(backButton, Pos.TOP_LEFT); BorderPane.setMargin(backButton, new Insets(10)); - Scene scene = new Scene(borderPane, 800, 700); + Scene scene = new Scene(borderPane, 800, 600); scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); stage.setScene(scene); diff --git a/src/views/HelpScreen.java b/src/views/HelpScreen.java index 0d5785d..a08459d 100644 --- a/src/views/HelpScreen.java +++ b/src/views/HelpScreen.java @@ -26,15 +26,15 @@ public class HelpScreen { 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); + Scene scene = new Scene(vbox, 800, 600); scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); stage.setScene(scene); diff --git a/src/views/HomeScreen.java b/src/views/HomeScreen.java index 2939543..ba2ebca 100644 --- a/src/views/HomeScreen.java +++ b/src/views/HomeScreen.java @@ -31,18 +31,16 @@ public class HomeScreen { 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 btn3 = createButton("Piloten anlegen", "/resources/icons/edit_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"); + Button editPilotsBtn = createButton("Pilot bearbeiten", "/resources/icons/manage_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 -> { Pilots pilots = (Pilots) XMLHelper.loadFromXML("pilots.xml"); if (pilots != null && !pilots.getPilots().isEmpty()) { @@ -51,6 +49,8 @@ public class HomeScreen { showAlert("Keine Piloten", "Es sind keine Piloten zum Bearbeiten verfügbar."); } }); + Button exitBtn = createButton("Exit", "/resources/icons/exit_icon.png", "Exit the application"); + exitBtn.setOnAction(e -> stage.close()); GridPane gridPane = new GridPane(); gridPane.setPadding(new Insets(20)); @@ -60,9 +60,9 @@ public class HomeScreen { 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); + gridPane.add(editPilotsBtn, 1, 1); + gridPane.add(btn4, 0, 2); + gridPane.add(exitBtn, 1, 2); VBox vbox = new VBox(20, title, gridPane); vbox.setAlignment(Pos.CENTER); diff --git a/src/views/ManagePilotProfileScreen.java b/src/views/ManagePilotProfileScreen.java index 8e7a4f4..253c5b3 100644 --- a/src/views/ManagePilotProfileScreen.java +++ b/src/views/ManagePilotProfileScreen.java @@ -46,7 +46,7 @@ public class ManagePilotProfileScreen { 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); @@ -54,7 +54,7 @@ public class ManagePilotProfileScreen { BorderPane.setAlignment(backButton, Pos.TOP_LEFT); BorderPane.setMargin(backButton, new Insets(10)); - Scene scene = new Scene(borderPane, 400, 300); + Scene scene = new Scene(borderPane, 800, 600); scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); @@ -101,7 +101,7 @@ public class ManagePilotProfileScreen { }); 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)); @@ -115,7 +115,7 @@ public class ManagePilotProfileScreen { 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); @@ -123,7 +123,7 @@ public class ManagePilotProfileScreen { BorderPane.setAlignment(backButton, Pos.TOP_LEFT); BorderPane.setMargin(backButton, new Insets(10)); - Scene scene = new Scene(borderPane, 400, 600); + Scene scene = new Scene(borderPane, 800, 600); scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); stage.setScene(scene); diff --git a/src/views/PilotView.java b/src/views/PilotView.java index f577445..20ce787 100644 --- a/src/views/PilotView.java +++ b/src/views/PilotView.java @@ -5,6 +5,7 @@ import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; @@ -31,7 +32,7 @@ public class PilotView { 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()); @@ -42,7 +43,8 @@ public class PilotView { BorderPane.setAlignment(backButton, Pos.TOP_LEFT); BorderPane.setMargin(backButton, new Insets(10)); - Scene scene = new Scene(borderPane, 400, 300); + Scene scene = new Scene(borderPane, 800, 600); // Fenstergröße angepasst + scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); stage.setScene(scene); stage.setTitle("Pilot Details"); stage.show(); @@ -53,31 +55,27 @@ public class PilotView { List 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); + Label pilotLabel = new Label(pilot.getName()); + vbox.getChildren().add(pilotLabel); } + ScrollPane scrollPane = new ScrollPane(vbox); // ScrollPane hinzugefügt + scrollPane.setFitToWidth(true); + scrollPane.setFitToHeight(true); + Button backButton = new Button("Zurück"); backButton.setOnAction(e -> new HomeScreen(stage).display()); BorderPane borderPane = new BorderPane(); borderPane.setTop(backButton); - borderPane.setCenter(vbox); + borderPane.setCenter(scrollPane); // ScrollPane anstelle von VBox hinzugefügt BorderPane.setAlignment(backButton, Pos.TOP_LEFT); BorderPane.setMargin(backButton, new Insets(10)); - Scene scene = new Scene(borderPane, 400, 300); - scene.getStylesheets().add(getClass().getResource("/resources/styles.css").toExternalForm()); - + Scene scene = new Scene(borderPane, 800, 600); // Fenstergröße angepasst stage.setScene(scene); stage.setTitle("Alle Piloten"); stage.show();