diff options
author | Tharre <tharre3@gmail.com> | 2018-06-18 21:30:20 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2018-06-18 21:45:37 +0200 |
commit | fbc917477d106be774d9c093ac42319aeadf1eff (patch) | |
tree | b1071538988f7cdc1e1e7a2e246c93e72e4faa35 /src/main/java/at/ac | |
parent | 41eaffacce8c35e517ec5a1e7a914858a0717a1d (diff) | |
download | sepm-groupproject-fbc917477d106be774d9c093ac42319aeadf1eff.tar.gz sepm-groupproject-fbc917477d106be774d9c093ac42319aeadf1eff.tar.xz sepm-groupproject-fbc917477d106be774d9c093ac42319aeadf1eff.zip |
RequestVehicles GUI list seperation #25953
Diffstat (limited to 'src/main/java/at/ac')
-rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java | 24 |
1 files changed, 20 insertions, 4 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() { |