#16: Setup Controller and View
All checks were successful
Quality Check / Qualty Check (push) Successful in 8s
Quality Check / Qualty Check (pull_request) Successful in 8s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-04-27 23:47:07 +02:00
parent 4a9dace345
commit 2bd06fab41
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
6 changed files with 149 additions and 64 deletions

Binary file not shown.

View file

@ -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<Nurse> tableView;
@FXML
private TableColumn<Nurse, Long> columnId;
@FXML
private TableColumn<Nurse, String> columnFirstName;
@FXML
private TableColumn<Nurse, String> columnSurname;
@FXML
private TableColumn<Nurse, String> columnPhoneNumber;
private final ObservableList<Nurse> 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();
}
}
}

View file

@ -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();
}
}
}

View file

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
<columns>
<TableColumn fx:id="colID" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
<TableColumn fx:id="colSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname" />
<TableColumn fx:id="colFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname" />
<TableColumn fx:id="colTelephone" maxWidth="7500.0" prefWidth="75.0" text="Telefon" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TableView>
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
<children>
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname" />
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname" />
<TextField fx:id="txfTelephone" prefWidth="160.0" promptText="Telefonnummer" />
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen" />
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen" />
</children>
</HBox>
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen" textAlignment="CENTER">
<font>
<Font size="36.0" />
</font>
</Label>
</children>
</HBox>
</children>
<padding>
<Insets top="10.0" />
</padding>
</AnchorPane>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?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/10.0.2-internal"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.AllNurseController">
<children>
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.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" prefWidth="100.0" text="Nachname"/>
<TableColumn fx:id="columnFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname"/>
<TableColumn fx:id="columnPhoneNumber" maxWidth="7500.0" prefWidth="75.0" text="Telefonnummer"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0"
AnchorPane.rightAnchor="15.0">
<children>
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname"/>
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname"/>
<TextField fx:id="txfPhoneNumber" prefWidth="160.0" promptText="Telefonnummer"/>
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen"/>
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen"/>
</children>
</HBox>
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0"
AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen"
textAlignment="CENTER">
<font>
<Font size="36.0"/>
</font>
</Label>
</children>
</HBox>
</children>
<padding>
<Insets top="10.0"/>
</padding>
</AnchorPane>

View file

@ -1,25 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?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.controller.MainWindowController">
<left>
<VBox id="vBox" alignment="CENTER" spacing="50.0" styleClass="vBox" stylesheets="@Application.css" BorderPane.alignment="CENTER">
<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>
<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>
</children>
</VBox>
</left>
<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.controller.MainWindowController">
<left>
<VBox id="vBox" alignment="CENTER" spacing="50.0" styleClass="vBox" stylesheets="@Application.css"
BorderPane.alignment="CENTER">
<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>
<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>
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false"
onAction="#handleShowAllNurses" prefWidth="105.0" text="Pfleger/innen">
<VBox.margin>
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0"/>
</VBox.margin>
</Button>
</children>
</VBox>
</left>
</BorderPane>