#23: Javadoc
This commit is contained in:
parent
c5237fed83
commit
8f31e85225
4 changed files with 49 additions and 1 deletions
|
@ -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 {
|
||||
|
|
|
@ -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<Ingredient> {
|
||||
private final TextField textField;
|
||||
private final Button deleteButton;
|
||||
|
@ -65,6 +71,9 @@ public class IngredientListCell extends ListCell<Ingredient> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Callback for use as a Listener for the {@link IngredientListCell#textField}.
|
||||
*/
|
||||
private void onTextFieldUpdate(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||
getItem().setName(textField.getText());
|
||||
|
||||
|
@ -81,6 +90,9 @@ public class IngredientListCell extends ListCell<Ingredient> {
|
|||
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());
|
||||
|
|
|
@ -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<Ingredient> 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());
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue