#26: Cleanup & Javadoc
This commit is contained in:
parent
ad3bd8ba0a
commit
8496f714d3
2 changed files with 33 additions and 24 deletions
|
@ -63,20 +63,20 @@ 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 -> {
|
cellData -> {
|
||||||
Medication medication = cellData.getValue();
|
Medication medication = cellData.getValue();
|
||||||
List<Ingredient> ingredients = medication.getIngredients();
|
List<Ingredient> ingredients = medication.getIngredients();
|
||||||
if(ingredients.isEmpty()){
|
if (ingredients.isEmpty()) {
|
||||||
return new SimpleStringProperty("");
|
return new SimpleStringProperty("");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SimpleStringProperty(
|
return new SimpleStringProperty(
|
||||||
ingredients
|
ingredients
|
||||||
.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"));
|
||||||
|
@ -96,6 +96,9 @@ public class AllMedicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to save the changes to a {@link Medication}.
|
||||||
|
*/
|
||||||
public void updateMedication(Medication medication) {
|
public void updateMedication(Medication medication) {
|
||||||
dao = DaoFactory.getInstance().createMedicationDAO();
|
dao = DaoFactory.getInstance().createMedicationDAO();
|
||||||
try {
|
try {
|
||||||
|
@ -117,6 +120,12 @@ public class AllMedicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
||||||
|
*
|
||||||
|
* @param medication The {@link Medication} which should be edited. Set null to create a new one.
|
||||||
|
* @param title The Title of the created modal.
|
||||||
|
*/
|
||||||
public void medicationWindow(Medication medication, String title) {
|
public void medicationWindow(Medication medication, String title) {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(
|
FXMLLoader loader = new FXMLLoader(
|
||||||
|
@ -148,7 +157,7 @@ public class AllMedicationController {
|
||||||
public void handleMouseClick() {
|
public void handleMouseClick() {
|
||||||
tableView.setOnMouseClicked(event -> {
|
tableView.setOnMouseClicked(event -> {
|
||||||
SelectionModel<Medication> selectionModel = tableView.getSelectionModel();
|
SelectionModel<Medication> selectionModel = tableView.getSelectionModel();
|
||||||
if(event.getClickCount() == 2 && (selectionModel.getSelectedItem() != null)){
|
if (event.getClickCount() == 2 && (selectionModel.getSelectedItem() != null)) {
|
||||||
int index = selectionModel.getSelectedIndex();
|
int index = selectionModel.getSelectedIndex();
|
||||||
Medication medication = this.medications.get(index);
|
Medication medication = this.medications.get(index);
|
||||||
medicationWindow(medication, "NHPlus - Medikament");
|
medicationWindow(medication, "NHPlus - Medikament");
|
||||||
|
|
|
@ -55,11 +55,11 @@ public class MedicationModalController {
|
||||||
Medication medication
|
Medication medication
|
||||||
) {
|
) {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.controller=controller;
|
this.controller = controller;
|
||||||
|
|
||||||
if( medication != null){
|
if (medication != null) {
|
||||||
this.medication = medication;
|
this.medication = medication;
|
||||||
}else {
|
} else {
|
||||||
isNewMedication = true;
|
isNewMedication = true;
|
||||||
this.medication = new Medication(
|
this.medication = new Medication(
|
||||||
"",
|
"",
|
||||||
|
@ -78,9 +78,9 @@ public class MedicationModalController {
|
||||||
|
|
||||||
ChangeListener<String> inputMedicationValidationListener = (observableValue, oldText, newText) -> {
|
ChangeListener<String> inputMedicationValidationListener = (observableValue, oldText, newText) -> {
|
||||||
boolean isValid = isValidMedicationName(textFieldName.getText())
|
boolean isValid = isValidMedicationName(textFieldName.getText())
|
||||||
&& isValidMedicationManufacturer(textFieldManufacturer.getText())
|
&& isValidMedicationManufacturer(textFieldManufacturer.getText())
|
||||||
&& isValidMedicationAdministrationMethod(textFieldAdministrationMethod.getText())
|
&& isValidMedicationAdministrationMethod(textFieldAdministrationMethod.getText())
|
||||||
&& isValidStock(textFieldCurrentStock.getText());
|
&& isValidStock(textFieldCurrentStock.getText());
|
||||||
|
|
||||||
this.buttonSave.setDisable(!isValid);
|
this.buttonSave.setDisable(!isValid);
|
||||||
};
|
};
|
||||||
|
@ -94,7 +94,7 @@ public class MedicationModalController {
|
||||||
/**
|
/**
|
||||||
* Internal method to show the data in the view.
|
* Internal method to show the data in the view.
|
||||||
*/
|
*/
|
||||||
private void showData(){
|
private void showData() {
|
||||||
ingredients.setAll(medication.getIngredients());
|
ingredients.setAll(medication.getIngredients());
|
||||||
textFieldName.setText(medication.getName());
|
textFieldName.setText(medication.getName());
|
||||||
textFieldManufacturer.setText(medication.getManufacturer());
|
textFieldManufacturer.setText(medication.getManufacturer());
|
||||||
|
@ -119,9 +119,9 @@ public class MedicationModalController {
|
||||||
.toList()
|
.toList()
|
||||||
);
|
);
|
||||||
|
|
||||||
if(isNewMedication){
|
if (isNewMedication) {
|
||||||
controller.createMedication(medication);
|
controller.createMedication(medication);
|
||||||
}else {
|
} else {
|
||||||
controller.updateMedication(medication);
|
controller.updateMedication(medication);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue