#10 story/pfleger-modul-sperren-und-loschen-von-pflegern #37

Merged
SZUT-Dorian merged 11 commits from story/pfleger-modul-sperren-und-loschen-von-pflegern into main 2024-05-16 11:57:12 +00:00
6 changed files with 253 additions and 12 deletions
Showing only changes of commit 453616c175 - Show all commits

View file

@ -3,6 +3,7 @@ package de.hitec.nhplus.main;
import de.hitec.nhplus.Main;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.SelectionModel;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
@ -29,10 +30,18 @@ public class MainWindowController {
@FXML
private Tab treatmentTab;
@FXML
private AnchorPane nursePage;
@FXML
private Tab nurseTab;
@FXML
private TabPane nurseTabPane;
@FXML
private AnchorPane activeNursePage;
@FXML
private Tab activeNurseTab;
@FXML
private AnchorPane lockedNursePage;
@FXML
private Tab lockedNurseTab;
@FXML
private AnchorPane medicationPage;
@FXML
private Tab medicationTab;
@ -46,6 +55,12 @@ public class MainWindowController {
treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage());
nurseTab.setOnSelectionChanged(event -> loadNursePage());
medicationTab.setOnSelectionChanged(event -> loadMedicationPage());
nurseTabPane.getSelectionModel().select(activeNurseTab);
activeNurseTab.setOnSelectionChanged(event -> loadActiveNursePage());
lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage());
}
/**
@ -88,15 +103,43 @@ public class MainWindowController {
* Loads the nurse page into its tab.
*/
private void loadNursePage() {
SelectionModel<Tab> selectionModel = nurseTabPane.getSelectionModel();
Tab selectedTab = selectionModel.getSelectedItem();
if(selectedTab == activeNurseTab){
loadActiveNursePage();
}
if(selectedTab == lockedNurseTab){
loadLockedNursePage();
}
}
private void loadActiveNursePage() {
SZUT-Dominik marked this conversation as resolved
Review
  • Missing Javadoc
- [x] Missing Javadoc
System.out.println("TODO: Active Nurse");
try {
BorderPane nursePane = FXMLLoader.load(
BorderPane activeNursePane = FXMLLoader.load(
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/AllNurseView.fxml"))
);
SZUT-Dominik marked this conversation as resolved Outdated
  • Typo: active wird kleingeschrieben.
- [x] Typo: **active** wird kleingeschrieben.
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);
SZUT-Dominik marked this conversation as resolved Outdated
  • Nurse wird klein geschrieben, oder eine Refernz
- [x] Nurse wird klein geschrieben, oder eine Refernz
AnchorPane.setBottomAnchor(activeNursePane, 0d);
AnchorPane.setLeftAnchor(activeNursePane, 0d);
AnchorPane.setRightAnchor(activeNursePane, 0d);
} catch (IOException exception) {
exception.printStackTrace();
}
}
SZUT-Dominik marked this conversation as resolved
Review
  • Missing Javadoc
- [x] Missing Javadoc
private void loadLockedNursePage() {
System.out.println("TODO: Locked Nurse");
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();
}

View file

