From 2bd06fab41a0522ea430bbc300a9edc1bed7dd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Sat, 27 Apr 2024 23:47:07 +0200 Subject: [PATCH] #16: Setup Controller and View MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- db/nursingHome.db | Bin 16384 -> 20480 bytes .../nhplus/controller/AllNurseController.java | 59 ++++++++++++++++++ .../controller/MainWindowController.java | 10 +++ .../de/hitec/nhplus/AllCaregiverView.fxml | 43 ------------- .../de/hitec/nhplus/AllNurseView.fxml | 47 ++++++++++++++ .../de/hitec/nhplus/MainWindowView.fxml | 54 +++++++++------- 6 files changed, 149 insertions(+), 64 deletions(-) create mode 100644 src/main/java/de/hitec/nhplus/controller/AllNurseController.java delete mode 100644 src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml create mode 100644 src/main/resources/de/hitec/nhplus/AllNurseView.fxml diff --git a/db/nursingHome.db b/db/nursingHome.db index fbd08333f7accb96ed84b67eae167f5eb8350dca..4febd503014f0942b925029f3e737ae975740ea3 100644 GIT binary patch delta 363 zcmZo@U~E{xI6+E?v4(+xffa~hz;~jKkr+@^uV^7J-(Ln6o|6oGtNF!vGk8vJYz*bm zZf@uMP+VGsO}HQlY{)`Y~Ce|TncPp2REk6 zZIEDLoB!!E3Gna&#hLg|Gw?s>KMgc;KfkFI6Dxzbq@rU{ vZe|{k$S*Civ@ka_H8D0aG!SQGWe^ru^v_B4KD;M6+rZGs*u>P#+``WO#D}v_#g9M*(~U=i+^GOpB670vpi!-QEFmI fZfaf$7dI=jG-E+xNhXj3(#*#Rm)rbLpGg1!hBYLI diff --git a/src/main/java/de/hitec/nhplus/controller/AllNurseController.java b/src/main/java/de/hitec/nhplus/controller/AllNurseController.java new file mode 100644 index 0000000..3bd75bb --- /dev/null +++ b/src/main/java/de/hitec/nhplus/controller/AllNurseController.java @@ -0,0 +1,59 @@ +package de.hitec.nhplus.controller; + +import de.hitec.nhplus.datastorage.DaoFactory; +import de.hitec.nhplus.datastorage.NurseDao; +import de.hitec.nhplus.model.Nurse; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; + +import java.sql.SQLException; + +public class AllNurseController { + + @FXML + private TableView tableView; + @FXML + private TableColumn columnId; + @FXML + private TableColumn columnFirstName; + @FXML + private TableColumn columnSurname; + @FXML + private TableColumn columnPhoneNumber; + + private final ObservableList nurses = FXCollections.observableArrayList(); + private NurseDao dao; + + public void initialize() { + this.readAllAndSHowInTableView(); + + this.columnId.setCellValueFactory(new PropertyValueFactory<>("nid")); + + this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName")); + this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname")); + this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn()); + + + this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber")); + this.columnPhoneNumber.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.tableView.setItems(this.nurses); + } + + private void readAllAndSHowInTableView(){ + this.nurses.clear(); + this.dao = DaoFactory.getDaoFactory().createNurseDAO(); + try { + this.nurses.addAll(this.dao.readAll()); + }catch (SQLException exception){ + exception.printStackTrace(); + } + } +} diff --git a/src/main/java/de/hitec/nhplus/controller/MainWindowController.java b/src/main/java/de/hitec/nhplus/controller/MainWindowController.java index 862380d..85b9f36 100644 --- a/src/main/java/de/hitec/nhplus/controller/MainWindowController.java +++ b/src/main/java/de/hitec/nhplus/controller/MainWindowController.java @@ -36,4 +36,14 @@ public class MainWindowController { exception.printStackTrace(); } } + + @FXML + private void handleShowAllNurses(ActionEvent event){ + FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/AllNurseView.fxml")); + try { + mainBorderPane.setCenter(loader.load()); + }catch (IOException exception){ + exception.printStackTrace(); + } + } } diff --git a/src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml b/src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml deleted file mode 100644 index 8e82ca1..0000000 --- a/src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + +