From ee67c83b2246419c148a97e0cd12339b055ca8aa Mon Sep 17 00:00:00 2001 From: giavaphi Date: Mon, 21 Nov 2022 00:03:19 +0100 Subject: [PATCH] update plant information plant fxml file --- .../zhaw/gartenverwaltung/PlantsController.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java b/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java index 8b821c1..5961c5f 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java @@ -41,7 +41,6 @@ public class PlantsController { private Plant selectedPlant = null; private final HardinessZone DEFAULT_HARDINESS_ZONE = HardinessZone.ZONE_8A; - // TODO: move to model private final ListProperty plantListProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); @FXML @@ -269,7 +268,7 @@ public class PlantsController { list_plants.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (newValue != null) { selectedPlant = newValue; - description_plant.setText(selectedPlant.description()); + description_plant.setText(getPlantDescription()); selectSowDay_button.setDisable(false); Image img1; if (selectedPlant.image() != null) { @@ -288,6 +287,20 @@ public class PlantsController { }); } + /** + * creates {@link String} of the plant information. + * @return return {@link Plant} description + */ + private String getPlantDescription() { + StringBuilder sb = new StringBuilder(); + sb.append("Name: ").append(selectedPlant.name()) + .append("\nDescription:\n").append(selectedPlant.description()) + .append("\nLight Level: ").append(selectedPlant.light()) + .append("\nSoil: ").append(selectedPlant.soil()) + .append("\nSpacing: ").append(selectedPlant.spacing()); + return sb.toString(); + } + /** * clears the ListView of entries