#54 update Seasons enum + update method name + javadoc update
This commit is contained in:
parent
2cf7f55215
commit
e92538fbb4
|
@ -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<Plant> 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<Insets bottom="10.0" top="10.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<Button fx:id="saveToMyPlant_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#saveToMyPlant" prefHeight="38.0" prefWidth="917.0" text="Save to MyPlants" />
|
||||
<Button fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" />
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
|
|
Loading…
Reference in New Issue