diff options
-rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java | 24 | ||||
-rw-r--r-- | src/main/resources/fxml/OperationDetails.fxml | 11 |
2 files changed, 30 insertions, 5 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java index 38d3bd1..937a86a 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java @@ -39,6 +39,7 @@ public class OperationDetailsController { private final VehicleService vehicleService; private final CreateOperationController createOperationController; @FXML private FlowPane fpVehicles; + @FXML private FlowPane fpAdditional; @FXML private ListView<Operation> lvActiveOperations; @FXML private Label lblChosenVehicles; @FXML private Button btnCloseOperation; @@ -75,11 +76,20 @@ public class OperationDetailsController { fpVehicles.getChildren().clear(); for (Vehicle vehicle : operation.vehicles()) { VehiclePaneController controller = VehiclePaneController.createVehiclePane(); + controller.setData(vehicle, true, false); + fpVehicles.getChildren().add(controller.getRootElement()); + } + + fpAdditional.getChildren().clear(); + for (Vehicle vehicle : operationService.rankVehicles(operation.opCode())) { + if (operation.vehicles().contains(vehicle)) continue; + + VehiclePaneController controller = VehiclePaneController.createVehiclePane(); controller.setData(vehicle, true, true); controller.getBtnRequest().setOnAction(e -> requestVehicleClicked(controller)); - fpVehicles.getChildren().add(controller.getRootElement()); + fpAdditional.getChildren().add(controller.getRootElement()); } - } catch (IOException e) { + } catch (IOException | ServiceException | InvalidOperationException e) { LOG.error("Error while updating list.", e); showServiceExceptionAlertAndWait("Error while updating list."); } @@ -150,15 +160,21 @@ public class OperationDetailsController { private void requestVehicleClicked(VehiclePaneController v) { LOG.debug("Button \"Nachfordern\" clicked."); + Vehicle vehicle; + try { - operationService.requestVehicles(operation.id(), Set.of(v.getData().id())); + vehicle = v.getData(); + if (vehicle == null) return; + + operationService.requestVehicles(operation.id(), Set.of(vehicle.id())); } catch (ServiceException | InvalidOperationException | InvalidVehicleException e) { LOG.error("Exception in requestVehicleClicked()", e); showServiceExceptionAlertAndWait(e.getMessage()); return; } showSuccessAlertAndWait("Das Fahrzeug wurde erfolgreich angefordert"); - createOperationController.updateList(); + operation.vehicles().add(vehicle); + updateFlowPane(); } public void closeWindow() { diff --git a/src/main/resources/fxml/OperationDetails.fxml b/src/main/resources/fxml/OperationDetails.fxml index e1a4daa..9d2fb5b 100644 --- a/src/main/resources/fxml/OperationDetails.fxml +++ b/src/main/resources/fxml/OperationDetails.fxml @@ -9,6 +9,7 @@ <?import javafx.scene.layout.FlowPane?> <?import javafx.scene.text.Font?> +<?import javafx.scene.layout.VBox?> <AnchorPane fx:id="operationDetailsAP" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="542.0" prefWidth="1100.0" visible="false" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.OperationDetailsController"> <children> <AnchorPane prefHeight="542.0" prefWidth="1100.0" style="-fx-background-color: rgba(239,235,232,1);" /> @@ -94,7 +95,15 @@ </AnchorPane> <ScrollPane layoutX="16.0" layoutY="195.0" prefHeight="345.0" prefWidth="846.0"> <content> - <FlowPane fx:id="fpVehicles" hgap="12" prefHeight="336.0" prefWidth="840.0" vgap="12" /> + <VBox> + <FlowPane fx:id="fpVehicles" hgap="12" prefHeight="168.0" prefWidth="840.0" vgap="12" /> + <Label text="Weitere Fahrzeuge:" > + <font> + <Font name="System Bold" size="19.0" /> + </font> + </Label> + <FlowPane fx:id="fpAdditional" hgap="12" prefHeight="168.0" prefWidth="840.0" vgap="12" /> + </VBox> </content> </ScrollPane> </children> |