diff --git a/bin/controllers/AddFlightController.class b/bin/controllers/AddFlightController.class index d8dc47d..d757dcc 100644 Binary files a/bin/controllers/AddFlightController.class and b/bin/controllers/AddFlightController.class differ diff --git a/bin/controllers/DeletePilotController.class b/bin/controllers/DeletePilotController.class index e2997b8..9a667c7 100644 Binary files a/bin/controllers/DeletePilotController.class and b/bin/controllers/DeletePilotController.class differ diff --git a/bin/controllers/LogbookController.class b/bin/controllers/LogbookController.class index bb6b17c..69a9a62 100644 Binary files a/bin/controllers/LogbookController.class and b/bin/controllers/LogbookController.class differ diff --git a/bin/models/Flight.class b/bin/models/Flight.class index 7afafe4..c774b0a 100644 Binary files a/bin/models/Flight.class and b/bin/models/Flight.class differ diff --git a/bin/program/Main.class b/bin/program/Main.class index 5b6814a..466683a 100644 Binary files a/bin/program/Main.class and b/bin/program/Main.class differ diff --git a/bin/utils/XMLHelper.class b/bin/utils/XMLHelper.class index 6dcd31a..d5d92d6 100644 Binary files a/bin/utils/XMLHelper.class and b/bin/utils/XMLHelper.class differ diff --git a/bin/views/AddFlightScreen.class b/bin/views/AddFlightScreen.class deleted file mode 100644 index 31b0db3..0000000 Binary files a/bin/views/AddFlightScreen.class and /dev/null differ diff --git a/bin/views/AddFlightView.class b/bin/views/AddFlightView.class new file mode 100644 index 0000000..2fe88bf Binary files /dev/null and b/bin/views/AddFlightView.class differ diff --git a/bin/views/DeletePilotScreen.class b/bin/views/DeletePilotView.class similarity index 87% rename from bin/views/DeletePilotScreen.class rename to bin/views/DeletePilotView.class index 04fa178..e9ae971 100644 Binary files a/bin/views/DeletePilotScreen.class and b/bin/views/DeletePilotView.class differ diff --git a/bin/views/HelpScreen.class b/bin/views/HelpView.class similarity index 87% rename from bin/views/HelpScreen.class rename to bin/views/HelpView.class index 1befc0f..a0a080e 100644 Binary files a/bin/views/HelpScreen.class and b/bin/views/HelpView.class differ diff --git a/bin/views/HomeScreen.class b/bin/views/HomeScreenView.class similarity index 92% rename from bin/views/HomeScreen.class rename to bin/views/HomeScreenView.class index 3efe2bd..66880b6 100644 Binary files a/bin/views/HomeScreen.class and b/bin/views/HomeScreenView.class differ diff --git a/bin/views/ManagePilotProfileScreen.class b/bin/views/ManagePilotProfileView.class similarity index 68% rename from bin/views/ManagePilotProfileScreen.class rename to bin/views/ManagePilotProfileView.class index 5097e37..f3ccc32 100644 Binary files a/bin/views/ManagePilotProfileScreen.class and b/bin/views/ManagePilotProfileView.class differ diff --git a/bin/views/ViewLogbookScreen.class b/bin/views/ViewLogbookScreen.class deleted file mode 100644 index 53a44d2..0000000 Binary files a/bin/views/ViewLogbookScreen.class and /dev/null differ diff --git a/bin/views/ViewLogbookView.class b/bin/views/ViewLogbookView.class new file mode 100644 index 0000000..e581410 Binary files /dev/null and b/bin/views/ViewLogbookView.class differ diff --git a/flights.xml b/flights.xml index 7918379..f266095 100644 --- a/flights.xml +++ b/flights.xml @@ -5,22 +5,22 @@ - 1.0 + 2.0 - 123 + ad - 12:00 - - 13:00 + + 15:00 + - 12 + 2 - 2024-06-17 + 2024-06-20 asd @@ -29,25 +29,15 @@ asd - + asd asd - - - dasd - - - asdaa - - - - asdasd - + asd @@ -68,19 +58,19 @@ 13:00 - 15 + 1 2024-06-17 - asd + asdsss asdtest - + asd @@ -131,7 +121,7 @@ asdtest - + asd @@ -155,6 +145,211 @@ + + + + 1.0 + + + Max + + + 12:00 + + + 13:00 + + + 2 + + + 2024-06-20 + + + t + + + Max + + + + + asd + + + asd + + + asd + + + + + + + + + 1.0 + + + Max + + + 12:00 + + + 13:00 + + + 2 + + + 2024-06-20 + + + t + + + Max2 + + + + + asd + + + asd + + + asd + + + + + + + + + 1.0 + + + asd + + + 12:00 + + + 13:00 + + + 2 + + + 2024-06-20 + + + asd + + + asd22222 + + + + + asd + + + asd + + + asd + + + + + + + + + 1.0 + + + asd + + + 12:00 + + + 13:00 + + + 2 + + + 2024-06-20 + + + asd + + + 5 + + + + + asd + + + asd + + + asd + + + + + + + + + 1.0 + + + rr + + + 14:00 + + + 15:00 + + + 2 + + + 2024-06-20 + + + asd + + + rrr + + + + + asd + + + asd + + + asd + + + + + diff --git a/pilots.xml b/pilots.xml index 3c70075..3df3301 100644 --- a/pilots.xml +++ b/pilots.xml @@ -15,42 +15,6 @@ - - - - asd - - - asd - - - - dasd - - - - asdaa - - - - asdasd - - - - - - - - s - - - d - - - a - - - diff --git a/src/controllers/AddFlightController.java b/src/controllers/AddFlightController.java index 2fa5518..67b6390 100644 --- a/src/controllers/AddFlightController.java +++ b/src/controllers/AddFlightController.java @@ -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 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<>()); diff --git a/src/controllers/DeletePilotController.java b/src/controllers/DeletePilotController.java index daf9b4f..ef19ec0 100644 --- a/src/controllers/DeletePilotController.java +++ b/src/controllers/DeletePilotController.java @@ -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 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; } diff --git a/src/controllers/LogbookController.java b/src/controllers/LogbookController.java index 797509d..363c064 100644 --- a/src/controllers/LogbookController.java +++ b/src/controllers/LogbookController.java @@ -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(); } } diff --git a/src/models/Flight.java b/src/models/Flight.java index b7bd469..2564a34 100644 --- a/src/models/Flight.java +++ b/src/models/Flight.java @@ -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 datum; // transient, um die direkte Serialization zu vermeiden + private String id; + private String datumStr; + private transient ObjectProperty 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 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<>(); - } + } diff --git a/src/models/Pilot.java b/src/models/Pilot.java index 8a6281c..0be0001 100644 --- a/src/models/Pilot.java +++ b/src/models/Pilot.java @@ -15,7 +15,7 @@ public class Pilot implements Serializable { private List lizenzen; private List zertifikate; - // Standardkonstruktor + public Pilot() { this.name = new SimpleStringProperty(); this.adresse = new SimpleStringProperty(); diff --git a/src/program/Main.java b/src/program/Main.java index 1045456..320c5b4 100644 --- a/src/program/Main.java +++ b/src/program/Main.java @@ -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); } } + diff --git a/src/utils/XMLHelper.java b/src/utils/XMLHelper.java index 9c6c66d..71cf133 100644 --- a/src/utils/XMLHelper.java +++ b/src/utils/XMLHelper.java @@ -4,22 +4,9 @@ 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)))) { encoder.writeObject(obj); diff --git a/src/views/AddFlightScreen.java b/src/views/AddFlightView.java similarity index 88% rename from src/views/AddFlightScreen.java rename to src/views/AddFlightView.java index 6c144cc..e1841d4 100644 --- a/src/views/AddFlightScreen.java +++ b/src/views/AddFlightView.java @@ -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 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 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); diff --git a/src/views/DeletePilotScreen.java b/src/views/DeletePilotView.java similarity index 94% rename from src/views/DeletePilotScreen.java rename to src/views/DeletePilotView.java index 5438e1a..4a8bb2a 100644 --- a/src/views/DeletePilotScreen.java +++ b/src/views/DeletePilotView.java @@ -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); diff --git a/src/views/HelpScreen.java b/src/views/HelpView.java similarity index 90% rename from src/views/HelpScreen.java rename to src/views/HelpView.java index a08459d..84d73b7 100644 --- a/src/views/HelpScreen.java +++ b/src/views/HelpView.java @@ -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); diff --git a/src/views/HomeScreen.java b/src/views/HomeScreenView.java similarity index 85% rename from src/views/HomeScreen.java rename to src/views/HomeScreenView.java index 59b3e8f..3414df4 100644 --- a/src/views/HomeScreen.java +++ b/src/views/HomeScreenView.java @@ -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; } diff --git a/src/views/ManagePilotProfileScreen.java b/src/views/ManagePilotProfileView.java similarity index 91% rename from src/views/ManagePilotProfileScreen.java rename to src/views/ManagePilotProfileView.java index 0c3c6d2..8db5775 100644 --- a/src/views/ManagePilotProfileScreen.java +++ b/src/views/ManagePilotProfileView.java @@ -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,8 +137,9 @@ public class ManagePilotProfileScreen { stage.show(); } - private void savePilot(Pilot pilot, TextField nameField, TextField adresseField, TextField kontaktinformationenField, - ListView lizenzListView, ListView zertifikatListView) { + private void savePilot(Pilot pilot, TextField nameField, TextField adresseField, + TextField kontaktinformationenField, + ListView lizenzListView, ListView zertifikatListView) { clearFieldStyles(nameField, adresseField, kontaktinformationenField); try { @@ -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) { diff --git a/src/views/ViewLogbookScreen.java b/src/views/ViewLogbookView.java similarity index 85% rename from src/views/ViewLogbookScreen.java rename to src/views/ViewLogbookView.java index 2a2623b..4b7e2d6 100644 --- a/src/views/ViewLogbookScreen.java +++ b/src/views/ViewLogbookView.java @@ -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 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(); } });