Compare commits
2 commits
942577a86a
...
930eba22e1
Author | SHA1 | Date | |
---|---|---|---|
930eba22e1 | |||
d89c0f49e4 |
3 changed files with 16 additions and 69 deletions
|
@ -1,15 +1,12 @@
|
||||||
package de.hitec.nhplus.medication;
|
package de.hitec.nhplus.medication;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
@ -19,6 +16,10 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller for viewing all {@link Medication}s.
|
* The controller for viewing all {@link Medication}s.
|
||||||
*
|
*
|
||||||
|
@ -56,14 +57,14 @@ public class AllMedicationController {
|
||||||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||||
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
||||||
this.columnIngredient.setCellValueFactory(
|
this.columnIngredient.setCellValueFactory(
|
||||||
cellData -> new SimpleStringProperty(
|
cellData -> new SimpleStringProperty(
|
||||||
cellData
|
cellData
|
||||||
.getValue()
|
.getValue()
|
||||||
.getIngredients()
|
.getIngredients()
|
||||||
.stream()
|
.stream()
|
||||||
.map(ingredient -> ingredient.getName())
|
.map(ingredient -> ingredient.getName())
|
||||||
.collect(Collectors.joining("\n"))
|
.collect(Collectors.joining("\n"))
|
||||||
));
|
));
|
||||||
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
|
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
|
||||||
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
|
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
|
||||||
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
||||||
|
@ -83,15 +84,6 @@ public class AllMedicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createMedication(Medication medication) {
|
|
||||||
dao = DaoFactory.getInstance().createMedicationDAO();
|
|
||||||
try {
|
|
||||||
dao.create(medication);
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleNewMedication() {
|
public void handleNewMedication() {
|
||||||
try {
|
try {
|
||||||
|
@ -103,7 +95,7 @@ public class AllMedicationController {
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
|
|
||||||
MedicationModalController controller = loader.getController();
|
MedicationModalController controller = loader.getController();
|
||||||
controller.initialize(stage, this, null);
|
controller.initialize(null);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setTitle("NHPlus - Neues Medikament");
|
stage.setTitle("NHPlus - Neues Medikament");
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
package de.hitec.nhplus.medication;
|
package de.hitec.nhplus.medication;
|
||||||
|
|
||||||
import de.hitec.nhplus.treatment.AllTreatmentController;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.control.TextArea;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MedicationModalController {
|
public class MedicationModalController {
|
||||||
|
@ -16,27 +11,13 @@ public class MedicationModalController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public ListView<Ingredient> listViewIngredients;
|
public ListView<Ingredient> listViewIngredients;
|
||||||
@FXML
|
|
||||||
public TextField textFieldName;
|
|
||||||
@FXML
|
|
||||||
public TextField textFieldManufacturer;
|
|
||||||
@FXML
|
|
||||||
public TextField textFieldAdministrationMethod;
|
|
||||||
@FXML
|
|
||||||
public TextField textFieldCurrentStock;
|
|
||||||
@FXML
|
|
||||||
public TextArea textAreaPossibleSideEffects;
|
|
||||||
|
|
||||||
private Stage stage;
|
|
||||||
|
|
||||||
private Medication medication;
|
private Medication medication;
|
||||||
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
||||||
private AllMedicationController controller;
|
private AllMedicationController controller;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize(Stage stage, AllMedicationController controller, Medication medication) {
|
public void initialize(Medication medication) {
|
||||||
this.stage = stage;
|
|
||||||
this.controller=controller;
|
|
||||||
this.medication = medication != null ? medication : new Medication(
|
this.medication = medication != null ? medication : new Medication(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -54,25 +35,10 @@ public class MedicationModalController {
|
||||||
|
|
||||||
private void showData(){
|
private void showData(){
|
||||||
ingredients.setAll(medication.getIngredients());
|
ingredients.setAll(medication.getIngredients());
|
||||||
textFieldName.setText(medication.getName());
|
|
||||||
textFieldManufacturer.setText(medication.getManufacturer());
|
|
||||||
textFieldAdministrationMethod.setText(medication.getAdministrationMethod());
|
|
||||||
textFieldCurrentStock.setText(String.valueOf(medication.getCurrentStock()));
|
|
||||||
textAreaPossibleSideEffects.setText(medication.getPossibleSideEffects());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleSave() {
|
public void handleSave() {
|
||||||
this.medication.setName(textFieldName.getText());
|
|
||||||
this.medication.setManufacturer(textFieldManufacturer.getText());
|
|
||||||
this.medication.setAdministrationMethod(textFieldAdministrationMethod.getText());
|
|
||||||
this.medication.setCurrentStock(Integer.parseInt(textFieldCurrentStock.getText()));
|
|
||||||
this.medication.setPossibleSideEffects(textAreaPossibleSideEffects.getText());
|
|
||||||
this.medication.setIngredients(ingredients);
|
|
||||||
|
|
||||||
controller.createMedication(medication);
|
|
||||||
controller.readAllAndShowInTableView();
|
|
||||||
stage.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
text="Name:"
|
text="Name:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fx:id="textFieldName"
|
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
/>
|
/>
|
||||||
|
@ -42,7 +41,6 @@
|
||||||
text="Hersteller:"
|
text="Hersteller:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fx:id="textFieldManufacturer"
|
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
/>
|
/>
|
||||||
|
@ -53,7 +51,6 @@
|
||||||
text="Verabreichungsmethode:"
|
text="Verabreichungsmethode:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fx:id="textFieldAdministrationMethod"
|
|
||||||
GridPane.rowIndex="1"
|
GridPane.rowIndex="1"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
/>
|
/>
|
||||||
|
@ -63,7 +60,6 @@
|
||||||
text="Lagerbestand:"
|
text="Lagerbestand:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fx:id="textFieldCurrentStock"
|
|
||||||
GridPane.rowIndex="1"
|
GridPane.rowIndex="1"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
/>
|
/>
|
||||||
|
@ -106,14 +102,7 @@
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</left>
|
</left>
|
||||||
<center>
|
<center>
|
||||||
<BorderPane>
|
<TextArea/>
|
||||||
<top>
|
|
||||||
<Label text="Nebenwirkungen"/>
|
|
||||||
</top>
|
|
||||||
<center>
|
|
||||||
<TextArea fx:id="textAreaPossibleSideEffects"/>
|
|
||||||
</center>
|
|
||||||
</BorderPane>
|
|
||||||
</center>
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</center>
|
</center>
|
||||||
|
|
Loading…
Reference in a new issue