From e92538fbb48e4b891f6cbb40877cdd188dfe394f Mon Sep 17 00:00:00 2001 From: giavaphi Date: Sat, 5 Nov 2022 17:19:41 +0100 Subject: [PATCH] #54 update Seasons enum + update method name + javadoc update --- .../zhaw/gartenverwaltung/PlantsController.java | 15 +++++++-------- .../ch/zhaw/gartenverwaltung/types/Seasons.java | 17 +++++++++++------ .../ch/zhaw/gartenverwaltung/Plants.fxml | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java b/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java index 894fb87..0d4764e 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/PlantsController.java @@ -20,7 +20,6 @@ import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; import javafx.scene.layout.VBox; import javafx.stage.Modality; import javafx.stage.Stage; @@ -55,17 +54,17 @@ public class PlantsController implements Initializable { private ListView list_plants; @FXML - private Button saveToMyPlant_button; + private Button selectSowDay_button; @FXML private TextField search_plants; /** - * saves the current selected plant in new JSON database + * open new window to select sow or harvest day to save the crop * @param event event */ @FXML - void saveToMyPlant(ActionEvent event) throws IOException { + void selectSowDate(ActionEvent event) throws IOException { Parent root; FXMLLoader fxmlLoader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("SelectSowDay.fxml"))); root = fxmlLoader.load(); @@ -92,7 +91,7 @@ public class PlantsController implements Initializable { list_plants.itemsProperty().bind(plantListProperty); description_plant.setText(""); - saveToMyPlant_button.setDisable(true); + selectSowDay_button.setDisable(true); createFilterSeasons(); createFilterHardinessZone(); @@ -202,7 +201,7 @@ public class PlantsController implements Initializable { private void createFilterSeasons() { ToggleGroup seasonGroup = new ToggleGroup(); for (Seasons season : Seasons.values()) { - RadioButton radioButton = new RadioButton(season.name()); + RadioButton radioButton = new RadioButton(season.getName()); radioButton.setToggleGroup(seasonGroup); radioButton.setPadding(new Insets(0,0,10,0)); if (season.equals(Seasons.AllSEASONS)) { @@ -239,7 +238,7 @@ public class PlantsController implements Initializable { if(newValue != null) { selectedPlant = newValue; description_plant.setText(selectedPlant.description()); - saveToMyPlant_button.setDisable(false); + selectSowDay_button.setDisable(false); Image img; if(selectedPlant.image() != null) { img = selectedPlant.image(); @@ -252,7 +251,7 @@ public class PlantsController implements Initializable { } else { selectedPlant = null; description_plant.setText(""); - saveToMyPlant_button.setDisable(true); + selectSowDay_button.setDisable(true); Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png"))); img_plant.setImage(img); } diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java b/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java index 5e907a4..2a2d2d0 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/Seasons.java @@ -3,18 +3,20 @@ package ch.zhaw.gartenverwaltung.types; import java.time.MonthDay; public enum Seasons { - AllSEASONS("--01-01", "--12-31"), - SPRING("--03-01", "--05-30"), - SOMMER("--06-01", "--08-30"), - AUTUM("--09-01", "--11-30"), - WINTER("--12-01", "--02-28"); + AllSEASONS("--01-01", "--12-31", "All Seasons"), + SPRING("--03-01", "--05-30", "Spring"), + SUMMER("--06-01", "--08-30", "Summer"), + AUTUMN("--09-01", "--11-30", "Autumn"), + WINTER("--12-01", "--02-28", "Winter"); public final String startDate; public final String endDate; + public final String name; - Seasons(String startDate, String endDate) { + Seasons(String startDate, String endDate, String name) { this.startDate = startDate; this.endDate = endDate; + this.name = name; } public MonthDay getStartDate() { @@ -23,4 +25,7 @@ public enum Seasons { public MonthDay getEndDate() { return MonthDay.parse(this.endDate); } + public String getName() { + return this.name; + } } diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/Plants.fxml b/src/main/resources/ch/zhaw/gartenverwaltung/Plants.fxml index 4fbb89b..4341e7b 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/Plants.fxml +++ b/src/main/resources/ch/zhaw/gartenverwaltung/Plants.fxml @@ -57,7 +57,7 @@ -