PlacesFormularController JavaDoc and Logger

This commit is contained in:
Leonardo Brandenberger 2022-05-13 22:42:51 +02:00
parent f94572c1fe
commit 52b79ed501
1 changed files with 38 additions and 10 deletions

View File

@ -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();