Refaktoring #21

Merged
SZUT-Dominik merged 12 commits from refactor into main 2024-04-30 12:21:17 +00:00
6 changed files with 252 additions and 193 deletions
Showing only changes of commit faebf31a91 - Show all commits

View file

@ -6,6 +6,7 @@ import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -23,12 +24,12 @@ public class Main extends Application {
public void mainWindow() { public void mainWindow() {
try { try {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/MainWindowView.fxml")); FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/MainWindowView.fxml"));
BorderPane pane = loader.load(); TabPane pane = loader.load();
Scene scene = new Scene(pane); Scene scene = new Scene(pane);
this.primaryStage.setTitle("NHPlus"); this.primaryStage.setTitle("NHPlus");
this.primaryStage.setScene(scene); this.primaryStage.setScene(scene);
this.primaryStage.setResizable(false); this.primaryStage.setResizable(true);
this.primaryStage.show(); this.primaryStage.show();
this.primaryStage.setOnCloseRequest(event -> { this.primaryStage.setOnCloseRequest(event -> {

View file

@ -1,37 +1,58 @@
package de.hitec.nhplus.main; package de.hitec.nhplus.main;
import de.hitec.nhplus.Main; import de.hitec.nhplus.Main;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.control.Tab;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import java.io.IOException; import java.io.IOException;
public class MainWindowController { public class MainWindowController {
@FXML @FXML
private BorderPane mainBorderPane; private AnchorPane patientPage;
@FXML
private Tab patientTab;
@FXML
private AnchorPane treatmentPage;
@FXML
private Tab treatmentTab;
@FXML @FXML
public void initialize() { public void initialize() {
handleShowAllPatient(null); loadPatientPage();
loadTreatmentsPage();
patientTab.setOnSelectionChanged(event -> loadPatientPage());
treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage());
} }
@FXML private void loadPatientPage() {
private void handleShowAllPatient(ActionEvent event) {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/patient/AllPatientView.fxml"));
try { try {
mainBorderPane.setCenter(loader.load()); BorderPane patientsPane = FXMLLoader.load(
Main.class.getResource("/de/hitec/nhplus/patient/AllPatientView.fxml")
);
patientPage.getChildren().setAll(patientsPane);
AnchorPane.setTopAnchor(patientsPane, 0d);
AnchorPane.setBottomAnchor(patientsPane, 0d);
AnchorPane.setLeftAnchor(patientsPane, 0d);
AnchorPane.setRightAnchor(patientsPane, 0d);
} catch (IOException exception) { } catch (IOException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@FXML private void loadTreatmentsPage() {
private void handleShowAllTreatments(ActionEvent event) {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/treatment/AllTreatmentView.fxml"));
try { try {
mainBorderPane.setCenter(loader.load()); BorderPane treatmentsPane = FXMLLoader.load(
Main.class.getResource("/de/hitec/nhplus/treatment/AllTreatmentView.fxml")
);
treatmentPage.getChildren().setAll(treatmentsPane);
AnchorPane.setTopAnchor(treatmentsPane, 0d);
AnchorPane.setBottomAnchor(treatmentsPane, 0d);
AnchorPane.setLeftAnchor(treatmentsPane, 0d);
AnchorPane.setRightAnchor(treatmentsPane, 0d);
} catch (IOException exception) { } catch (IOException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }

View file

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

View file

@ -1,44 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?> <?import javafx.scene.control.Tab?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <TabPane
<BorderPane tabClosingPolicy="UNAVAILABLE"
fx:id="mainBorderPane" xmlns="http://javafx.com/javafx/17.0.2-ea"
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" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="de.hitec.nhplus.main.MainWindowController"> fx:controller="de.hitec.nhplus.main.MainWindowController"
<top> >
<HBox id="tabs" alignment="CENTER_LEFT" styleClass="tabs" stylesheets="@Application.css"> <Tab fx:id="patientTab" text="Patienten">
<children> <AnchorPane fx:id="patientPage"/>
<Button </Tab>
alignment="CENTER" <Tab fx:id="treatmentTab" text="Behandlungen">
contentDisplay="CENTER" <AnchorPane fx:id="treatmentPage"/>
mnemonicParsing="false" </Tab>
onAction="#handleShowAllPatient" </TabPane>
prefWidth="105.0"
text="Patienten"
>
<opaqueInsets>
<Insets/>
</opaqueInsets>
</Button>
<Button
alignment="CENTER"
contentDisplay="CENTER"
mnemonicParsing="false"
onAction="#handleShowAllTreatments"
prefWidth="105.0"
text="Behandlungen"
></Button>
</children>
</HBox>
</top>
</BorderPane>

View file

@ -3,44 +3,72 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?> <BorderPane
<AnchorPane
prefHeight="500.0"
prefWidth="855.0"
xmlns="http://javafx.com/javafx/11.0.1" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="de.hitec.nhplus.patient.AllPatientController"> fx:controller="de.hitec.nhplus.patient.AllPatientController"
<children> >
<padding>
<Insets top="8" left="8" bottom="8" right="8"/>
</padding>
<center>
<TableView <TableView
fx:id="tableView" fx:id="tableView"
editable="true" layoutX="31.0" editable="true"
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> <columns>
<TableColumn fx:id="columnId" maxWidth="-1.0" minWidth="40.0" prefWidth="5.0" text="ID"/> <TableColumn
<TableColumn fx:id="columnSurname" maxWidth="-1.0" minWidth="140.0" onEditCommit="#handleOnEditSurname" fx:id="columnId"
prefWidth="100.0" text="Nachname"/> minWidth="40.0"
<TableColumn fx:id="columnFirstName" maxWidth="-1.00" minWidth="140.0" text="ID"
onEditCommit="#handleOnEditFirstname" prefWidth="75.0" text="Vorname"/> />
<TableColumn fx:id="columnDateOfBirth" maxWidth="-1.0" minWidth="140.0" <TableColumn
onEditCommit="#handleOnEditDateOfBirth" prefWidth="75.0" text="Geburtstag"/> fx:id="columnSurname"
<TableColumn fx:id="columnCareLevel" maxWidth="-1.0" minWidth="140.0" minWidth="140.0"
onEditCommit="#handleOnEditCareLevel" prefWidth="75.0" text="Pflegegrad"/> onEditCommit="#handleOnEditSurname"
<TableColumn fx:id="columnRoomNumber" maxWidth="-1.0" minWidth="140.0" text="Nachname"
onEditCommit="#handleOnEditRoomNumber" prefWidth="75.0" text="Raum"/> />
<TableColumn
fx:id="columnFirstName"
minWidth="140.0"
onEditCommit="#handleOnEditFirstname"
text="Vorname"
/>
<TableColumn
fx:id="columnDateOfBirth"
minWidth="140.0"
onEditCommit="#handleOnEditDateOfBirth"
text="Geburtstag"
/>
<TableColumn
fx:id="columnCareLevel"
minWidth="140.0"
onEditCommit="#handleOnEditCareLevel"
prefWidth="75.0"
text="Pflegegrad"
/>
<TableColumn
fx:id="columnRoomNumber"
minWidth="140.0"
onEditCommit="#handleOnEditRoomNumber"
text="Raum"
/>
</columns> </columns>
<columnResizePolicy> <columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/> <TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy> </columnResizePolicy>
</TableView> </TableView>
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" </center>
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0"> <bottom>
<children> <BorderPane>
<GridPane hgap="10.0" vgap="10.0"> <BorderPane.margin>
<Insets top="8.0"/>
</BorderPane.margin>
<center>
<GridPane hgap="8.0" vgap="8.0">
<padding>
<Insets right="48.0"/>
</padding>
<columnConstraints> <columnConstraints>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" prefWidth="200.0"/> <ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" prefWidth="200.0"/>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="200.0" prefWidth="200.0"/> <ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="200.0" prefWidth="200.0"/>
@ -50,48 +78,65 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints> </rowConstraints>
<children> <TextField
<TextField fx:id="textFieldFirstName" minWidth="200.0" prefHeight="26.0" prefWidth="200.0" fx:id="textFieldFirstName"
promptText="Vorname"/> minWidth="200.0"
<TextField fx:id="textFieldSurname" minWidth="200.0" prefHeight="26.0" prefWidth="200.0" prefHeight="26.0"
promptText="Nachname" GridPane.columnIndex="1"/> prefWidth="200.0"
<TextField fx:id="textFieldDateOfBirth" minWidth="160.0" prefWidth="160.0" promptText="Vorname"
promptText="Geburtstag" GridPane.columnIndex="2"/> />
<TextField fx:id="textFieldCareLevel" prefHeight="26.0" prefWidth="200.0" <TextField
promptText="Pflegegrad" GridPane.rowIndex="1"/> fx:id="textFieldSurname"
<TextField fx:id="textFieldRoomNumber" prefHeight="26.0" prefWidth="200.0" promptText="Raum" minWidth="200.0"
GridPane.columnIndex="1" GridPane.rowIndex="1"/> prefHeight="26.0"
</children> prefWidth="200.0"
<padding> promptText="Nachname"
<Insets right="10.0"/> GridPane.columnIndex="1"
</padding> />
<HBox.margin> <TextField
<Insets/> fx:id="textFieldDateOfBirth"
</HBox.margin> 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"
/>
</GridPane> </GridPane>
<HBox alignment="TOP_CENTER" prefWidth="190.0" spacing="10.0"> </center>
<children> <right>
<Button fx:id="buttonAdd" mnemonicParsing="false" onAction="#handleAdd" prefWidth="90.0" <VBox spacing="8.0">
text="Hinzufügen"/> <Button
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="90.0" fx:id="buttonAdd"
text="Löschen"/> mnemonicParsing="false"
</children> onAction="#handleAdd"
</HBox> prefWidth="90.0"
</children> text="Hinzufügen"
</HBox> />
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" <Button
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0"> fx:id="buttonDelete"
<children> mnemonicParsing="false"
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Patienten" onAction="#handleDelete"
textAlignment="CENTER"> prefWidth="90.0"
<font> text="Löschen"
<Font size="36.0"/> />
</font> </VBox>
</Label> </right>
</children> </BorderPane>
</HBox> </bottom>
</children> </BorderPane>
<padding>
<Insets top="10.0"/>
</padding>
</AnchorPane>

View file

@ -3,70 +3,93 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?> <BorderPane
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.treatment.AllTreatmentController"> xmlns:fx="http://javafx.com/fxml/1"
<children> fx:controller="de.hitec.nhplus.treatment.AllTreatmentController"
<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" <padding>
AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0"> <Insets top="8" left="8" bottom="8" right="8"/>
</padding>
<center>
<TableView
fx:id="tableView"
editable="true"
onMouseClicked="#handleMouseClick"
>
<columns> <columns>
<TableColumn fx:id="columnId" maxWidth="-1.0" minWidth="40.0" prefWidth="50.0" text="ID"/> <TableColumn
<TableColumn fx:id="columnPatientId" maxWidth="-1.0" minWidth="40.0" prefWidth="120.0" fx:id="columnId"
text="PatientID"/> minWidth="40.0"
<TableColumn fx:id="columnDate" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Datum"/> text="ID"
<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
<TableColumn fx:id="columnDescription" maxWidth="-1.0" minWidth="200.0" prefWidth="300.0" fx:id="columnPatientId"
text="Kurzbeschreibung"/> minWidth="40.0"
text="PatientID"
/>
<TableColumn
fx:id="columnDate"
maxWidth="-1.0"
minWidth="140.0"
prefWidth="150.0"
text="Datum"
/>
<TableColumn
fx:id="columnBegin"
minWidth="140.0"
text="Beginn"
/>
<TableColumn
fx:id="columnEnd"
minWidth="140.0"
text="Ende"
/>
<TableColumn
fx:id="columnDescription"
minWidth="200.0"
text="Kurzbeschreibung"
/>
</columns> </columns>
<columnResizePolicy> <columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/> <TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy> </columnResizePolicy>
</TableView> </TableView>
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" </center>
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0"> <bottom>
<children> <BorderPane>
<GridPane hgap="10.0" vgap="10.0"> <BorderPane.margin>
<columnConstraints> <Insets top="8.0"/>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" prefWidth="200.0"/> </BorderPane.margin>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="200.0" prefWidth="200.0"/> <center>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="160.0"/> <HBox spacing="8.0">
</columnConstraints> <Button
<rowConstraints> fx:id="buttonNewTreament"
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/> mnemonicParsing="false"
</rowConstraints> onAction="#handleNewTreatment"
<children> prefWidth="200.0"
<Button fx:id="buttonNewTreament" mnemonicParsing="false" onAction="#handleNewTreatment" text="neue Behandlung anlegen"
prefWidth="200.0" text="neue Behandlung anlegen" GridPane.columnIndex="1"/> GridPane.columnIndex="1"
<ComboBox fx:id="comboBoxPatientSelection" minWidth="160.0" onAction="#handleComboBox" />
<ComboBox
fx:id="comboBoxPatientSelection"
minWidth="160.0"
onAction="#handleComboBox"
prefWidth="200.0"/> 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"/>
</padding>
<HBox.margin>
<Insets/>
</HBox.margin>
</GridPane>
<HBox prefWidth="190.0" spacing="10.0"/>
</children>
</HBox> </HBox>
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" </center>
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0"> <right>
<children> <Button
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Behandlungen" fx:id="buttonDelete"
textAlignment="CENTER"> mnemonicParsing="false"
<font> onAction="#handleDelete"
<Font size="36.0"/> prefWidth="200.0"
</font> text="Löschen"
</Label> GridPane.columnIndex="2"
</children> />
</HBox> </right>
</children> </BorderPane>
<padding>
<Insets top="10.0"/> </bottom>
</padding> </BorderPane>
</AnchorPane>