From 678060ecc07ed12a19508ee8ab8e1f7895206d23 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sun, 1 May 2022 13:46:20 +0200 Subject: [PATCH] extracted Method delete Tournament in TournamentDecorator.java --- .../projekt2/turnierverwaltung/TournamentDecorator.java | 9 +++++++++ .../main/tournamentList/TournamentListController.java | 9 ++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java index 0177d05..a848a4a 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/TournamentDecorator.java @@ -50,6 +50,15 @@ public class TournamentDecorator implements IsObservable{ } } + public void deleteTournament(FileIO.TournamentFile tournamentFile){ + try { + fileIO.deleteTournament(tournamentFile); + informListener(); + } catch (IOException e) { + e.printStackTrace(); //TODO handle and logging + } + } + public void informListener() { for(IsObserver observer : listener) { diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/TournamentListController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/TournamentListController.java index fcb26c0..bcc1109 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/TournamentListController.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/TournamentListController.java @@ -67,15 +67,10 @@ public class TournamentListController extends FXController { @FXML void deleteTournament(ActionEvent event) { - File tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0); + FileIO.TournamentFile tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0); AlertDelete alert = new AlertDelete(tournamentFile.toString()); if(alert.showAndGetResult()){ - try { - getFileIO().deleteTournament(tournamentFile); - loadContent(); - } catch (IOException e) { - e.printStackTrace(); //TODO handle and logging - } + getTournamentDecorator().deleteTournament(tournamentFile); } }