update plant information plant fxml file

This commit is contained in:
giavaphi 2022-11-21 00:03:19 +01:00
parent 2963872237
commit ee67c83b22
1 changed files with 15 additions and 2 deletions

View File

@ -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<Plant> 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