diff --git a/src/main/java/ch/zhaw/gartenverwaltung/CropDetailController.java b/src/main/java/ch/zhaw/gartenverwaltung/CropDetailController.java index 85fb66d..997ac93 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/CropDetailController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/CropDetailController.java @@ -81,22 +81,37 @@ public class CropDetailController { } + /** + * close Window + */ @FXML void goBack() { Stage stage = (Stage) imageView.getScene().getWindow(); stage.close(); } + /** + * open dialog to set area + */ @FXML void setArea() { } + /** + * open dialog to set location + */ @FXML void setLocation() { } + /** + * set labels and image from selected {@link Crop} + * set icons for buttons + * @param crop {@link Crop} which will be displayed + * @throws PlantNotFoundException exception + */ public void setPlantFromCrop(Crop crop) throws PlantNotFoundException { this.crop = crop; try { diff --git a/src/main/java/ch/zhaw/gartenverwaltung/HomeController.java b/src/main/java/ch/zhaw/gartenverwaltung/HomeController.java index 7df4661..5c9014c 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/HomeController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/HomeController.java @@ -1,5 +1,47 @@ package ch.zhaw.gartenverwaltung; -public class HomeController -{ +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; + +import java.net.URL; +import java.util.ResourceBundle; + +public class HomeController implements Initializable { + + @FXML + private ImageView imageViewDavid; + + @FXML + private ImageView imageViewElias; + + @FXML + private ImageView imageViewGian; + + @FXML + private ImageView imageViewPhilippe; + + @FXML + private ImageView imageViewRoman; + + @Override + public void initialize(URL location, ResourceBundle resources) { + setImages(imageViewDavid, ""); + setImages(imageViewElias, ""); + setImages(imageViewGian, ""); + setImages(imageViewRoman, ""); + setImages(imageViewPhilippe, ""); + } + + private void setImages(ImageView imageView, String photoName) { + Image img; + if (photoName.equals("")) { + img = new Image(String.valueOf(getClass().getResource("icons/userIcon.png"))); + } else { + img = new Image(String.valueOf(getClass().getResource("icons/" + photoName))); + } + imageView.setImage(img); + } } + diff --git a/src/main/java/ch/zhaw/gartenverwaltung/MainFXMLController.java b/src/main/java/ch/zhaw/gartenverwaltung/MainFXMLController.java index 6970451..2cc05d3 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/MainFXMLController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/MainFXMLController.java @@ -4,7 +4,6 @@ import ch.zhaw.gartenverwaltung.bootstrap.AfterInject; import ch.zhaw.gartenverwaltung.bootstrap.AppLoader; import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent; import ch.zhaw.gartenverwaltung.bootstrap.Inject; -import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.*; @@ -41,26 +40,39 @@ public class MainFXMLController { @FXML private Button tutorial_button; + /** + * go to home pane + */ @FXML void goToHome() { showPaneAsMainView("Home.fxml"); styleChangeButton(home_button); } + /** + * go to my garden pane + */ @FXML void goToMyPlants() { showPaneAsMainView("MyGarden.fxml"); styleChangeButton(myGarden_button); } + /** + * go to the schedule pane + */ @FXML void goToMySchedule() { showPaneAsMainView("MySchedule.fxml"); styleChangeButton(mySchedule_button); } + /** + * open dialog of the settings + * @throws IOException exception + */ @FXML - public void openSettings(ActionEvent actionEvent) throws IOException { + public void openSettings() throws IOException { Dialog dialog = new Dialog<>(); dialog.setTitle("Settings"); dialog.setHeaderText("Settings"); @@ -82,8 +94,11 @@ public class MainFXMLController { } } - public void goToTutorial(ActionEvent actionEvent) { - //showPaneAsMainView("Tutorial.fxml"); + /** + * go to Tutorial pane + */ + public void goToTutorial() { + showPaneAsMainView("Tutorial.fxml"); styleChangeButton(tutorial_button); } @@ -109,10 +124,15 @@ public class MainFXMLController { private final EventHandler changeMainViewHandler = (ChangeViewEvent event) -> showPaneAsMainView(event.view()); + /** + * preload all menu bar panes + * @throws IOException exception + */ private void preloadPanes() throws IOException { appLoader.loadAndCacheFxml("MyGarden.fxml"); appLoader.loadAndCacheFxml("MySchedule.fxml"); appLoader.loadAndCacheFxml("Plants.fxml"); + appLoader.loadAndCacheFxml("Tutorial.fxml"); } private void styleChangeButton(Button button) { @@ -142,7 +162,7 @@ public class MainFXMLController { } /** - * adds icon to button + * adds icon to given button * @param button the button which get the icon * @param iconFileName file name of icon */ diff --git a/src/main/java/ch/zhaw/gartenverwaltung/MyGardenController.java b/src/main/java/ch/zhaw/gartenverwaltung/MyGardenController.java index 3de534f..d7efaf4 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/MyGardenController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/MyGardenController.java @@ -47,6 +47,11 @@ public class MyGardenController { @FXML private Button addPlant_button; + /** + * initialize crop list + * add listener for crop list + * set icon for button + */ @AfterInject @SuppressWarnings("unused") public void init() { @@ -65,6 +70,9 @@ public class MyGardenController { setIconToButton(addPlant_button, "addIcon.png"); } + /** + * redirect to plant fxml file + */ @FXML void addPlant() { myGardenRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "Plants.fxml")); @@ -119,6 +127,11 @@ public class MyGardenController { button.setGraphic(imageView); } + /** + * open detail window of the selected {@link Crop} + * @param crop {@link Crop} which is selected + * @return {@link EventHandler} for button + */ private EventHandler getGoToCropDetailEvent(Crop crop) { return (event) -> { try { @@ -136,6 +149,11 @@ public class MyGardenController { }; } + /** + * open alert for deleting the selected {@link Crop} + * @param crop {@link Crop} which is selected + * @return {@link EventHandler} for button + */ private EventHandler getDeleteCropEvent(Crop crop) { return (event) -> { try { @@ -146,9 +164,16 @@ public class MyGardenController { }; } + /** + * Alert to confirm that the crop can be deleted. + * @param crop {@link Crop} which is selected + * @throws IOException exception + * @throws HardinessZoneNotSetException exception + */ private void showConfirmation(Crop crop) throws IOException, HardinessZoneNotSetException { + Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get(); Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("Delete Crop"); + alert.setTitle("Delete" + plant.name()); alert.setHeaderText("Are you sure want to delete this Crop?"); alert.setContentText("Deleting this crop will remove all associated tasks from your schedule."); diff --git a/src/main/java/ch/zhaw/gartenverwaltung/SelectSowDayController.java b/src/main/java/ch/zhaw/gartenverwaltung/SelectSowDayController.java index e3722fc..c6ff944 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/SelectSowDayController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/SelectSowDayController.java @@ -21,6 +21,11 @@ public class SelectSowDayController { @FXML public ToggleGroup phase_group; + /** + * if sow date radio button was selected return sow date + * if sow date was not selected get sow from harvest day and return sow date + * @return {@link LocalDate} of the sow date + */ public LocalDate retrieveResult() { LocalDate sowDate = datepicker.getValue(); if (harvest_radio.isSelected()) { @@ -53,6 +58,10 @@ public class SelectSowDayController { harvest_radio.setUserData(GrowthPhaseType.HARVEST); } + /** + * Disable save button when date picker is empty + * @param saveButton {@link Button} to be disabled + */ public void initSaveButton(Button saveButton) { saveButton.disableProperty().bind(datepicker.valueProperty().isNull()); } diff --git a/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java b/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java new file mode 100644 index 0000000..aa02930 --- /dev/null +++ b/src/main/java/ch/zhaw/gartenverwaltung/TutorialController.java @@ -0,0 +1,6 @@ +package ch.zhaw.gartenverwaltung; + + +public class TutorialController { + +} diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/Home.fxml b/src/main/resources/ch/zhaw/gartenverwaltung/Home.fxml index c159ce4..35065d8 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/Home.fxml +++ b/src/main/resources/ch/zhaw/gartenverwaltung/Home.fxml @@ -2,42 +2,210 @@ + + + - - + - - - - - - - - - - + + + + + + diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/Tutorial.fxml b/src/main/resources/ch/zhaw/gartenverwaltung/Tutorial.fxml new file mode 100644 index 0000000..f86ce0b --- /dev/null +++ b/src/main/resources/ch/zhaw/gartenverwaltung/Tutorial.fxml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/icons/userIcon.png b/src/main/resources/ch/zhaw/gartenverwaltung/icons/userIcon.png new file mode 100644 index 0000000..f1feb14 Binary files /dev/null and b/src/main/resources/ch/zhaw/gartenverwaltung/icons/userIcon.png differ