aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/at/ac/tuwien
diff options
context:
space:
mode:
authorViktoria Pundy <viktoria.pundy@aon.at>2018-05-31 09:24:48 +0200
committerTharre <tharre3@gmail.com>2018-06-02 00:14:15 +0200
commit2ce4e7f6a0194c8428882216ad30821eb9e8eb8b (patch)
tree156816b3ed54518507d5a5b321e3c9a80d1db2db /src/main/java/at/ac/tuwien
parentf5476716fa6aa1c2ce82a4cd116b8e80f2d30896 (diff)
downloadsepm-groupproject-2ce4e7f6a0194c8428882216ad30821eb9e8eb8b.tar.gz
sepm-groupproject-2ce4e7f6a0194c8428882216ad30821eb9e8eb8b.tar.xz
sepm-groupproject-2ce4e7f6a0194c8428882216ad30821eb9e8eb8b.zip
Added fxml and controller for archived operations [#27299]
Created fxml-file for archived operations. Additionally, a controller was created to fill the pane with information about an archived Operation. Furthermore, the already existing controller archiveOperationController was adjusted to created these panes according to the existing archived operations.
Diffstat (limited to 'src/main/java/at/ac/tuwien')
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java55
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationInArchiveController.java65
2 files changed, 112 insertions, 8 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);
+ }
+}