aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/at/ac/tuwien/sepm
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/ac/tuwien/sepm')
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java24
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() {