added functionality to autosave result and place if changed.
This commit is contained in:
parent
53ffa90c69
commit
b51a585167
|
@ -1,7 +1,8 @@
|
||||||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||||
|
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.*;
|
import ch.zhaw.projekt2.turnierverwaltung.*;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.event.Event;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
@ -32,8 +33,13 @@ public class GameController extends FXController{
|
||||||
private TextField pointsTeamTwo;
|
private TextField pointsTeamTwo;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void saveGamerResult(ActionEvent event) {
|
void saveGameResult(Event event) {
|
||||||
gameDecorator.saveGame(pointsTeamOne.getText(), pointsTeamTwo.getText(), placesChoiceBox.getValue());
|
gameDecorator.saveGameResult(pointsTeamOne.getText(), pointsTeamTwo.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void saveGamePlace(Place newPlace) {
|
||||||
|
gameDecorator.saveGamePlace(newPlace);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGameBoxHeigth(){
|
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) {
|
public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane, GameDecorator gameDecorator) {
|
||||||
setTournamentDecorator(tournamentDecorator);
|
setTournamentDecorator(tournamentDecorator);
|
||||||
this.gameDecorator = gameDecorator;
|
this.gameDecorator = gameDecorator;
|
||||||
|
placesChoiceBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends Place> observable, Place oldValue, Place newValue) -> saveGamePlace(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,9 +24,17 @@ public class GameDecorator implements IsObservable{
|
||||||
listener.remove(observer);
|
listener.remove(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveGame(String points1, String points2, Place place){
|
public void saveGameResult(String points1, String points2){
|
||||||
game.setPoints1(Integer.parseInt(points1));
|
if(points1.length() > 0){
|
||||||
game.setPoints2(Integer.parseInt(points2));
|
game.setPoints1(Integer.parseInt(points1));
|
||||||
|
}
|
||||||
|
if(points2.length() > 0) {
|
||||||
|
game.setPoints2(Integer.parseInt(points2));
|
||||||
|
}
|
||||||
|
informListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveGamePlace(Place place){
|
||||||
game.setPlace(place);
|
game.setPlace(place);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,13 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Button fx:id="editLocBtn" mnemonicParsing="false" onAction="#openPlacesFormular" text="Orte bearbeiten">
|
<Button fx:id="editLocBtn" mnemonicParsing="false" onAction="#openPlacesFormular" text="Orte bearbeiten">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="40.0" />
|
<Insets right="20.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Button fx:id="closeTournamentBtn" layoutX="470.0" layoutY="10.0" mnemonicParsing="false" onAction="#closeTournament" text="Close Tournament" />
|
<Button fx:id="closeTournamentBtn" layoutX="470.0" layoutY="10.0" mnemonicParsing="false" onAction="#closeTournament" text="Close Tournament">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="20.0" />
|
||||||
|
</HBox.margin></Button>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
</top>
|
</top>
|
||||||
|
|
Loading…
Reference in New Issue