@ -33,6 +33,8 @@ public class AllNurseController {
@FXML
public Button buttonAdd;
@FXML
public Button buttonLock;
@FXML
private TableView<Nurse> tableView;
@FXML
private TableColumn<Nurse, Long> columnId;
@ -89,7 +91,7 @@ public class AllNurseController {
this.nurses.clear();
this.dao = DaoFactory.getInstance().createNurseDAO();
try {
this.nurses.setAll(this.dao.readAll());
this.nurses.setAll(this.dao.readAllActive());
}catch (SQLException exception){
exception.printStackTrace();
}
@ -119,5 +121,20 @@ public class AllNurseController {
clearTextfields();
}
@FXML
public void handleLock(){
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
if (selectedItem == null){
return;
}
try {
selectedItem.setLocked(true);
this.dao.update(selectedItem);
}catch (SQLException exception){
exception.printStackTrace();
}
readAllAndShowInTableView();
}
}

View file

@ -0,0 +1,96 @@
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
SZUT-Dominik marked this conversation as resolved Outdated
  • Missing Javadoc
    Hier würded ihr euch auch mit Author Tags hinzufügen:
    @author Armin Ribic
    wir haben überall die klar Namen geschrieben
- [ ] Missing Javadoc Hier würded ihr euch auch mit Author Tags hinzufügen: `@author Armin Ribic` wir haben überall die klar Namen geschrieben
private Button buttonUnlock;
@FXML
public TableView<Nurse> tableView;
SZUT-Dominik marked this conversation as resolved
Review
  • Author alleine reicht Heidemann hier nicht, kurze Beschreibung wie bei den anderen Controllern hier hin, muss nix Langes sein.
- [x] Author alleine reicht Heidemann hier nicht, kurze Beschreibung wie bei den anderen Controllern hier hin, muss nix Langes sein.
@FXML
public TableColumn<Nurse, Long> columnId;
@FXML
public TableColumn<Nurse, String> columnFirstName;
@FXML
public TableColumn<Nurse, String> columnSurName;
@FXML
public TableColumn<Nurse, String> columnDeleteDate;
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
private NurseDao dao;
public void initialize() {
this.readAllAndShowInTableView();
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
SZUT-Dominik marked this conversation as resolved Outdated
  • Missing Javadoc
- [x] Missing Javadoc
  • Ist technisch falsch, technisch korrekt wäre:

    Initialization method that is called after the binding of all the fields.

    Weil Initalize & Instanciate nicht dasselbe sind.

    Initalize ist eine Methode, die im Hintergrund von JavaFx, nach dem Instaciating & Binding aufgerufen wird.

- [x] Ist technisch falsch, technisch korrekt wäre: > Initialization method that is called after the binding of all the fields. Weil **Initalize** & **Instanciate** nicht dasselbe sind. **Initalize** ist eine Methode, die im Hintergrund von **JavaFx**, nach dem **Instaciating** & **Binding** aufgerufen wird.
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);
}
private void readAllAndShowInTableView() {
this.nurses.clear();
this.dao = DaoFactory.getInstance().createNurseDAO();
try {
this.nurses.addAll(this.dao.readAllLocked());
} catch (SQLException exception) {
exception.printStackTrace();
}
SZUT-Dominik marked this conversation as resolved Outdated
  • Missing Javadoc
- [x] Missing Javadoc
}
@FXML
public void handleDelete() {
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
return;
}
try {
SZUT-Dominik marked this conversation as resolved
Review
  • Refernz für Nurse hier bitte rein {@link Nurse}
- [x] Refernz für Nurse hier bitte rein {@link Nurse}
this.dao.delete(selectedItem.getId());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML
public void changeUnlock() {
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
return;
}
try {
selectedItem.setLocked(false);
this.dao.update(selectedItem);
} catch (SQLException exception) {
exception.printStackTrace();
SZUT-Dominik marked this conversation as resolved Outdated
  • Methoden mit @FXML benötigen keine Javadoc, weil sie durch ihr Linking bereits deklarativ genug sind
- [x] Methoden mit @FXML benötigen keine Javadoc, weil sie durch ihr Linking bereits deklarativ genug sind
}
readAllAndShowInTableView();
}
}

View file

@ -16,7 +16,14 @@
<AnchorPane fx:id="treatmentPage"/>
</Tab>
<Tab fx:id="nurseTab" text="Pfleger">
<AnchorPane fx:id="nursePage"/>
<TabPane fx:id="nurseTabPane" tabClosingPolicy="UNAVAILABLE">
<Tab fx:id="activeNurseTab" text="Pfleger">
<AnchorPane fx:id="activeNursePage"/>
</Tab>
<Tab fx:id="lockedNurseTab" text="Gesperrte Pfleger">
<AnchorPane fx:id="lockedNursePage"/>
</Tab>
</TabPane>
</Tab>
<Tab fx:id="medicationTab" text="Medikamente">
<AnchorPane fx:id="medicationPage"/>

View file

@ -77,10 +77,11 @@
text="Hinzufügen"
/>
<Button
fx:id="buttonDelete"
fx:id="buttonLock"
mnemonicParsing="false"
onAction="#handleLock"
prefWidth="90.0"
text="Löschen"
text="Sperren"
/>
</HBox>
</right>

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="de.hitec.nhplus.nurse.LockedNurseController"
>
<padding>
<Insets top="8" left="8" right="8" bottom="8"/>
</padding>
<center>
<TableView fx:id="tableView" layoutX="31.0" layoutY="40">
<columns>
<TableColumn
fx:id="columnId"
minWidth="40.0"
text="ID"
/>
<TableColumn
fx:id="columnSurName"
minWidth="140.0"
text="Nachname"
/>
<TableColumn
fx:id="columnFirstName"
minWidth="140.0"
text="Vorname"
/>
<TableColumn
fx:id="columnDeleteDate"
minWidth="140.0"
text="Löschen ab"
/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
</center>
<bottom>
<BorderPane>
<BorderPane.margin>
<Insets top="8.0"/>
</BorderPane.margin>
<center>
<HBox spacing="8.0">
<padding>
<Insets right="8.0"/>
</padding>
</HBox>
</center>
<right>
<HBox>
<spacing>8.0</spacing>
<Button
fx:id="buttonUnlock"
mnemonicParsing="false"
onAction="#changeUnlock"
prefWidth="90.0"
text="Entsperren"
/>
<Button
fx:id="buttonDelete"
mnemonicParsing="false"
onAction="#handleDelete"
prefWidth="90.0"
text="Löschen"
/>
</HBox>
</right>
</BorderPane>
</bottom>
</BorderPane>