diff --git a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java index b10f266..ee217ad 100644 --- a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java +++ b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java @@ -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 tableView; @@ -53,8 +52,7 @@ public class AllTreatmentController private final ObservableList patientSelection = FXCollections.observableArrayList(); private ArrayList patientList; - public void initialize() - { + public void initialize() { readAllAndShowInTableView(); comboBoxPatientSelection.setItems(patientSelection); comboBoxPatientSelection.getSelectionModel().select(0); @@ -69,86 +67,69 @@ public class AllTreatmentController this.buttonDelete.setDisable(true); this.tableView - .getSelectionModel() - .selectedItemProperty() - .addListener((observableValue, oldTreatment, newTreatment) -> - { - AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null); - } - ); + .getSelectionModel() + .selectedItemProperty() + .addListener((observableValue, oldTreatment, newTreatment) -> + { + AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null); + } + ); 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) 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(); } } diff --git a/src/main/resources/de/hitec/nhplus/Application.css b/src/main/resources/de/hitec/nhplus/Application.css index 20cf4b4..feaa0ee 100644 --- a/src/main/resources/de/hitec/nhplus/Application.css +++ b/src/main/resources/de/hitec/nhplus/Application.css @@ -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; } diff --git a/src/main/resources/de/hitec/nhplus/MainWindowView.fxml b/src/main/resources/de/hitec/nhplus/MainWindowView.fxml index 83afde7..861efcc 100644 --- a/src/main/resources/de/hitec/nhplus/MainWindowView.fxml +++ b/src/main/resources/de/hitec/nhplus/MainWindowView.fxml @@ -1,25 +1,44 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/main/resources/de/hitec/nhplus/patient/AllPatientView.fxml b/src/main/resources/de/hitec/nhplus/patient/AllPatientView.fxml index 6a189ed..a7908fa 100644 --- a/src/main/resources/de/hitec/nhplus/patient/AllPatientView.fxml +++ b/src/main/resources/de/hitec/nhplus/patient/AllPatientView.fxml @@ -1,78 +1,97 @@ - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -