| @@ -132,6 +132,10 @@ public class MainController { | |||||
| return messageController; | return messageController; | ||||
| } | } | ||||
| public LogController getLogController(){ | |||||
| return logController; | |||||
| } | |||||
| public void increaseParallelTaskCount() { | public void increaseParallelTaskCount() { | ||||
| parallelTaskCount++; | parallelTaskCount++; | ||||
| if (parallelTaskCount > 0 && progressIndicator != null) { | if (parallelTaskCount > 0 && progressIndicator != null) { | ||||
| @@ -4,8 +4,19 @@ import de.uniluebeck.mi.projmi6.model.Fall; | |||||
| import de.uniluebeck.mi.projmi6.model.HL7Message; | import de.uniluebeck.mi.projmi6.model.HL7Message; | ||||
| import de.uniluebeck.mi.projmi6.model.Patient; | import de.uniluebeck.mi.projmi6.model.Patient; | ||||
| import de.uniluebeck.mi.projmi6.view.MessageIcon; | import de.uniluebeck.mi.projmi6.view.MessageIcon; | ||||
| import javafx.beans.property.SimpleListProperty; | |||||
| import javafx.collections.FXCollections; | |||||
| import javafx.collections.ObservableList; | import javafx.collections.ObservableList; | ||||
| import javafx.fxml.FXML; | import javafx.fxml.FXML; | ||||
| import javafx.fxml.FXMLLoader; | |||||
| import javafx.scene.Parent; | |||||
| import javafx.scene.Scene; | |||||
| import javafx.scene.image.Image; | |||||
| import javafx.stage.Modality; | |||||
| import javafx.stage.Stage; | |||||
| import java.io.IOException; | |||||
| import java.time.LocalDateTime; | |||||
| /** | /** | ||||
| * Created by Johannes on 21/11/2015. | * Created by Johannes on 21/11/2015. | ||||
| @@ -16,6 +27,7 @@ public class MessageController { | |||||
| @FXML | @FXML | ||||
| private MessageIcon messageIcon; | private MessageIcon messageIcon; | ||||
| private final SimpleListProperty<HL7Message> messages = new SimpleListProperty(FXCollections.observableArrayList()); | |||||
| @@ -25,18 +37,45 @@ public class MessageController { | |||||
| @FXML | @FXML | ||||
| private void initialize(){ | private void initialize(){ | ||||
| messageIcon.messageCountProperty().bind(messages.sizeProperty()); | |||||
| messages.add(new HL7Message(null, 0, LocalDateTime.now(), null, true)); | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| private void onMessageIconClicked(){ | private void onMessageIconClicked(){ | ||||
| showMessageList(); | |||||
| } | } | ||||
| private void showMessageList(){ | |||||
| FXMLLoader fxmlLoader = new FXMLLoader(); | |||||
| fxmlLoader.setLocation(getClass().getClassLoader().getResource("message_list.fxml")); | |||||
| MessageListController messageListController = new MessageListController(messages, mainController); | |||||
| fxmlLoader.setControllerFactory(clazz -> messageListController); | |||||
| Parent root = null; | |||||
| try { | |||||
| root = fxmlLoader.load(); | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| return; | |||||
| } | |||||
| Stage stage = new Stage(); | |||||
| stage.setTitle(messages.size()+ " neue HL7-Nachrichten"); | |||||
| stage.setScene(new Scene(root, 600, 400)); | |||||
| stage.getIcons().add(new Image("icon.png")); | |||||
| stage.initModality(Modality.WINDOW_MODAL); | |||||
| stage.initOwner(messageIcon.getScene().getWindow()); | |||||
| stage.show(); | |||||
| } | |||||
| public void addMessage(HL7Message message){ | |||||
| public void addMessage(HL7Message message){ | |||||
| messages.add(message); | |||||
| mainController.getLogController().refreshLogFromDb(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,79 @@ | |||||
| package de.uniluebeck.mi.projmi6.controller; | |||||
| /** | |||||
| * Created by Johannes on 21/11/2015. | |||||
| */ | |||||
| import de.uniluebeck.mi.projmi6.model.HL7Message; | |||||
| import javafx.beans.property.SimpleListProperty; | |||||
| import javafx.collections.ObservableList; | |||||
| import javafx.fxml.FXML; | |||||
| import javafx.scene.control.Alert; | |||||
| import javafx.scene.control.Button; | |||||
| import javafx.scene.control.ListView; | |||||
| import javafx.stage.Modality; | |||||
| import javafx.stage.Stage; | |||||
| public class MessageListController { | |||||
| private final SimpleListProperty<HL7Message> messages; | |||||
| private final MainController mainController; | |||||
| public MessageListController(SimpleListProperty<HL7Message> messages, MainController mainController){ | |||||
| this.messages = messages; | |||||
| this.mainController = mainController; | |||||
| } | |||||
| @FXML | |||||
| private void initialize(){ | |||||
| lvMessages.setItems(messages); | |||||
| btnShow.disableProperty().bind(lvMessages.getSelectionModel().selectedItemProperty().isNull()); | |||||
| btnRemove.disableProperty().bind(lvMessages.getSelectionModel().selectedItemProperty().isNull()); | |||||
| messages.sizeProperty().addListener((observable, oldValue, newValue) -> { | |||||
| if(messages.getSize()<=0){ | |||||
| ((Stage)lvMessages.getScene().getWindow()).close(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| @FXML | |||||
| private ListView<HL7Message> lvMessages; | |||||
| @FXML | |||||
| private Button btnShow; | |||||
| @FXML | |||||
| private Button btnRemove; | |||||
| @FXML | |||||
| void clickedRemove() { | |||||
| HL7Message message = lvMessages.getSelectionModel().getSelectedItem(); | |||||
| if(message==null){ | |||||
| return; | |||||
| } | |||||
| messages.remove(message); | |||||
| } | |||||
| @FXML | |||||
| void clickedShow() { | |||||
| HL7Message message = lvMessages.getSelectionModel().getSelectedItem(); | |||||
| if(message==null){ | |||||
| return; | |||||
| } | |||||
| messages.remove(message); | |||||
| if(message.isFailed()){ | |||||
| Alert alert = new Alert(Alert.AlertType.ERROR); | |||||
| alert.setTitle("Nachricht konnte nicht verarbeitet werden"); | |||||
| alert.setHeaderText("Die Nachricht konnte nicht verarbeitet werden"); | |||||
| alert.setContentText(message.getMessageContent()); | |||||
| alert.initOwner(btnShow.getScene().getWindow()); | |||||
| alert.initModality(Modality.APPLICATION_MODAL); | |||||
| alert.showAndWait(); | |||||
| } | |||||
| //TODO Go to patient | |||||
| } | |||||
| } | |||||
| @@ -23,10 +23,15 @@ public class HL7Message { | |||||
| } | } | ||||
| public LocalDateTime getDateTime() { | public LocalDateTime getDateTime() { | ||||
| return dateTime; | return dateTime; | ||||
| } | } | ||||
| @Override | |||||
| public String toString() { | |||||
| return dateTime+ " - "+(failed?"<fehlerhafte Nachricht>": | |||||
| (patient!=null? patient.getNachname()+", "+patient.getVorname():"")); | |||||
| } | |||||
| public void setDateTime(LocalDateTime dateTime) { | public void setDateTime(LocalDateTime dateTime) { | ||||
| this.dateTime = dateTime; | this.dateTime = dateTime; | ||||
| } | } | ||||
| @@ -0,0 +1,23 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <?import javafx.geometry.*?> | |||||
| <?import javafx.scene.control.*?> | |||||
| <?import java.lang.*?> | |||||
| <?import javafx.scene.layout.*?> | |||||
| <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" | |||||
| fx:controller="de.uniluebeck.mi.projmi6.controller.MessageListController"> | |||||
| <children> | |||||
| <ListView fx:id="lvMessages" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" /> | |||||
| <HBox alignment="CENTER_RIGHT" spacing="5.0" VBox.vgrow="NEVER"> | |||||
| <children> | |||||
| <Button fx:id="btnRemove" cancelButton="true" mnemonicParsing="false" onAction="#clickedRemove" text="Entfernen" /> | |||||
| <Button fx:id="btnShow" defaultButton="true" mnemonicParsing="false" onAction="#clickedShow" text="Zeigen" /> | |||||
| </children> | |||||
| <VBox.margin> | |||||
| <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> | |||||
| </VBox.margin> | |||||
| </HBox> | |||||
| </children> | |||||
| </VBox> | |||||