From fbc917477d106be774d9c093ac42319aeadf1eff Mon Sep 17 00:00:00 2001 From: Tharre Date: Mon, 18 Jun 2018 21:30:20 +0200 Subject: RequestVehicles GUI list seperation #25953 --- .../controller/OperationDetailsController.java | 24 ++++++++++++++++++---- 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 lvActiveOperations; @FXML private Label lblChosenVehicles; @FXML private Button btnCloseOperation; @@ -74,12 +75,21 @@ public class OperationDetailsController { try { 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 @@ + @@ -94,7 +95,15 @@ - + + + + + -- cgit v1.2.3-70-g09d2