Funktionen angepasst
parent
950a4a9078
commit
5290732598
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
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.
16
pilots.xml
16
pilots.xml
|
@ -29,15 +29,23 @@
|
|||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="models.Pilot">
|
||||
<object class="models.Pilot" id="Pilot0">
|
||||
<void property="adresse">
|
||||
<string>asdasd</string>
|
||||
<string>sad</string>
|
||||
</void>
|
||||
<void property="kontaktinformationen">
|
||||
<string>23</string>
|
||||
<string>ads</string>
|
||||
</void>
|
||||
<void property="lizenzen">
|
||||
<void method="add">
|
||||
<string>äää</string>
|
||||
</void>
|
||||
<void method="add">
|
||||
<string>äää</string>
|
||||
</void>
|
||||
</void>
|
||||
<void property="name">
|
||||
<string>adsasd</string>
|
||||
<string>sad</string>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<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);
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue