PlacesFormularController JavaDoc and Logger
This commit is contained in:
parent
f94572c1fe
commit
52b79ed501
|
@ -2,18 +2,20 @@ package ch.zhaw.projekt2.turnierverwaltung.main.placesAddFormular;
|
||||||
|
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.Place;
|
import ch.zhaw.projekt2.turnierverwaltung.Place;
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.Player;
|
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
|
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.input.MouseEvent;
|
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.VBox;
|
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 {
|
public class PlacesFormularController extends FXController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -50,35 +52,61 @@ public class PlacesFormularController extends FXController {
|
||||||
@FXML
|
@FXML
|
||||||
private Button saveBtn;
|
private Button saveBtn;
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(PlacesFormularController.class.getCanonicalName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects an item (place) from the List view
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void changedSelection(MouseEvent event){
|
void changedSelection() {
|
||||||
Place place = placeListView.getSelectionModel().getSelectedItems().get(0);
|
Place place = placeListView.getSelectionModel().getSelectedItems().get(0);
|
||||||
|
logger.finer("Selected new Place from list: " + place);
|
||||||
placeNameTextField.setText(place.getName());
|
placeNameTextField.setText(place.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the name of a new place into the list and clears the form
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void savePlace(ActionEvent event) {
|
void savePlace() {
|
||||||
getTournamentDecorator().savePlace(placeNameTextField.getText());
|
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();
|
placeNameTextField.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method deletes the currently selected place from the list.
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void delete(ActionEvent event) {
|
void delete() {
|
||||||
Place place = placeListView.getSelectionModel().getSelectedItems().get(0);
|
Place place = placeListView.getSelectionModel().getSelectedItems().get(0);
|
||||||
|
logger.fine("Deleting " + place + "from place list");
|
||||||
getTournamentDecorator().deletePlace(place);
|
getTournamentDecorator().deletePlace(place);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the current Place view, going back to previous view
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void close(ActionEvent event) {
|
void close() {
|
||||||
|
logger.fine("Closing place form");
|
||||||
getFactoryDecorator().openScheduleView();
|
getFactoryDecorator().openScheduleView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the already saved places and displays them on the places list.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadContent() {
|
public void loadContent() {
|
||||||
|
logger.fine("Getting the Saved tournaments into the Places list");
|
||||||
Tournament tournament = getTournamentDecorator().getTournament();
|
Tournament tournament = getTournamentDecorator().getTournament();
|
||||||
if (tournament != null) {
|
if (tournament != null) {
|
||||||
placeListView.setItems(tournament.getPlaces());
|
placeListView.setItems(tournament.getPlaces());
|
||||||
|
|
Loading…
Reference in New Issue