Tournament list #11

Merged
schrom01 merged 13 commits from TournamentList into main 2022-05-01 18:45:02 +02:00
2 changed files with 41 additions and 5 deletions
Showing only changes of commit 80005d214d - Show all commits

View File

@ -0,0 +1,34 @@
package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import java.io.IOException;
public class AlertDelete extends Alert {
ButtonType yesButton = new ButtonType("Ja", ButtonBar.ButtonData.YES);
ButtonType noButton = new ButtonType("Nein", ButtonBar.ButtonData.NO);
Boolean result;
public AlertDelete(String name){
super(Alert.AlertType.WARNING);
setTitle("Entfernen");
setHeaderText("Turnier entfernen?");
setContentText("Sind Sie sicher, dass sie das Turnier " + name + " entfernen wollen?\n" +
"Nach diesem Vorgang kann es nicht wiederhergestellt werden.");
getButtonTypes().setAll(yesButton, noButton);
}
public boolean showAndGetResult() {
result = false;
showAndWait().ifPresent(type -> {
if (type == yesButton) {
result = true;
}
});
return result;
}
}

View File

@ -87,14 +87,16 @@ public class TournamentListController extends FXController {
@FXML
void deleteTournament(ActionEvent event) {
//TODO Ask first to delete?
File tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0);
AlertDelete alert = new AlertDelete(tournamentFile.toString());
if(alert.showAndGetResult()){
try {
getFileIO().deleteTournament(tournamentFile);
} catch (IOException e) {
e.printStackTrace(); //TODO handle and logging
}
}
}
@Override
public void loadContent() {