Create alert popup if user wants to create new game schedule #49
|
@ -0,0 +1,26 @@
|
||||||
|
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||||
|
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.ButtonBar;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
|
||||||
|
public class AlertNewSchedule extends Alert {
|
||||||
|
private ButtonType yesButton = new ButtonType("Ja", ButtonBar.ButtonData.YES);
|
||||||
|
private ButtonType noButton = new ButtonType("Nein", ButtonBar.ButtonData.NO);
|
||||||
|
private boolean result;
|
||||||
|
|
||||||
|
public AlertNewSchedule() {
|
||||||
|
super(AlertType.WARNING);
|
||||||
|
setTitle("Neu erstellen");
|
||||||
|
setHeaderText("Spielplan neu erstellen?");
|
||||||
|
setContentText("Sind Sie sicher, dass Sie den Spielplan neu erstellen moechten?\nAlle Spielfortschritte gehen daraufhin verloren!");
|
||||||
|
getButtonTypes().setAll(yesButton,noButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean showAndGetResult() {
|
||||||
|
showAndWait().ifPresent(input -> {
|
||||||
|
result = input == yesButton;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||||
|
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
@ -30,7 +29,14 @@ public class GameScheduleController extends FXController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void createNewSchedule(ActionEvent event) {
|
void createNewSchedule(ActionEvent event) {
|
||||||
getTournamentDecorator().createNewGameSchedule();
|
if (getTournamentDecorator().getTournament().getGameList().size() > 0) {
|
||||||
|
AlertNewSchedule alert = new AlertNewSchedule();
|
||||||
|
if (alert.showAndGetResult()) {
|
||||||
|
getTournamentDecorator().createNewGameSchedule();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getTournamentDecorator().createNewGameSchedule();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|
Loading…
Reference in New Issue