From c72f9889dc0c50be5fd7386dbfd77796bb42ab5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20K=C3=BCck?= Date: Wed, 8 May 2024 16:58:00 +0200 Subject: [PATCH] #23: Create Medication Modal --- .../medication/AllMedicationController.java | 30 +++++++++++++++++++ .../medication/MedicationModalController.java | 8 +++++ .../nhplus/medication/AllMedicationView.fxml | 1 + .../nhplus/medication/MedicationModal.fxml | 18 +++++++++++ 4 files changed, 57 insertions(+) create mode 100644 src/main/java/de/hitec/nhplus/medication/MedicationModalController.java create mode 100644 src/main/resources/de/hitec/nhplus/medication/MedicationModal.fxml diff --git a/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java b/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java index 5261958..56bffeb 100644 --- a/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java +++ b/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java @@ -1,15 +1,22 @@ package de.hitec.nhplus.medication; +import de.hitec.nhplus.Main; import de.hitec.nhplus.datastorage.DaoFactory; import de.hitec.nhplus.medication.database.MedicationDao; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; +import java.io.IOException; import java.sql.SQLException; import java.util.stream.Collectors; @@ -76,4 +83,27 @@ public class AllMedicationController { exception.printStackTrace(); } } + + @FXML + public void handleNewMedication() { + try { + FXMLLoader loader = new FXMLLoader( + Main.class.getResource("/de/hitec/nhplus/medication/MedicationModal.fxml") + ); + BorderPane pane = loader.load(); + Scene scene = new Scene(pane); + Stage stage = new Stage(); + + MedicationModalController controller = loader.getController(); + controller.initialize(); + + stage.setScene(scene); + stage.setTitle("NHPlus - Neues Medikament"); + stage.setResizable(true); + stage.setAlwaysOnTop(true); + stage.showAndWait(); + } catch (IOException exception) { + exception.printStackTrace(); + } + } } diff --git a/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java b/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java new file mode 100644 index 0000000..50585f0 --- /dev/null +++ b/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java @@ -0,0 +1,8 @@ +package de.hitec.nhplus.medication; + +public class MedicationModalController { + + public void initialize(){ + + } +} diff --git a/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml b/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml index f5ee43b..53e03b9 100644 --- a/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml +++ b/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml @@ -66,6 +66,7 @@ fx:id="buttonAdd" mnemonicParsing="false" prefWidth="90.0" + onAction="#handleNewMedication" text="Hinzufügen" />