From fc4571106c2a4706e224423ad9093eacd6b05140 Mon Sep 17 00:00:00 2001 From: arminribic Date: Wed, 8 May 2024 14:26:05 +0200 Subject: [PATCH] =?UTF-8?q?#10:=20UI=20f=C3=BCrs=20Sperren/L=C3=B6schen/En?= =?UTF-8?q?tsperren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dataSources.xml | 2 +- .idea/sqldialects.xml | 1 - db/nursingHome.db | Bin 20480 -> 20480 bytes .../nhplus/main/MainWindowController.java | 49 +++++++++-- .../nhplus/nurse/AllNurseController.java | 14 ++++ .../nhplus/nurse/LockedNurseController.java | 79 ++++++++++++++++++ .../java/de/hitec/nhplus/nurse/Nurse.java | 14 ++++ .../de/hitec/nhplus/main/MainWindowView.fxml | 13 ++- .../de/hitec/nhplus/nurse/AllNurseView.fxml | 5 +- .../hitec/nhplus/nurse/LockedNurseView.fxml | 78 +++++++++++++++++ 10 files changed, 242 insertions(+), 13 deletions(-) create mode 100644 src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java create mode 100644 src/main/resources/de/hitec/nhplus/nurse/LockedNurseView.fxml diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index fed79a7..98f48a2 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,7 +1,7 @@ - + sqlite.xerial true org.sqlite.JDBC diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml index aecddda..b2ef682 100644 --- a/.idea/sqldialects.xml +++ b/.idea/sqldialects.xml @@ -3,7 +3,6 @@ - \ No newline at end of file diff --git a/db/nursingHome.db b/db/nursingHome.db index 2f42a9d3d3514a912207d2b54e56471170d2b12e..a7d3477a98725ce1fc1bd29cd8b1723b4040d91f 100644 GIT binary patch delta 98 zcmZozz}T>Wae_3X*hCp;MzM_vo%)QNn_uZm32-n7Ffj0c<3F`o&|w$8!y delta 97 zcmZozz}T>Wae_1>+e8^>Mz)O!o%)PSn_uZm32-p+pJw2H&VPEdpu loadPatientPage()); treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage()); nurseTab.setOnSelectionChanged(event -> loadNursePage()); + activeNurseTab.setOnSelectionChanged(event -> loadActiveNursePage()); + lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage()); } private void loadPatientPage() { @@ -70,14 +83,38 @@ public class MainWindowController { private void loadNursePage() { try { - BorderPane nursePane = FXMLLoader.load( + nurseTabPane.getSelectionModel().select(activeNurseTab); + loadActiveNursePage(); + } catch (Exception exception) { + exception.printStackTrace(); + } + } + + private void loadActiveNursePage() { + try { + BorderPane activeNursePane = FXMLLoader.load( Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/AllNurseView.fxml")) ); - nursePage.getChildren().setAll(nursePane); - AnchorPane.setTopAnchor(nursePane, 0d); - AnchorPane.setBottomAnchor(nursePane, 0d); - AnchorPane.setLeftAnchor(nursePane, 0d); - AnchorPane.setRightAnchor(nursePane, 0d); + activeNursePage.getChildren().setAll(activeNursePane); + AnchorPane.setTopAnchor(activeNursePane, 0d); + AnchorPane.setBottomAnchor(activeNursePane, 0d); + AnchorPane.setLeftAnchor(activeNursePane, 0d); + AnchorPane.setRightAnchor(activeNursePane, 0d); + } catch (IOException exception) { + exception.printStackTrace(); + } + } + + private void loadLockedNursePage() { + try { + BorderPane lockedNursePane = FXMLLoader.load( + Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/LockedNurseView.fxml")) + ); + lockedNursePage.getChildren().setAll(lockedNursePane); + AnchorPane.setTopAnchor(lockedNursePane, 0d); + AnchorPane.setBottomAnchor(lockedNursePane, 0d); + AnchorPane.setLeftAnchor(lockedNursePane, 0d); + AnchorPane.setRightAnchor(lockedNursePane, 0d); } catch (IOException exception) { exception.printStackTrace(); } diff --git a/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java b/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java index 7f69645..3106ec4 100644 --- a/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java +++ b/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java @@ -27,6 +27,8 @@ public class AllNurseController { @FXML public Button buttonAdd; @FXML + public Button buttonLock; + @FXML private TableView tableView; @FXML private TableColumn columnId; @@ -95,6 +97,18 @@ public class AllNurseController { readAllAndShowInTableView(); clearTextfields(); } + @FXML + public void handleLock(){ + Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem(); + if (selectedItem != null){ + try { + DaoFactory.getInstance().createNurseDAO().delete(selectedItem.getId()); + this.tableView.getItems().remove(selectedItem); + }catch (SQLException exception){ + exception.printStackTrace(); + } + } + } private void clearTextfields() { this.textFieldFirstName.clear(); diff --git a/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java b/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java new file mode 100644 index 0000000..21fa0e7 --- /dev/null +++ b/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java @@ -0,0 +1,79 @@ +package de.hitec.nhplus.nurse; + +import de.hitec.nhplus.datastorage.DaoFactory; +import de.hitec.nhplus.nurse.database.NurseDao; +import javafx.application.Application; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Tab; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; +import javafx.scene.layout.AnchorPane; +import javafx.stage.Stage; + +import java.sql.SQLException; + +public class LockedNurseController { + @FXML + public Button buttonDelete; + @FXML + private Button buttonUnlock; + @FXML + public TableView tableView; + @FXML + public TableColumn columnId; + @FXML + public TableColumn columnFirstName; + @FXML + public TableColumn columnSurName; + @FXML + public TableColumn columnDeleteDate; + + private final ObservableList nurses = FXCollections.observableArrayList(); + private NurseDao dao; + + public void initialize(){ + this.columnId.setCellValueFactory(new PropertyValueFactory<>("id")); + + this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName")); + this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName")); + this.columnSurName.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.columnDeleteDate.setCellValueFactory(new PropertyValueFactory<>("date")); + this.columnDeleteDate.setCellFactory(TextFieldTableCell.forTableColumn()); + + // this.tableView.setItems(this.nurses); + + + } + + + @FXML + public void handleDelete(){ + Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem(); + if (selectedItem != null){ + try { + DaoFactory.getInstance().createNurseDAO().delete(selectedItem.getId()); + this.tableView.getItems().remove(selectedItem); + }catch (SQLException exception){ + exception.printStackTrace(); + } + } + } + @FXML + public void changeLockStatus(){ + Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem(); + if ( !selectedItem.getisLocked()){ + selectedItem.setLocked(true); + } else if (selectedItem.getisLocked()) { + selectedItem.setLocked(false); + } + } + +} diff --git a/src/main/java/de/hitec/nhplus/nurse/Nurse.java b/src/main/java/de/hitec/nhplus/nurse/Nurse.java index 18e87f1..598740e 100644 --- a/src/main/java/de/hitec/nhplus/nurse/Nurse.java +++ b/src/main/java/de/hitec/nhplus/nurse/Nurse.java @@ -1,6 +1,7 @@ package de.hitec.nhplus.nurse; import de.hitec.nhplus.main.Person; +import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; @@ -9,6 +10,8 @@ import java.util.StringJoiner; public class Nurse extends Person { private SimpleIntegerProperty id; private final SimpleStringProperty phoneNumber; + private boolean isLocked; + public Nurse( String firstName, @@ -17,6 +20,7 @@ public class Nurse extends Person { ) { super(firstName, surName); this.phoneNumber = new SimpleStringProperty(phoneNumber); + this.isLocked = false; } public Nurse( @@ -28,6 +32,7 @@ public class Nurse extends Person { super(firstName, surName); this.id = new SimpleIntegerProperty(id); this.phoneNumber = new SimpleStringProperty(phoneNumber); + this.isLocked = false; } public void setPhoneNumber(String phoneNumber) { @@ -49,6 +54,15 @@ public class Nurse extends Person { public SimpleStringProperty phoneNumberProperty() { return phoneNumber; } + public boolean getisLocked() { + return isLocked; + } + public void setLocked(boolean locked) { + isLocked = locked; + } + + + @Override public String toString() { diff --git a/src/main/resources/de/hitec/nhplus/main/MainWindowView.fxml b/src/main/resources/de/hitec/nhplus/main/MainWindowView.fxml index 7d1697d..5837d2d 100644 --- a/src/main/resources/de/hitec/nhplus/main/MainWindowView.fxml +++ b/src/main/resources/de/hitec/nhplus/main/MainWindowView.fxml @@ -16,7 +16,14 @@ - - - + + + + + + + + + + diff --git a/src/main/resources/de/hitec/nhplus/nurse/AllNurseView.fxml b/src/main/resources/de/hitec/nhplus/nurse/AllNurseView.fxml index eec0384..664d6d7 100644 --- a/src/main/resources/de/hitec/nhplus/nurse/AllNurseView.fxml +++ b/src/main/resources/de/hitec/nhplus/nurse/AllNurseView.fxml @@ -77,10 +77,11 @@ text="Hinzufügen" />