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