diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/placesAddFormular/PlacesFormularController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/placesAddFormular/PlacesFormularController.java index b2a031a..d17a36b 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/placesAddFormular/PlacesFormularController.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/placesAddFormular/PlacesFormularController.java @@ -2,18 +2,20 @@ package ch.zhaw.projekt2.turnierverwaltung.main.placesAddFormular; import ch.zhaw.projekt2.turnierverwaltung.FXController; import ch.zhaw.projekt2.turnierverwaltung.Place; -import ch.zhaw.projekt2.turnierverwaltung.Player; import ch.zhaw.projekt2.turnierverwaltung.Tournament; -import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.TextField; -import javafx.scene.input.MouseEvent; import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; +import java.util.logging.Logger; + +/** + * Controller of the places form, in charge of its functionality. + */ public class PlacesFormularController extends FXController { @FXML @@ -50,37 +52,63 @@ public class PlacesFormularController extends FXController { @FXML private Button saveBtn; + private static final Logger logger = Logger.getLogger(PlacesFormularController.class.getCanonicalName()); + + /** + * Selects an item (place) from the List view + */ @FXML - void changedSelection(MouseEvent event){ + void changedSelection() { Place place = placeListView.getSelectionModel().getSelectedItems().get(0); + logger.finer("Selected new Place from list: " + place); placeNameTextField.setText(place.getName()); } + /** + * Saves the name of a new place into the list and clears the form + */ @FXML - void savePlace(ActionEvent event) { + void savePlace() { getTournamentDecorator().savePlace(placeNameTextField.getText()); - clearFormular(); + logger.fine("Saved " + placeNameTextField + " to the list of places"); + clearForm(); } - private void clearFormular() { + /** + * Method clears the input field + */ + private void clearForm() { + logger.finer("Clearing input text field"); placeNameTextField.clear(); } + /** + * Method deletes the currently selected place from the list. + */ @FXML - void delete(ActionEvent event) { + void delete() { Place place = placeListView.getSelectionModel().getSelectedItems().get(0); + logger.fine("Deleting " + place + "from place list"); getTournamentDecorator().deletePlace(place); } + /** + * Closes the current Place view, going back to previous view + */ @FXML - void close(ActionEvent event) { + void close() { + logger.fine("Closing place form"); getFactoryDecorator().openScheduleView(); } + /** + * Loads the already saved places and displays them on the places list. + */ @Override public void loadContent() { + logger.fine("Getting the Saved tournaments into the Places list"); Tournament tournament = getTournamentDecorator().getTournament(); - if(tournament != null){ + if (tournament != null) { placeListView.setItems(tournament.getPlaces()); } else { placeListView.getItems().clear();