#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.control.*;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
@ -55,17 +54,17 @@ public class PlantsController implements Initializable {
|
||||||
private ListView<Plant> list_plants;
|
private ListView<Plant> list_plants;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button saveToMyPlant_button;
|
private Button selectSowDay_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TextField search_plants;
|
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
|
* @param event event
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void saveToMyPlant(ActionEvent event) throws IOException {
|
void selectSowDate(ActionEvent event) throws IOException {
|
||||||
Parent root;
|
Parent root;
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("SelectSowDay.fxml")));
|
FXMLLoader fxmlLoader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("SelectSowDay.fxml")));
|
||||||
root = fxmlLoader.load();
|
root = fxmlLoader.load();
|
||||||
|
@ -92,7 +91,7 @@ public class PlantsController implements Initializable {
|
||||||
list_plants.itemsProperty().bind(plantListProperty);
|
list_plants.itemsProperty().bind(plantListProperty);
|
||||||
|
|
||||||
description_plant.setText("");
|
description_plant.setText("");
|
||||||
saveToMyPlant_button.setDisable(true);
|
selectSowDay_button.setDisable(true);
|
||||||
|
|
||||||
createFilterSeasons();
|
createFilterSeasons();
|
||||||
createFilterHardinessZone();
|
createFilterHardinessZone();
|
||||||
|
@ -202,7 +201,7 @@ public class PlantsController implements Initializable {
|
||||||
private void createFilterSeasons() {
|
private void createFilterSeasons() {
|
||||||
ToggleGroup seasonGroup = new ToggleGroup();
|
ToggleGroup seasonGroup = new ToggleGroup();
|
||||||
for (Seasons season : Seasons.values()) {
|
for (Seasons season : Seasons.values()) {
|
||||||
RadioButton radioButton = new RadioButton(season.name());
|
RadioButton radioButton = new RadioButton(season.getName());
|
||||||
radioButton.setToggleGroup(seasonGroup);
|
radioButton.setToggleGroup(seasonGroup);
|
||||||
radioButton.setPadding(new Insets(0,0,10,0));
|
radioButton.setPadding(new Insets(0,0,10,0));
|
||||||
if (season.equals(Seasons.AllSEASONS)) {
|
if (season.equals(Seasons.AllSEASONS)) {
|
||||||
|
@ -239,7 +238,7 @@ public class PlantsController implements Initializable {
|
||||||
if(newValue != null) {
|
if(newValue != null) {
|
||||||
selectedPlant = newValue;
|
selectedPlant = newValue;
|
||||||
description_plant.setText(selectedPlant.description());
|
description_plant.setText(selectedPlant.description());
|
||||||
saveToMyPlant_button.setDisable(false);
|
selectSowDay_button.setDisable(false);
|
||||||
Image img;
|
Image img;
|
||||||
if(selectedPlant.image() != null) {
|
if(selectedPlant.image() != null) {
|
||||||
img = selectedPlant.image();
|
img = selectedPlant.image();
|
||||||
|
@ -252,7 +251,7 @@ public class PlantsController implements Initializable {
|
||||||
} else {
|
} else {
|
||||||
selectedPlant = null;
|
selectedPlant = null;
|
||||||
description_plant.setText("");
|
description_plant.setText("");
|
||||||
saveToMyPlant_button.setDisable(true);
|
selectSowDay_button.setDisable(true);
|
||||||
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
img_plant.setImage(img);
|
img_plant.setImage(img);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,20 @@ package ch.zhaw.gartenverwaltung.types;
|
||||||
import java.time.MonthDay;
|
import java.time.MonthDay;
|
||||||
|
|
||||||
public enum Seasons {
|
public enum Seasons {
|
||||||
AllSEASONS("--01-01", "--12-31"),
|
AllSEASONS("--01-01", "--12-31", "All Seasons"),
|
||||||
SPRING("--03-01", "--05-30"),
|
SPRING("--03-01", "--05-30", "Spring"),
|
||||||
SOMMER("--06-01", "--08-30"),
|
SUMMER("--06-01", "--08-30", "Summer"),
|
||||||
AUTUM("--09-01", "--11-30"),
|
AUTUMN("--09-01", "--11-30", "Autumn"),
|
||||||
WINTER("--12-01", "--02-28");
|
WINTER("--12-01", "--02-28", "Winter");
|
||||||
|
|
||||||
public final String startDate;
|
public final String startDate;
|
||||||
public final String endDate;
|
public final String endDate;
|
||||||
|
public final String name;
|
||||||
|
|
||||||
Seasons(String startDate, String endDate) {
|
Seasons(String startDate, String endDate, String name) {
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
this.endDate = endDate;
|
this.endDate = endDate;
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MonthDay getStartDate() {
|
public MonthDay getStartDate() {
|
||||||
|
@ -23,4 +25,7 @@ public enum Seasons {
|
||||||
public MonthDay getEndDate() {
|
public MonthDay getEndDate() {
|
||||||
return MonthDay.parse(this.endDate);
|
return MonthDay.parse(this.endDate);
|
||||||
}
|
}
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
<Insets bottom="10.0" top="10.0" />
|
<Insets bottom="10.0" top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</Label>
|
</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>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
|
|
Loading…
Reference in New Issue