diff options
Diffstat (limited to 'src/main')
4 files changed, 176 insertions, 12 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java index 0b7ec40..9c372fe 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java @@ -5,12 +5,14 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.S  import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle;  import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.io.IOException;  import java.time.LocalDateTime;  import java.time.ZoneOffset;  import java.util.Collection;  import java.util.EnumSet; -import java.util.LinkedList; +import java.util.HashSet;  import java.util.Objects; +import java.util.Set;  import java.util.stream.Collectors;  import javafx.fxml.FXML;  import javafx.scene.control.Alert; @@ -25,8 +27,9 @@ import org.springframework.stereotype.Controller;  @Controller  public class ArchiveOperationController { +    @FXML private AnchorPane backApMain; +    @FXML private AnchorPane backApDetails;      @FXML private AnchorPane archiveOperationAP; -    @FXML private AnchorPane apHeader;      @FXML private AnchorPane apDetails;      @FXML private Label lblCodeHeader;      @FXML private Hyperlink hypBack; @@ -38,7 +41,7 @@ public class ArchiveOperationController {      private final OperationService operationService;      @FXML private FlowPane archiveOperationFlowPane;      private final CreateOperationController createOperationController; -    private LinkedList<Operation> list = new LinkedList<>(); +    private Set<Operation> list = new HashSet<>();      public ArchiveOperationController(              OperationService operationService, @@ -58,19 +61,50 @@ public class ArchiveOperationController {              alert.setContentText("Die Einsätze konnten nicht geladen werden!");              alert.showAndWait();          } -        for (Operation operation : list) { +        setFlowPane(); + +        /*for (Operation operation : list) {              Button b = new Button();              b.setPrefHeight(200);              b.setPrefWidth(750 / 2);              b.setText(operation.opCode());              b.setOnAction(event -> buttonClicked(b));              archiveOperationFlowPane.getChildren().add(b); +        }*/ +    } + +    private void setFlowPane() { +        try { +            archiveOperationFlowPane.getChildren().clear(); +            Set<Operation> operations = list; +            for (Operation operation : operations) { +                OperationInArchiveController opInAController = +                        OperationInArchiveController.create(); +                opInAController.set(operation); +                opInAController +                        .getRoot() +                        .setOnMouseClicked( +                                event -> { +                                    detailOperation = operation; +                                    backApMain.setVisible(false); +                                    backApDetails.setVisible(true); +                                    setOperation(); +                                    setDetailsVisible(true); +                                }); +                archiveOperationFlowPane.getChildren().add(opInAController.getRoot()); +            } +        } catch (IOException e) { +            Alert alert = new Alert(Alert.AlertType.ERROR); +            alert.setTitle("Fehler"); +            alert.setHeaderText("Fehler!"); +            alert.setContentText("Das Element konnte nicht geladen werden!"); +            alert.showAndWait();          }      }      private Operation detailOperation; -    private void buttonClicked(Button button) { +    /*private void buttonClicked(Button button) {          int size = archiveOperationFlowPane.getChildren().size();          int index = 0;          for (int i = 0; i < size; i++) { @@ -80,10 +114,12 @@ public class ArchiveOperationController {              }          }          detailOperation = list.get(index); -        apHeader.setVisible(false); +        backApMain.setVisible(false); +        backApDetails.setVisible(true); +        //apHeader.setVisible(false);          setOperation();          setDetailsVisible(true); -    } +    }*/      private void setOperation() {          lblCodeHeader.setText(detailOperation.opCode()); @@ -131,7 +167,9 @@ public class ArchiveOperationController {      public void backClicked() {          fpVehicles.getChildren().clear();          setDetailsVisible(false); -        apHeader.setVisible(true); +        // apHeader.setVisible(true); +        backApDetails.setVisible(false); +        backApMain.setVisible(true);      }      public void backToMain() { @@ -141,5 +179,6 @@ public class ArchiveOperationController {      public void setVisible(boolean b) {          archiveOperationAP.setVisible(b); +        backApMain.setVisible(b);      }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java new file mode 100644 index 0000000..935b2fe --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java @@ -0,0 +1,65 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Collection; +import java.util.Objects; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.text.Text; + +public class OperationInArchiveController { + +    @FXML private Text txtAddress; +    @FXML private Text txtVehicles; +    @FXML private Text txtDate; +    @FXML private Text txtOpCode; + +    public static OperationInArchiveController create() throws IOException { +        FXMLLoader fxmlLoader = +                new FXMLLoader( +                        OperationInArchiveController.class.getResource( +                                "/fxml/OperationInArchive.fxml")); +        Node root = fxmlLoader.load(); +        OperationInArchiveController result = fxmlLoader.getController(); +        result.rootElement = root; + +        return result; +    } + +    public Node getRoot() { +        return rootElement; +    } + +    private Node rootElement; + +    public void set(Operation operation) { +        txtAddress.setText(operation.destination()); +        String date = "am "; +        if (operation.created() != null) { +            LocalDateTime myDateTime = +                    LocalDateTime.ofInstant( +                            Objects.requireNonNull(operation.created()), ZoneOffset.UTC); +            date += +                    myDateTime.getDayOfMonth() +                            + "." +                            + myDateTime.getMonth().getValue() +                            + "." +                            + myDateTime.getYear(); +            txtDate.setText(date); +        } else { +            txtDate.setText("---"); +        } +        txtOpCode.setText(operation.opCode()); +        Collection<String> elements = +                operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); +        String result = String.join(", ", elements); + +        txtVehicles.setText(result); +    } +} diff --git a/src/main/resources/fxml/ArchiveOperation.fxml b/src/main/resources/fxml/ArchiveOperation.fxml index 8598350..21662fd 100644 --- a/src/main/resources/fxml/ArchiveOperation.fxml +++ b/src/main/resources/fxml/ArchiveOperation.fxml @@ -9,14 +9,14 @@  <AnchorPane fx:id="archiveOperationAP" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="650.0" prefWidth="800.0" style="-fx-background-color: BLACK;" 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.ArchiveOperationController">    <children> -      <ScrollPane layoutY="100.0" prefHeight="550.0" prefWidth="800.0" AnchorPane.leftAnchor="0.0"> +      <ScrollPane layoutY="169.0" prefHeight="481.0" prefWidth="800.0" AnchorPane.leftAnchor="0.0">           <content>            <FlowPane fx:id="archiveOperationFlowPane" prefHeight="650.0" prefWidth="800.0" />           </content>        </ScrollPane>        <AnchorPane fx:id="apDetails" layoutX="201.0" prefHeight="650.0" prefWidth="800.0" style="-fx-background-color: rgba(239,235,232,1);" visible="false" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">           <children> -            <AnchorPane prefHeight="170.0" prefWidth="800.0" style="-fx-background-color: rgba(191,144,0,1);"> +            <AnchorPane fx:id="backApDetails" prefHeight="170.0" prefWidth="800.0" style="-fx-background-color: rgba(191,144,0,1);">                 <children>                    <Label layoutX="81.0" layoutY="20.0" prefHeight="34.0" prefWidth="116.0" text="Archiv-Eintrag:" textFill="WHITE">                       <font> @@ -65,9 +65,9 @@              </ScrollPane>           </children>        </AnchorPane> -      <AnchorPane fx:id="apHeader" prefHeight="100.0" prefWidth="800.0" style="-fx-background-color: BROWN;"> +      <AnchorPane fx:id="backApMain" prefHeight="170.0" prefWidth="800.0" style="-fx-background-color: rgba(191,144,0,1);" visible="false" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">           <children> -            <Hyperlink layoutX="713.0" layoutY="16.0" onAction="#backToMain" text="Zurück" textFill="WHITE"> +            <Hyperlink layoutX="29.0" layoutY="23.0" onAction="#backToMain" text="Zurück" textFill="WHITE">                 <font>                    <Font name="System Bold" size="16.0" />                 </font> diff --git a/src/main/resources/fxml/OperationInArchive.fxml b/src/main/resources/fxml/OperationInArchive.fxml new file mode 100644 index 0000000..43ac14b --- /dev/null +++ b/src/main/resources/fxml/OperationInArchive.fxml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.ColumnConstraints?> +<?import javafx.scene.layout.GridPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.RowConstraints?> +<?import javafx.scene.text.Font?> +<?import javafx.scene.text.Text?> + +<GridPane hgap="6.0" maxHeight="100.0" maxWidth="400.0" prefHeight="100.0" prefWidth="400.0" styleClass="bg-white, shadowed" stylesheets="@/styles/main.css" 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.OperationInArchiveController"> +   <columnConstraints> +      <ColumnConstraints /> +      <ColumnConstraints /> +      <ColumnConstraints /> +      <ColumnConstraints /> +      <ColumnConstraints /> +   </columnConstraints> +   <rowConstraints> +      <RowConstraints /> +      <RowConstraints /> +      <RowConstraints /> +   </rowConstraints> +   <padding> +      <Insets bottom="6.0" left="12.0" right="12.0" top="6.0" /> +   </padding> +   <children> +      <Text fx:id="txtAddress" text="Text" GridPane.rowIndex="1"> +         <font> +            <Font size="20.0" /> +         </font> +      </Text> +      <HBox prefHeight="102.0" prefWidth="200.0" GridPane.rowIndex="2"> +         <children> +            <ImageView fitHeight="23.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true"> +               <image> +                  <Image url="@../images/Vehicle.png" /> +               </image> +            </ImageView> +            <Text fx:id="txtVehicles" strokeType="OUTSIDE" strokeWidth="0.0" text="Text"> +               <font> +                  <Font size="20.0" /> +               </font> +            </Text> +         </children> +      </HBox> +      <Text fx:id="txtDate" nodeOrientation="RIGHT_TO_LEFT" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" wrappingWidth="187.73674726486206" GridPane.columnIndex="1"> +         <font> +            <Font name="System Bold" size="20.0" /> +         </font> +      </Text> +      <Text fx:id="txtOpCode" strokeType="OUTSIDE" strokeWidth="0.0" text="Text"> +         <font> +            <Font name="System Bold" size="20.0" /> +         </font> +      </Text> +   </children> +</GridPane>  | 
