Merge pull request #49 from PM2-IT21bWIN-ruiz-mach-krea/gameSchedule_Alert
Create alert popup if user wants to create new game schedule
This commit is contained in:
commit
3d522dd13c
|
@ -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,8 +29,15 @@ public class GameScheduleController extends FXController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void createNewSchedule(ActionEvent event) {
|
void createNewSchedule(ActionEvent event) {
|
||||||
|
if (getTournamentDecorator().getTournament().getGameList().size() > 0) {
|
||||||
|
AlertNewSchedule alert = new AlertNewSchedule();
|
||||||
|
if (alert.showAndGetResult()) {
|
||||||
getTournamentDecorator().createNewGameSchedule();
|
getTournamentDecorator().createNewGameSchedule();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
getTournamentDecorator().createNewGameSchedule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void openPlacesFormular(ActionEvent event) {
|
void openPlacesFormular(ActionEvent event) {
|
||||||
|
|
|
@ -21,9 +21,7 @@ public class AlertDelete extends Alert {
|
||||||
public boolean showAndGetResult() {
|
public boolean showAndGetResult() {
|
||||||
result = false;
|
result = false;
|
||||||
showAndWait().ifPresent(type -> {
|
showAndWait().ifPresent(type -> {
|
||||||
if (type == yesButton) {
|
result = type == yesButton;
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue