From 4849e2fdcdbaca390f427e13a45de9015c2e8752 Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Tue, 1 May 2018 11:41:23 +0200 Subject: create first version of createNewEmployee-UI --- src/main/resources/fxml/createNewEmployee.fxml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/resources/fxml/createNewEmployee.fxml (limited to 'src/main/resources/fxml') diff --git a/src/main/resources/fxml/createNewEmployee.fxml b/src/main/resources/fxml/createNewEmployee.fxml new file mode 100644 index 0000000..3acc7d1 --- /dev/null +++ b/src/main/resources/fxml/createNewEmployee.fxml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/fxmlFiles/CreateOperationController.fxml b/src/main/resources/fxmlFiles/CreateOperationController.fxml deleted file mode 100644 index 7b188fd..0000000 --- a/src/main/resources/fxmlFiles/CreateOperationController.fxml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-70-g09d2 From 3d3f4440238ededefa6bb142106295d6eab4678c Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Mon, 7 May 2018 12:33:11 +0200 Subject: Change CreateOperationController.fxml labels to hyperlinks with onAction --- src/main/resources/fxml/CreateOperationController.fxml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/resources/fxml') diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml index 949d4ec..1ba6498 100644 --- a/src/main/resources/fxml/CreateOperationController.fxml +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -1,6 +1,7 @@ + @@ -59,21 +60,21 @@ - - - + -- cgit v1.2.3-70-g09d2 From e7acdd7afb6612ef35265ba706ae968d326495a7 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Sat, 5 May 2018 22:17:05 +0200 Subject: First mockup of RegistrationWindow and its controller --- .../controller/RegistrationWindowController.java | 203 +++++++++++++++++++++ src/main/resources/fxml/RegistrationWindow.fxml | 76 ++++++++ 2 files changed, 279 insertions(+) create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java create mode 100644 src/main/resources/fxml/RegistrationWindow.fxml (limited to 'src/main/resources/fxml') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java new file mode 100644 index 0000000..8fea9dc --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java @@ -0,0 +1,203 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.RegistrationService; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; +import javafx.beans.property.SimpleStringProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; + +@Controller +public class RegistrationWindowController { + + private static final Logger LOG = LoggerFactory.getLogger(RegistrationWindowController.class); + + private EmployeeService employeeService; + + private VehicleService vehicleService; + + private RegistrationService registrationService; + + @Autowired + public void setEmployeeService(EmployeeService employeeService) { + this.employeeService = employeeService; + } + + @Autowired + public void setVehicleService(VehicleService vehicleService) { + this.vehicleService = vehicleService; + } + + @Autowired + public void setRegistrationService(RegistrationService registrationService) { + this.registrationService = registrationService; + } + + @FXML public ChoiceBox cbStart; + @FXML public ChoiceBox cbEnd; + @FXML public Label lVehicles; + @FXML public Label lEmployees; + @FXML public TextField tfVehicleSearch; + @FXML public TextField tfEmployeeSearch; + @FXML public TableView tvVehicles; + @FXML public TableView tvEmployees; + @FXML public TableColumn tcVehicles; + @FXML public TableColumn tcEmployees; + + private Vehicle chosenVehicle; + private List chosenEmployees = new LinkedList<>(); + + @FXML + public void initialize() { + // will have to be replaced for FlowPane + try { + List vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); + tcVehicles.setCellValueFactory(x -> new SimpleStringProperty(x.getValue().name())); + tvVehicles.setItems(FXCollections.observableArrayList(vehicles)); + } catch (ServiceException e) { + LOG.warn( + "Caught ServiceException while getting vehicles. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.ERROR); + alert.setTitle("Fahrzeuge - Fehler!"); + alert.setHeaderText("Beim Auflisten der Fahrzeug ist ein Fehler aufgetreten."); + alert.setContentText(e.getMessage()); + alert.show(); + } + try { + List employees = employeeService.list(); + tcEmployees.setCellValueFactory(x -> new SimpleStringProperty(x.getValue().name())); + tvEmployees.setItems(FXCollections.observableArrayList(employees)); + } catch (ServiceException e) { + LOG.warn( + "Caught ServiceException while getting employees. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.ERROR); + alert.setTitle("Personal - Fehler!"); + alert.setHeaderText("Beim Auflisten des Personals ist ein Fehler aufgetreten."); + alert.setContentText(e.getMessage()); + alert.show(); + } + tvVehicles.setOnMousePressed( + new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + if (mouseEvent.isPrimaryButtonDown() && mouseEvent.getClickCount() == 2) { + chosenVehicle = tvVehicles.getSelectionModel().getSelectedItem(); + lVehicles.setText(chosenVehicle.name()); + } + } + }); + tvEmployees.setOnMousePressed( + new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + if (mouseEvent.isPrimaryButtonDown() && mouseEvent.getClickCount() == 2) { + chosenEmployees.add(tvEmployees.getSelectionModel().getSelectedItem()); + StringBuilder text = new StringBuilder(); + for (Employee employee : chosenEmployees) { + text.append(employee.name()).append("\n"); + } + lEmployees.setText(text.toString()); + } + } + }); + ObservableList hours = + FXCollections.observableArrayList( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23); + cbStart.setItems(hours); + cbEnd.setItems(hours); + } + + public void cancel() { + LOG.debug("Cancel Button clicked"); + ((Stage) lVehicles.getScene().getWindow()).close(); + } + + public void create() { + LOG.debug("Create Button clicked"); + + List registrations = new LinkedList<>(); + + for (Employee employee : chosenEmployees) { + registrations.add( + Registration.builder() + .id(chosenVehicle.id()) + .employee(employee) + .start( + LocalDateTime.of( + LocalDate.now(), + LocalTime.of(cbStart.getValue(), 0)) + .toInstant(ZoneOffset.ofHours(0))) + .end( + LocalDateTime.of( + LocalDate.now(), + LocalTime.of(cbEnd.getValue(), 0)) + .toInstant(ZoneOffset.ofHours(0))) + .build()); + } + try { + registrationService.add(chosenVehicle, registrations); + } catch (InvalidVehicleException e) { + // NOT THROWN ANYWHERE RIGHT NOW + LOG.info( + "Caught InvalidVehicleException. Showing it to user. Error message: {}", + e.getClass().toString(), + e.getMessage()); + Alert alert = new Alert(AlertType.WARNING); + alert.setTitle("Ungültiges Fahrzeug"); + alert.setHeaderText("Das spezifizierte Fahrzeug ist nicht gültig."); + alert.setContentText(e.getMessage()); + alert.show(); + } catch (ServiceException e) { + LOG.warn( + "Caught ServiceException while getting vehicles. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.ERROR); + alert.setTitle("Anmeldung - Fehler!"); + alert.setHeaderText("Beim Erstellen der Anmeldung ist ein Fehler aufgetreten."); + alert.setContentText(e.getMessage()); + alert.show(); + } catch (InvalidRegistrationException e) { + LOG.info( + "Caught InvalidRegistrationException. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.WARNING); + alert.setTitle("Ungültige Eingabe"); + alert.setHeaderText( + "Die gewählte Kombination von Fahrzeug und Personal ist nicht gültig!"); + alert.setContentText(e.getMessage()); + alert.show(); + } + } +} diff --git a/src/main/resources/fxml/RegistrationWindow.fxml b/src/main/resources/fxml/RegistrationWindow.fxml new file mode 100644 index 0000000..0394ca7 --- /dev/null +++ b/src/main/resources/fxml/RegistrationWindow.fxml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From e8aff26f9855c9106defd23c78d37c0907a0d97e Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Mon, 7 May 2018 21:29:38 +0200 Subject: Change header-background-color and add drop-shadows to main elements --- src/main/resources/fxml/CreateOperationController.fxml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/resources/fxml') diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml index 1ba6498..086a5d1 100644 --- a/src/main/resources/fxml/CreateOperationController.fxml +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -10,8 +10,8 @@ - - + + - - + @@ -75,7 +75,7 @@ - + - + -- cgit v1.2.3-70-g09d2 From d1be1e7dc30f11084f4d7054612d02a230271514 Mon Sep 17 00:00:00 2001 From: Andreas Weninger Date: Thu, 3 May 2018 20:25:01 +0200 Subject: Empty skeleton for VehiclePane. --- .../ui/vehiclePane/VehiclePaneController.java | 33 ++++++++++++++++++++++ src/main/resources/fxml/vehiclePane.fxml | 14 +++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java create mode 100644 src/main/resources/fxml/vehiclePane.fxml (limited to 'src/main/resources/fxml') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java new file mode 100644 index 0000000..ee9e29f --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java @@ -0,0 +1,33 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.ui.vehiclePane; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import java.io.IOException; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; + +public class VehiclePaneController { + public static VehiclePaneController createVehiclePane() throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); + Node root = fxmlLoader.load(); + VehiclePaneController result = fxmlLoader.getController(); + result.rootElement = root; + + return result; + } + + private Node rootElement; + + public Node getRootElement() { + return rootElement; + } + + /*** + * Set the displayed data of this VehiclePane. + * @param vehicle The data to display. + * @param showQualification If true, the most recent registration of vehicle will be searched for the highest qualification. + */ + public void setData(Vehicle vehicle, boolean showQualification) + { + + } +} diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml new file mode 100644 index 0000000..f6824dc --- /dev/null +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -0,0 +1,14 @@ + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From 4e9bbe5134b2efd9e3eab277a92366fe0ba38d4e Mon Sep 17 00:00:00 2001 From: Andreas Weninger Date: Sat, 5 May 2018 16:28:09 +0200 Subject: VehiclePane FXML --- .../ui/vehiclePane/VehiclePaneController.java | 11 +++ src/main/resources/fxml/vehiclePane.fxml | 78 ++++++++++++++++++--- src/main/resources/images/NEF.png | Bin 0 -> 327 bytes src/main/resources/images/Not.png | Bin 0 -> 872 bytes src/main/resources/images/NotNEF.png | Bin 0 -> 1042 bytes src/main/resources/images/Qualification.png | Bin 0 -> 1029 bytes src/main/resources/images/Vehicle.png | Bin 0 -> 964 bytes 7 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/images/NEF.png create mode 100644 src/main/resources/images/Not.png create mode 100644 src/main/resources/images/NotNEF.png create mode 100644 src/main/resources/images/Qualification.png create mode 100644 src/main/resources/images/Vehicle.png (limited to 'src/main/resources/fxml') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java index ee9e29f..903028e 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java @@ -4,8 +4,19 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import java.io.IOException; import javafx.fxml.FXMLLoader; import javafx.scene.Node; +import javafx.scene.image.ImageView; +import javafx.scene.text.Text; public class VehiclePaneController { + + private Text txtType; + private Text txtNumber; + private ImageView ivNEF; + private Text txtNEF; + private ImageView ivQualification; + private Text txtQualification; + private Text txtRooftype; + public static VehiclePaneController createVehiclePane() throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); Node root = fxmlLoader.load(); diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml index f6824dc..6014c72 100644 --- a/src/main/resources/fxml/vehiclePane.fxml +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -1,14 +1,70 @@ - - - - - + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/images/NEF.png b/src/main/resources/images/NEF.png new file mode 100644 index 0000000..687f914 Binary files /dev/null and b/src/main/resources/images/NEF.png differ diff --git a/src/main/resources/images/Not.png b/src/main/resources/images/Not.png new file mode 100644 index 0000000..03063af Binary files /dev/null and b/src/main/resources/images/Not.png differ diff --git a/src/main/resources/images/NotNEF.png b/src/main/resources/images/NotNEF.png new file mode 100644 index 0000000..0c17d53 Binary files /dev/null and b/src/main/resources/images/NotNEF.png differ diff --git a/src/main/resources/images/Qualification.png b/src/main/resources/images/Qualification.png new file mode 100644 index 0000000..c58a640 Binary files /dev/null and b/src/main/resources/images/Qualification.png differ diff --git a/src/main/resources/images/Vehicle.png b/src/main/resources/images/Vehicle.png new file mode 100644 index 0000000..2fe992d Binary files /dev/null and b/src/main/resources/images/Vehicle.png differ -- cgit v1.2.3-70-g09d2 From b9aadec691affd632c8d83e30293964cc1bb05bb Mon Sep 17 00:00:00 2001 From: Andreas Weninger Date: Mon, 7 May 2018 17:53:59 +0200 Subject: Reformat. Implemented find maximum education in VehiclePaneController; relies on EducationLevel.Compare. --- .../ui/vehiclePane/VehiclePaneController.java | 69 ----------------- .../ui/vehiclepane/VehiclePaneController.java | 84 ++++++++++++++++++++ src/main/resources/fxml/vehiclePane.fxml | 90 +++++++++++----------- 3 files changed, 129 insertions(+), 114 deletions(-) delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java (limited to 'src/main/resources/fxml') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java deleted file mode 100644 index 2b0df13..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java +++ /dev/null @@ -1,69 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.ui.vehiclePane; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import java.io.IOException; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Node; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.text.Text; - -public class VehiclePaneController { - @FXML private Text txtType; - @FXML private Text txtNumber; - @FXML private ImageView ivNEF; - @FXML private Text txtNEF; - @FXML private ImageView ivQualification; - @FXML private Text txtQualification; - @FXML private Text txtRooftype; - - public static VehiclePaneController createVehiclePane() throws IOException { - FXMLLoader fxmlLoader = - new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); - Node root = fxmlLoader.load(); - VehiclePaneController result = fxmlLoader.getController(); - result.rootElement = root; - - return result; - } - - private Node rootElement; - - public Node getRootElement() { - return rootElement; - } - - /** - * * Set the displayed data of this VehiclePane. - * - * @param vehicle The data to display. - * @param showQualification If true, the most recent registration of vehicle will be searched - * for the highest qualification. - */ - public void setData(Vehicle vehicle, boolean showQualification) { - txtType.setText(vehicle.type().name()); - String constrType = vehicle.constructionType().name(); - txtRooftype.setText( - constrType.substring(0, 1).toUpperCase() + constrType.substring(1).toLowerCase()); - txtNumber.setText("" + vehicle.id()); - if (vehicle.hasNef()) { - ivNEF.setImage(new Image("../images/NEF.png")); - txtNEF.setText("hat NEF-Halterung"); - } else { - ivNEF.setImage(new Image("../images/NotNEF.png")); - txtNEF.setText("keine NEF-Halterung"); - } - if (showQualification) - { - //TODO - } - else - { - txtQualification.setVisible(false); - txtQualification.setManaged(false); - ivQualification.setVisible(false); - ivQualification.setManaged(false); - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java new file mode 100644 index 0000000..2db6f37 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java @@ -0,0 +1,84 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.ui.vehiclepane; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import java.io.IOException; +import java.time.Instant; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.text.Text; + +public class VehiclePaneController { + @FXML private Text txtType; + @FXML private Text txtNumber; + @FXML private ImageView ivNEF; + @FXML private Text txtNEF; + @FXML private ImageView ivQualification; + @FXML private Text txtQualification; + @FXML private Text txtRooftype; + + public static VehiclePaneController createVehiclePane() throws IOException { + FXMLLoader fxmlLoader = + new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); + Node root = fxmlLoader.load(); + VehiclePaneController result = fxmlLoader.getController(); + result.rootElement = root; + + return result; + } + + private Node rootElement; + + public Node getRootElement() { + return rootElement; + } + + /** + * * Set the displayed data of this VehiclePane. + * + * @param vehicle The data to display. + * @param showQualification If true, the most recent registration of vehicle will be searched + * for the highest qualification. + */ + public void setData(Vehicle vehicle, boolean showQualification) { + txtType.setText(vehicle.type().name()); + String constrType = vehicle.constructionType().name(); + txtRooftype.setText( + constrType.substring(0, 1).toUpperCase() + constrType.substring(1).toLowerCase()); + txtNumber.setText("" + vehicle.id()); + if (vehicle.hasNef()) { + ivNEF.setImage(new Image("../images/NEF.png")); + txtNEF.setText("hat NEF-Halterung"); + } else { + ivNEF.setImage(new Image("../images/NotNEF.png")); + txtNEF.setText("keine NEF-Halterung"); + } + if (showQualification) { + + Instant now = (new Date()).toInstant(); + List regs = vehicle.registrations(); + + assert regs != null; + Optional edu = + regs.stream() + .filter(reg -> reg.start().isBefore(now) && reg.end().isAfter(now)) + .map(reg -> reg.employee().educationLevel()) + .max(EducationLevel::compareTo); + + assert edu.isPresent(); + txtQualification.setText(edu.get().name()); + } else { + txtQualification.setVisible(false); + txtQualification.setManaged(false); + ivQualification.setVisible(false); + ivQualification.setManaged(false); + } + } +} diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml index 6014c72..8b1d194 100644 --- a/src/main/resources/fxml/vehiclePane.fxml +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -10,61 +10,61 @@ - + - - - - + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - + + - + - - - - + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2