diff --git a/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java b/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java index 2b4aab7..1370ff0 100644 --- a/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java +++ b/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java @@ -24,6 +24,7 @@ import javafx.stage.Stage; * The controller for viewing all {@link Medication}s. * * @author Dominik Säume + * @author Ole Kück */ public class AllMedicationController { @FXML @@ -90,6 +91,9 @@ public class AllMedicationController { } } + /** + * Method to create a new {@link Medication}. + */ public void createMedication(Medication medication) { dao = DaoFactory.getInstance().createMedicationDAO(); try { diff --git a/src/main/java/de/hitec/nhplus/medication/IngredientListCell.java b/src/main/java/de/hitec/nhplus/medication/IngredientListCell.java index 0e15a32..5156e4d 100644 --- a/src/main/java/de/hitec/nhplus/medication/IngredientListCell.java +++ b/src/main/java/de/hitec/nhplus/medication/IngredientListCell.java @@ -9,6 +9,12 @@ import javafx.scene.control.TextField; import javafx.scene.layout.BorderPane; import javafx.scene.text.Text; +/** + * A custom implementation of the {@link ListCell} for {@link Ingredient}s. + * This implementation contains an automatic resizing of the parent {@link ListView}. + * + * @author Dominik Säume + */ public class IngredientListCell extends ListCell { private final TextField textField; private final Button deleteButton; @@ -65,6 +71,9 @@ public class IngredientListCell extends ListCell { } } + /** + * A Callback for use as a Listener for the {@link IngredientListCell#textField}. + */ private void onTextFieldUpdate(ObservableValue observable, String oldValue, String newValue) { getItem().setName(textField.getText()); @@ -81,6 +90,9 @@ public class IngredientListCell extends ListCell { getListView().setMinWidth(max + totalSpacing); } + /** + * Internal method to calculate the required width of the {@link IngredientListCell#textField}. + */ private double getTextFieldRequiredWidth(TextField textField) { Text textNode = new Text(textField.getText()); textNode.setFont(textField.getFont()); diff --git a/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java b/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java index c8f572f..76a97c3 100644 --- a/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java +++ b/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java @@ -1,5 +1,6 @@ package de.hitec.nhplus.medication; +import de.hitec.nhplus.treatment.Treatment; import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -16,6 +17,11 @@ import java.util.function.Predicate; import static de.hitec.nhplus.utils.Validator.*; +/** + * The controller for creating and editing a specific {@link Medication}. + * + * @author Ole Kück + */ public class MedicationModalController { @FXML @@ -38,8 +44,15 @@ public class MedicationModalController { private final ObservableList ingredients = FXCollections.observableArrayList(); private AllMedicationController controller; + /** + * Initialization method that is called after the binding of all the fields. + */ @FXML - public void initialize(Stage stage, AllMedicationController controller, Medication medication) { + public void initialize( + Stage stage, + AllMedicationController controller, + Medication medication + ) { this.stage = stage; this.controller=controller; @@ -76,6 +89,9 @@ public class MedicationModalController { this.textFieldCurrentStock.textProperty().addListener(inputMedicationValidationListener); } + /** + * Internal method to show the data in the view. + */ private void showData(){ ingredients.setAll(medication.getIngredients()); textFieldName.setText(medication.getName()); diff --git a/src/main/java/de/hitec/nhplus/utils/Validator.java b/src/main/java/de/hitec/nhplus/utils/Validator.java index f331fa9..24c9416 100644 --- a/src/main/java/de/hitec/nhplus/utils/Validator.java +++ b/src/main/java/de/hitec/nhplus/utils/Validator.java @@ -149,18 +149,34 @@ public class Validator { return !text.isBlank(); } + /** + * Validate that a {@link String} is a valid {@link de.hitec.nhplus.medication.Medication#name Medication name}. + * @param text The {@link String} to validate. + */ public static boolean isValidMedicationName(String text) { return !text.isBlank(); } + /** + * Validate that a {@link String} is a valid {@link de.hitec.nhplus.medication.Medication#manufacturer Medication manufacturer}. + * @param text The {@link String} to validate. + */ public static boolean isValidMedicationManufacturer(String text) { return !text.isBlank(); } + /** + * Validate that a {@link String} is a valid {@link de.hitec.nhplus.medication.Medication#administrationMethod Medication administration method}. + * @param text The {@link String} to validate. + */ public static boolean isValidMedicationAdministrationMethod(String text) { return !text.isBlank(); } + /** + * Validate that a {@link String} is a valid stock count. + * @param text The {@link String} to validate. + */ public static boolean isValidStock(String text) { if (text.isBlank()) { return false;