NOTICKET: Cleanup Views

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-04-28 01:10:41 +02:00
parent 3a58ea5206
commit a3cbf3a940
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
5 changed files with 249 additions and 238 deletions

View file

@ -2,8 +2,8 @@ package de.hitec.nhplus.treatment;
import de.hitec.nhplus.Main;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.patient.PatientDao;
import de.hitec.nhplus.patient.Patient;
import de.hitec.nhplus.patient.PatientDao;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
@ -18,8 +18,7 @@ import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
public class AllTreatmentController
{
public class AllTreatmentController {
@FXML
private TableView<Treatment> tableView;
@ -53,8 +52,7 @@ public class AllTreatmentController
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
private ArrayList<Patient> patientList;
public void initialize()
{
public void initialize() {
readAllAndShowInTableView();
comboBoxPatientSelection.setItems(patientSelection);
comboBoxPatientSelection.getSelectionModel().select(0);
@ -80,75 +78,58 @@ public class AllTreatmentController
this.createComboBoxData();
}
public void readAllAndShowInTableView()
{
public void readAllAndShowInTableView() {
this.treatments.clear();
comboBoxPatientSelection.getSelectionModel().select(0);
this.dao = DaoFactory.getDaoFactory().createTreatmentDao();
try
{
try {
this.treatments.addAll(dao.readAll());
} catch (SQLException exception)
{
} catch (SQLException exception) {
exception.printStackTrace();
}
}
private void createComboBoxData()
{
private void createComboBoxData() {
PatientDao dao = DaoFactory.getDaoFactory().createPatientDAO();
try
{
try {
patientList = (ArrayList<Patient>) dao.readAll();
this.patientSelection.add("alle");
for (Patient patient : patientList)
{
for (Patient patient : patientList) {
this.patientSelection.add(patient.getSurname());
}
} catch (SQLException exception)
{
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML
public void handleComboBox()
{
public void handleComboBox() {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
this.treatments.clear();
this.dao = DaoFactory.getDaoFactory().createTreatmentDao();
if (selectedPatient.equals("alle"))
{
try
{
if (selectedPatient.equals("alle")) {
try {
this.treatments.addAll(this.dao.readAll());
} catch (SQLException exception)
{
} catch (SQLException exception) {
exception.printStackTrace();
}
}
Patient patient = searchInList(selectedPatient);
if (patient != null)
{
try
{
if (patient != null) {
try {
this.treatments.addAll(this.dao.readTreatmentsByPid(patient.getId()));
} catch (SQLException exception)
{
} catch (SQLException exception) {
exception.printStackTrace();
}
}
}
private Patient searchInList(String surname)
{
for (Patient patient : this.patientList)
{
if (patient.getSurname().equals(surname))
{
private Patient searchInList(String surname) {
for (Patient patient : this.patientList) {
if (patient.getSurname().equals(surname)) {
return patient;
}
}
@ -156,30 +137,24 @@ public class AllTreatmentController
}
@FXML
public void handleDelete()
{
public void handleDelete() {
int index = this.tableView.getSelectionModel().getSelectedIndex();
Treatment t = this.treatments.remove(index);
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
try
{
try {
dao.deleteById(t.getId());
} catch (SQLException exception)
{
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML
public void handleNewTreatment()
{
try
{
public void handleNewTreatment() {
try {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
Patient patient = searchInList(selectedPatient);
newTreatmentWindow(patient);
} catch (NullPointerException exception)
{
} catch (NullPointerException exception) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information");
alert.setHeaderText("Patient für die Behandlung fehlt!");
@ -189,12 +164,10 @@ public class AllTreatmentController
}
@FXML
public void handleMouseClick()
{
public void handleMouseClick() {
tableView.setOnMouseClicked(event ->
{
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null))
{
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
int index = this.tableView.getSelectionModel().getSelectedIndex();
Treatment treatment = this.treatments.get(index);
treatmentWindow(treatment);
@ -202,11 +175,11 @@ public class AllTreatmentController
});
}
public void newTreatmentWindow(Patient patient)
{
try
{
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/treatment/NewTreatmentView.fxml"));
public void newTreatmentWindow(Patient patient) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/NewTreatmentView.fxml")
);
AnchorPane pane = loader.load();
Scene scene = new Scene(pane);
@ -219,16 +192,13 @@ public class AllTreatmentController
stage.setScene(scene);
stage.setResizable(false);
stage.showAndWait();
} catch (IOException exception)
{
} catch (IOException exception) {
exception.printStackTrace();
}
}
public void treatmentWindow(Treatment treatment)
{
try
{
public void treatmentWindow(Treatment treatment) {
try {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentView.fxml"));
AnchorPane pane = loader.load();
Scene scene = new Scene(pane);
@ -241,8 +211,7 @@ public class AllTreatmentController
stage.setScene(scene);
stage.setResizable(false);
stage.showAndWait();
} catch (IOException exception)
{
} catch (IOException exception) {
exception.printStackTrace();
}
}

View file

@ -1,4 +1,6 @@
.vBox{
-fx-background-color: navy;
-fx-border-color: rgb(142, 142, 142);
/* https://materialui.co/colors */
.tabs{
-fx-background-color: #1565C0;
-fx-padding: 4px;
-fx-spacing: 4px;
}

View file

@ -1,25 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane fx:id="mainBorderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="688.0" prefWidth="926.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.main.MainWindowController">
<left>
<VBox id="vBox" alignment="CENTER" spacing="50.0" styleClass="vBox" stylesheets="@Application.css" BorderPane.alignment="CENTER">
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<BorderPane
fx:id="mainBorderPane"
maxHeight="-Infinity"
maxWidth="-Infinity"
minHeight="-Infinity"
minWidth="-Infinity"
prefHeight="688.0"
prefWidth="926.0"
xmlns="http://javafx.com/javafx/10.0.2-internal"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="de.hitec.nhplus.main.MainWindowController">
<top>
<HBox id="tabs" alignment="CENTER_LEFT" styleClass="tabs" stylesheets="@Application.css">
<children>
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowAllPatient" prefWidth="105.0" text="Patienten/innen">
<VBox.margin>
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
</VBox.margin>
<Button
alignment="CENTER"
contentDisplay="CENTER"
mnemonicParsing="false"
onAction="#handleShowAllPatient"
prefWidth="105.0"
text="Patienten"
>
<opaqueInsets>
<Insets/>
</opaqueInsets></Button>
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowAllTreatments" prefWidth="105.0" text="Behandlungen">
<VBox.margin>
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
</VBox.margin></Button>
</opaqueInsets>
</Button>
<Button
alignment="CENTER"
contentDisplay="CENTER"
mnemonicParsing="false"
onAction="#handleShowAllTreatments"
prefWidth="105.0"
text="Behandlungen"
></Button>
</children>
</VBox>
</left>
</HBox>
</top>
</BorderPane>

View file

@ -1,34 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.patient.AllPatientController">
<AnchorPane
prefHeight="500.0"
prefWidth="855.0"
xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="de.hitec.nhplus.patient.AllPatientController">
<children>
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="120.0" prefHeight="287.0" prefWidth="825.0" AnchorPane.bottomAnchor="100.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
<TableView
fx:id="tableView"
editable="true" layoutX="31.0"
layoutY="120.0" prefHeight="287.0"
prefWidth="825.0"
AnchorPane.bottomAnchor="100.0"
AnchorPane.leftAnchor="15.0"
AnchorPane.rightAnchor="15.0"
AnchorPane.topAnchor="80.0">
<columns>
<TableColumn fx:id="columnId" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
<TableColumn fx:id="columnSurname" maxWidth="7500.0" minWidth="20.0" onEditCommit="#handleOnEditSurname" prefWidth="100.0" text="Nachname" />
<TableColumn fx:id="columnFirstName" maxWidth="7500.0" onEditCommit="#handleOnEditFirstname" prefWidth="75.0" text="Vorname" />
<TableColumn fx:id="columnDateOfBirth" maxWidth="7500.0" onEditCommit="#handleOnEditDateOfBirth" prefWidth="75.0" text="Geburtstag" />
<TableColumn fx:id="columnCareLevel" onEditCommit="#handleOnEditCareLevel" prefWidth="75.0" text="Pflegegrad" />
<TableColumn fx:id="columnRoomNumber" onEditCommit="#handleOnEditRoomNumber" prefWidth="75.0" text="Raum" />
<TableColumn fx:id="columnId" maxWidth="-1.0" minWidth="40.0" prefWidth="5.0" text="ID"/>
<TableColumn fx:id="columnSurname" maxWidth="-1.0" minWidth="140.0" onEditCommit="#handleOnEditSurname"
prefWidth="100.0" text="Nachname"/>
<TableColumn fx:id="columnFirstName" maxWidth="-1.00" minWidth="140.0"
onEditCommit="#handleOnEditFirstname" prefWidth="75.0" text="Vorname"/>
<TableColumn fx:id="columnDateOfBirth" maxWidth="-1.0" minWidth="140.0"
onEditCommit="#handleOnEditDateOfBirth" prefWidth="75.0" text="Geburtstag"/>
<TableColumn fx:id="columnCareLevel" maxWidth="-1.0" minWidth="140.0"
onEditCommit="#handleOnEditCareLevel" prefWidth="75.0" text="Pflegegrad"/>
<TableColumn fx:id="columnRoomNumber" maxWidth="-1.0" minWidth="140.0"
onEditCommit="#handleOnEditRoomNumber" prefWidth="75.0" text="Raum"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0"
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
<children>
<GridPane hgap="10.0" vgap="10.0">
<columnConstraints>
@ -41,11 +51,16 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<TextField fx:id="textFieldFirstName" minWidth="200.0" prefHeight="26.0" prefWidth="200.0" promptText="Vorname" />
<TextField fx:id="textFieldSurname" minWidth="200.0" prefHeight="26.0" prefWidth="200.0" promptText="Nachname" GridPane.columnIndex="1" />
<TextField fx:id="textFieldDateOfBirth" minWidth="160.0" prefWidth="160.0" promptText="Geburtstag" GridPane.columnIndex="2" />
<TextField fx:id="textFieldCareLevel" prefHeight="26.0" prefWidth="200.0" promptText="Pflegegrad" GridPane.rowIndex="1" />
<TextField fx:id="textFieldRoomNumber" prefHeight="26.0" prefWidth="200.0" promptText="Raum" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="textFieldFirstName" minWidth="200.0" prefHeight="26.0" prefWidth="200.0"
promptText="Vorname"/>
<TextField fx:id="textFieldSurname" minWidth="200.0" prefHeight="26.0" prefWidth="200.0"
promptText="Nachname" GridPane.columnIndex="1"/>
<TextField fx:id="textFieldDateOfBirth" minWidth="160.0" prefWidth="160.0"
promptText="Geburtstag" GridPane.columnIndex="2"/>
<TextField fx:id="textFieldCareLevel" prefHeight="26.0" prefWidth="200.0"
promptText="Pflegegrad" GridPane.rowIndex="1"/>
<TextField fx:id="textFieldRoomNumber" prefHeight="26.0" prefWidth="200.0" promptText="Raum"
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
</children>
<padding>
<Insets right="10.0"/>
@ -56,15 +71,19 @@
</GridPane>
<HBox alignment="TOP_CENTER" prefWidth="190.0" spacing="10.0">
<children>
<Button fx:id="buttonAdd" mnemonicParsing="false" onAction="#handleAdd" prefWidth="90.0" text="Hinzufügen" />
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="90.0" text="Löschen" />
<Button fx:id="buttonAdd" mnemonicParsing="false" onAction="#handleAdd" prefWidth="90.0"
text="Hinzufügen"/>
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="90.0"
text="Löschen"/>
</children>
</HBox>
</children>
</HBox>
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0"
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Patienten/innen" textAlignment="CENTER">
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Patienten"
textAlignment="CENTER">
<font>
<Font size="36.0"/>
</font>

View file

@ -1,34 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.treatment.AllTreatmentController">
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.treatment.AllTreatmentController">
<children>
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="35.0" onMouseClicked="#handleMouseClick" prefHeight="364.0" prefWidth="825.0" AnchorPane.bottomAnchor="75.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="35.0" onMouseClicked="#handleMouseClick"
prefHeight="364.0" prefWidth="825.0" AnchorPane.bottomAnchor="75.0" AnchorPane.leftAnchor="15.0"
AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
<columns>
<TableColumn fx:id="columnId" maxWidth="-1.0" minWidth="40.0" prefWidth="50.0" text="ID"/>
<TableColumn fx:id="columnPatientId" maxWidth="-1.0" minWidth="100.0" prefWidth="120.0" text="PatientID" />
<TableColumn fx:id="columnPatientId" maxWidth="-1.0" minWidth="40.0" prefWidth="120.0"
text="PatientID"/>
<TableColumn fx:id="columnDate" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Datum"/>
<TableColumn fx:id="columnBegin" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Beginn"/>
<TableColumn fx:id="columnEnd" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Ende"/>
<TableColumn fx:id="columnDescription" maxWidth="-1.0" minWidth="200.0" prefWidth="300.0" text="Kurzbeschreibung" />
<TableColumn fx:id="columnDescription" maxWidth="-1.0" minWidth="200.0" prefWidth="300.0"
text="Kurzbeschreibung"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0"
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
<children>
<GridPane hgap="10.0" vgap="10.0">
<columnConstraints>
@ -40,9 +37,12 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Button fx:id="buttonNewTreament" mnemonicParsing="false" onAction="#handleNewTreatment" prefWidth="200.0" text="neue Behandlung anlegen" GridPane.columnIndex="1" />
<ComboBox fx:id="comboBoxPatientSelection" minWidth="160.0" onAction="#handleComboBox" prefWidth="200.0" />
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="200.0" text="Löschen" GridPane.columnIndex="2" />
<Button fx:id="buttonNewTreament" mnemonicParsing="false" onAction="#handleNewTreatment"
prefWidth="200.0" text="neue Behandlung anlegen" GridPane.columnIndex="1"/>
<ComboBox fx:id="comboBoxPatientSelection" minWidth="160.0" onAction="#handleComboBox"
prefWidth="200.0"/>
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="200.0"
text="Löschen" GridPane.columnIndex="2"/>
</children>
<padding>
<Insets right="10.0"/>
@ -54,9 +54,11 @@
<HBox prefWidth="190.0" spacing="10.0"/>
</children>
</HBox>
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="15.0">
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0"
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Behandlungen" textAlignment="CENTER">
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Behandlungen"
textAlignment="CENTER">
<font>
<Font size="36.0"/>
</font>