diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java | 41 | ||||
| -rw-r--r-- | src/main/resources/fxml/OperationDetails.fxml | 27 | 
2 files changed, 39 insertions, 29 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java index 7694b95..ffb4166 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java @@ -7,6 +7,8 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.Operati  import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.io.IOException; +import java.lang.invoke.MethodHandles;  import java.util.Collection;  import java.util.EnumSet;  import java.util.stream.Collectors; @@ -19,6 +21,7 @@ import javafx.scene.control.Label;  import javafx.scene.control.ListCell;  import javafx.scene.control.ListView;  import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane;  import org.slf4j.Logger;  import org.slf4j.LoggerFactory;  import org.springframework.stereotype.Controller; @@ -31,13 +34,14 @@ public class OperationDetailsController {      private final OperationService operationService;      private final VehicleService vehicleService;      private final CreateOperationController createOperationController; -    @FXML private ListView<Vehicle> lvVehicles; +    @FXML private FlowPane fpVehicles;      @FXML private ListView<Operation> lvActiveOperations;      @FXML private Label lblChosenVehicles;      @FXML private Button btnCloseOperation;      @FXML private Button btnCancelOperation;      @FXML private Label lblCode, lblAdditionalInfo, lblAddress;      @FXML private AnchorPane operationDetailsAP; +    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());      public OperationDetailsController(              OperationService operationService, @@ -50,20 +54,6 @@ public class OperationDetailsController {      @FXML      private void initialize() { -        lvVehicles.setCellFactory( -                param -> -                        new ListCell<>() { -                            @Override -                            protected void updateItem(Vehicle item, boolean empty) { -                                super.updateItem(item, empty); - -                                if (empty || item == null || item.name() == null) { -                                    setText(null); -                                } else { -                                    setText(item.name()); -                                } -                            } -                        });          lvActiveOperations.setCellFactory(                  param ->                          new ListCell<>() { @@ -89,6 +79,25 @@ public class OperationDetailsController {                  });      } +    private void updateFlowPane() { +        try { +            fpVehicles.getChildren().clear(); +            for (Vehicle vehicle : operation.vehicles()) { +                VehiclePaneController controller = VehiclePaneController.createVehiclePane(); +                controller.setData(vehicle, true); +                fpVehicles.getChildren().add(controller.getRootElement()); +            } +        } catch (IOException e) { +            LOG.error("Error while updating list.", e); + +            Alert alert = new Alert(Alert.AlertType.ERROR); +            alert.setTitle("Fehler"); +            alert.setHeaderText("Fehler!"); +            alert.setContentText(e.getMessage()); +            alert.showAndWait(); +        } +    } +      void initOperation(Operation operation) {          fillActiveList();          this.operation = operation; @@ -99,7 +108,7 @@ public class OperationDetailsController {          lblChosenVehicles.setText(result.toString());          lblAdditionalInfo.setText(operation.additionalInfo());          lblAddress.setText(operation.destination()); -        lvVehicles.setItems(FXCollections.observableArrayList(operation.vehicles())); +        updateFlowPane();          operationDetailsAP.setVisible(true);      } diff --git a/src/main/resources/fxml/OperationDetails.fxml b/src/main/resources/fxml/OperationDetails.fxml index 3ac7d93..911b030 100644 --- a/src/main/resources/fxml/OperationDetails.fxml +++ b/src/main/resources/fxml/OperationDetails.fxml @@ -4,22 +4,24 @@  <?import javafx.scene.control.Hyperlink?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.control.ListView?> +<?import javafx.scene.control.ScrollPane?>  <?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.FlowPane?>  <?import javafx.scene.text.Font?>  <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.einsatzverwaltung.controller.OperationDetailsController">    <children> -    <AnchorPane prefHeight="542.0" prefWidth="1100.0" style="-fx-background-color: white;" /> +    <AnchorPane prefHeight="542.0" prefWidth="1100.0" style="-fx-background-color: rgba(239,235,232,1);" />      <AnchorPane layoutX="10.0" layoutY="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="542.0" prefWidth="1000.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">        <children>          <AnchorPane layoutX="964.0" layoutY="-66.0" prefHeight="152.0" prefWidth="1100.0" style="-fx-background-color: green;" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">            <children> -            <Hyperlink layoutX="1023.0" layoutY="16.0" onAction="#closeWindow" text="Zurück" textFill="WHITE"> +            <Hyperlink layoutX="1023.0" layoutY="16.0" onAction="#closeWindow" styleClass="text-medium" text="Zurück" textFill="WHITE">                <font>                  <Font size="15.0" />                </font>              </Hyperlink> -            <Label layoutX="17.0" layoutY="13.0" prefHeight="34.0" prefWidth="174.0" text="Ausgewählter Einsatz:" textFill="WHITE"> +            <Label layoutX="17.0" layoutY="13.0" prefHeight="34.0" prefWidth="174.0" styleClass="text-big" text="Ausgewählter Einsatz:" textFill="WHITE">                <font>                  <Font size="17.0" />                </font> @@ -28,20 +30,14 @@          </AnchorPane>          <AnchorPane fx:id="apActiveOperations" layoutX="874.0" layoutY="50.0" prefHeight="298.0" prefWidth="200.0" style="-fx-background-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 5);">            <children> -            <ListView fx:id="lvActiveOperations" layoutX="9.0" layoutY="55.0" prefHeight="242.0" prefWidth="182.0" style="-fx-background-color: white;" /> -            <Label layoutX="9.0" layoutY="11.0" prefHeight="46.0" prefWidth="103.0" text="Aktive Einsätze"> +            <ListView fx:id="lvActiveOperations" layoutX="9.0" layoutY="46.0" prefHeight="251.0" prefWidth="182.0" style="-fx-background-color: white;" /> +            <Label layoutX="9.0" layoutY="4.0" prefHeight="46.0"  prefWidth="103.0" text="Aktive Einsätze">                <font>                  <Font name="System Bold" size="14.0" />                </font>              </Label> -            <Label layoutX="150.0" layoutY="24.0" text="Archiv"> -              <font> -                <Font size="13.0" /> -              </font> -            </Label>            </children>          </AnchorPane> -        <ListView fx:id="lvVehicles" layoutX="16.0" layoutY="185.0" prefHeight="355.0" prefWidth="846.0" style="-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 5);" />          <AnchorPane fx:id="apCreateOperation" layoutX="16.0" layoutY="49.0" prefHeight="134.0" prefWidth="845.0" style="-fx-background-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 5, 0, 0, 5);">            <children>              <Label layoutX="14.0" layoutY="14.0" prefHeight="30.0" prefWidth="62.0" text="Code"> @@ -69,12 +65,12 @@                  <Font size="17.0" />                </font>              </Label> -            <Button fx:id="btnCloseOperation" layoutX="709.0" layoutY="89.0" mnemonicParsing="false" onAction="#closeOperationClicked" prefHeight="39.0" prefWidth="122.0" text="Abschließen"> +            <Button fx:id="btnCloseOperation" layoutX="709.0" layoutY="89.0" mnemonicParsing="false" onAction="#closeOperationClicked" prefHeight="39.0" prefWidth="122.0" styleClass="button-main" text="Abschließen">                <font>                  <Font name="System Bold" size="17.0" />                </font>              </Button> -            <Button fx:id="btnCancelOperation" layoutX="575.0" layoutY="90.0" mnemonicParsing="false" onAction="#cancelOperationClicked" prefHeight="38.0" prefWidth="122.0" text="Stornieren"> +            <Button fx:id="btnCancelOperation" layoutX="575.0" layoutY="90.0" mnemonicParsing="false" onAction="#cancelOperationClicked" prefHeight="38.0" prefWidth="122.0" style="-fx-background-color: rgba(82, 83, 87, 0.51); -fx-text-fill: white;" text="Stornieren">                <font>                  <Font name="System Bold" size="17.0" />                </font> @@ -96,6 +92,11 @@              </Label>            </children>          </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" /> +               </content> +            </ScrollPane>        </children>      </AnchorPane>    </children>  | 
