diff options
author | Viktoria Pundy <viktoria.pundy@aon.at> | 2018-05-16 18:23:26 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2018-05-22 15:53:23 +0200 |
commit | 00df04016586450a2c5f49f13f565feadb20130d (patch) | |
tree | 64d12c7095a65d29336eadae99371647591773dc /src | |
parent | 470a40aaa819e08d61ebae8f7124d4a7eafbe2ee (diff) | |
download | sepm-groupproject-00df04016586450a2c5f49f13f565feadb20130d.tar.gz sepm-groupproject-00df04016586450a2c5f49f13f565feadb20130d.tar.xz sepm-groupproject-00df04016586450a2c5f49f13f565feadb20130d.zip |
Added Details for Archive Operation [#24990]
Added fxml-file for details of one operation as well as methods to fill in data and show Data in UI
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/ArchivOperationController.java | 97 | ||||
-rw-r--r-- | src/main/resources/fxml/ArchivOperation.fxml | 49 |
2 files changed, 132 insertions, 14 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/ArchivOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/ArchivOperationController.java index 76e551a..5136090 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/ArchivOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/ArchivOperationController.java @@ -4,21 +4,33 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.EnumSet; import java.util.LinkedList; -import java.util.List; -import javafx.fxml.FXML; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; +import javafx.scene.control.Hyperlink; +import javafx.scene.control.Label; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.FlowPane; import org.springframework.stereotype.Controller; @Controller public class ArchivOperationController { + + public AnchorPane apDetails; + public Label lblCodeHeader; + public Hyperlink hypBack; + public Label lblOpCode; + public Label lblVehicles; + public Label lblDate; + public Label lblAddress; OperationService operationService; public FlowPane archiveOperationFlowPane; public CreateOperationController createOperationController; + LinkedList<Operation> list = new LinkedList<>(); public ArchivOperationController() {} @@ -29,19 +41,7 @@ public class ArchivOperationController { this.createOperationController = createOperationController; } - @FXML - public void initialize() { - /*for (int i = 0; i < 2; i++) { - Button b = new Button(); - b.setPrefHeight(200); - b.setPrefWidth(800 / 2); - archiveOperationFlowPane.getChildren().add(b); - }*/ - } - public void fillList() { - // TODO Test - List<Operation> list = new LinkedList<>(); try { list.addAll(operationService.list(EnumSet.of(Status.CANCELLED, Status.COMPLETED))); } catch (ServiceException e) { @@ -56,7 +56,76 @@ public class ArchivOperationController { b.setPrefHeight(200); b.setPrefWidth(800 / 2); b.setText(list.get(i).opCode()); + b.setOnAction(event -> buttonClicked(b)); archiveOperationFlowPane.getChildren().add(b); } } + + Operation detailOperation; + + public void buttonClicked(Button button) { + // TODO: Problem wenn identischer Code, eventuell am Index erkennen + int size = archiveOperationFlowPane.getChildren().size(); + int index = 0; + for (int i = 0; i < size; i++) { + if (archiveOperationFlowPane.getChildren().get(i) == button) { + index = i; + break; + } + } + detailOperation = list.get(index); + + /*for (int i = 0; i < list.size(); i++) { + if (list.get(i).opCode().equals(opCode)) { + detailOperation = list.get(i); + break; + } + }*/ + setOperation(); + setDetailsVisible(true); + } + + private void setOperation() { + // TODO + lblCodeHeader.setText(detailOperation.opCode()); + String date = "am "; + if (detailOperation.created() != null) { + LocalDateTime myDateTime = + LocalDateTime.ofInstant(detailOperation.created(), ZoneOffset.UTC); + date += + myDateTime.getDayOfMonth() + + "." + + myDateTime.getMonth().getValue() + + "." + + myDateTime.getYear(); + lblDate.setText(date); + } else { + lblDate.setText("---"); + } + + lblOpCode.setText(detailOperation.opCode()); + StringBuilder result = new StringBuilder(); + for (int i = 0; i < detailOperation.vehicles().size(); i++) { + if (i == detailOperation.vehicles().size() - 1) { + result.append(detailOperation.vehicles().get(i).name()); + } else { + result.append(detailOperation.vehicles().get(i).name()).append(", "); + } + } + lblVehicles.setText(result.toString()); + lblAddress.setText(detailOperation.destination()); + } + + public void setListVisible(boolean b) { + archiveOperationFlowPane.setVisible(b); + } + + public void setDetailsVisible(boolean b) { + apDetails.setVisible(b); + } + + public void backClicked() { + setDetailsVisible(false); + // setListVisible(true); + } } diff --git a/src/main/resources/fxml/ArchivOperation.fxml b/src/main/resources/fxml/ArchivOperation.fxml index 7ce19d0..991cafe 100644 --- a/src/main/resources/fxml/ArchivOperation.fxml +++ b/src/main/resources/fxml/ArchivOperation.fxml @@ -1,11 +1,60 @@ <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.scene.control.Hyperlink?> +<?import javafx.scene.control.Label?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.FlowPane?> +<?import javafx.scene.text.Font?> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="650.0" prefWidth="1200.0" style="-fx-background-color: BLACK;" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.userInterface.ArchivOperationController"> <children> <AnchorPane prefHeight="650.0" prefWidth="800.0" style="-fx-background-color: rgba(239,235,232,1);" AnchorPane.leftAnchor="200.0" /> <FlowPane fx:id="archiveOperationFlowPane" prefHeight="650.0" prefWidth="800.0" AnchorPane.leftAnchor="200.0" /> + <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="201.0" AnchorPane.topAnchor="0.0"> + <children> + <AnchorPane 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> + <Font name="System Bold" size="16.0" /> + </font> + </Label> + <Label fx:id="lblCodeHeader" layoutX="203.0" layoutY="20.0" prefHeight="34.0" prefWidth="116.0" textFill="WHITE"> + <font> + <Font name="System Bold" size="16.0" /> + </font> + </Label> + <Hyperlink fx:id="hypBack" onAction="#backClicked" layoutX="656.0" layoutY="20.0" text="Zurück" textFill="WHITE"> + <font> + <Font name="System Bold" size="16.0" /> + </font> + </Hyperlink> + </children></AnchorPane> + <AnchorPane layoutX="82.0" layoutY="60.0" prefHeight="150.0" prefWidth="636.0" style="-fx-background-color: white;"> + <children> + <Label fx:id="lblOpCode" layoutX="25.0" layoutY="22.0" prefHeight="26.0" prefWidth="116.0" text="Label"> + <font> + <Font name="System Bold" size="18.0" /> + </font> + </Label> + <Label fx:id="lblAddress" layoutX="26.0" layoutY="53.0" prefHeight="22.0" prefWidth="540.0" text="Label"> + <font> + <Font size="15.0" /> + </font> + </Label> + <Label fx:id="lblVehicles" layoutX="58.0" layoutY="91.0" prefHeight="46.0" prefWidth="554.0" text="Label"> + <font> + <Font size="15.0" /> + </font> + </Label> + <Label fx:id="lblDate" alignment="CENTER_RIGHT" layoutX="482.0" layoutY="22.0" prefHeight="27.0" prefWidth="140.0" text="Label"> + <font> + <Font name="System Bold" size="18.0" /> + </font> + </Label> + </children> + </AnchorPane> + </children> + </AnchorPane> </children> </AnchorPane> |