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. --- src/main/resources/fxml/vehiclePane.fxml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/resources/fxml/vehiclePane.fxml (limited to 'src/main/resources/fxml/vehiclePane.fxml') 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/vehiclePane.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/vehiclePane.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