diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameController.java index 0618db0..c8f5761 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameController.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameController.java @@ -1,7 +1,8 @@ package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView; import ch.zhaw.projekt2.turnierverwaltung.*; -import javafx.event.ActionEvent; +import javafx.beans.value.ObservableValue; +import javafx.event.Event; import javafx.fxml.FXML; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; @@ -32,8 +33,13 @@ public class GameController extends FXController{ private TextField pointsTeamTwo; @FXML - void saveGamerResult(ActionEvent event) { - gameDecorator.saveGame(pointsTeamOne.getText(), pointsTeamTwo.getText(), placesChoiceBox.getValue()); + void saveGameResult(Event event) { + gameDecorator.saveGameResult(pointsTeamOne.getText(), pointsTeamTwo.getText()); + } + + + private void saveGamePlace(Place newPlace) { + gameDecorator.saveGamePlace(newPlace); } public double getGameBoxHeigth(){ @@ -68,6 +74,7 @@ public class GameController extends FXController{ public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane, GameDecorator gameDecorator) { setTournamentDecorator(tournamentDecorator); this.gameDecorator = gameDecorator; + placesChoiceBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue observable, Place oldValue, Place newValue) -> saveGamePlace(newValue)); } } \ No newline at end of file diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java index 29d93f2..6a87104 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/gameScheduleView/GameDecorator.java @@ -24,9 +24,17 @@ public class GameDecorator implements IsObservable{ listener.remove(observer); } - public void saveGame(String points1, String points2, Place place){ - game.setPoints1(Integer.parseInt(points1)); - game.setPoints2(Integer.parseInt(points2)); + public void saveGameResult(String points1, String points2){ + if(points1.length() > 0){ + game.setPoints1(Integer.parseInt(points1)); + } + if(points2.length() > 0) { + game.setPoints2(Integer.parseInt(points2)); + } + informListener(); + } + + public void saveGamePlace(Place place){ game.setPlace(place); informListener(); } diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/gameScheduleView/GameSchedule.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/gameScheduleView/GameSchedule.fxml index 34f2257..c9bd568 100644 --- a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/gameScheduleView/GameSchedule.fxml +++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/gameScheduleView/GameSchedule.fxml @@ -20,10 +20,13 @@ -