aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java')
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java113
1 files changed, 0 insertions, 113 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java
deleted file mode 100644
index 6c0932b..0000000
--- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller;
-
-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.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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VehiclePaneController {
-
- private static Logger LOG = LoggerFactory.getLogger(VehiclePaneController.class);
-
- 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;
- }
-
- @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;
-
- private Node rootElement;
- private Vehicle data;
-
- public Node getRootElement() {
- return rootElement;
- }
-
- public Vehicle getData() {
- return data;
- }
-
- /**
- * * 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 = Instant.now();
- List<Registration> regs = vehicle.registrations();
-
- if (regs == null) {
- return;
- }
-
- Optional<EducationLevel> edu =
- regs.stream()
- .filter(reg -> reg.start().isBefore(now) && reg.end().isAfter(now))
- .map(reg -> reg.employee().educationLevel())
- .max(EducationLevel::compareTo);
-
- if (!edu.isPresent()) {
- return;
- }
-
- txtQualification.setText(edu.get().name());
- } else {
- txtQualification.setVisible(false);
- txtQualification.setManaged(false);
- ivQualification.setVisible(false);
- ivQualification.setManaged(false);
- }
-
- this.data = vehicle;
- }
-
- public void setSelected(boolean selected) {
- rootElement.getStyleClass().clear();
-
- if (selected) {
- rootElement.getStyleClass().add("bg-yellow");
- rootElement.getStyleClass().add("shadowed");
- } else {
- rootElement.getStyleClass().add("bg-white");
- rootElement.getStyleClass().add("shadowed");
- }
- }
-}