diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java index babea73..2e51f0d 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java @@ -1,14 +1,18 @@ package ch.zhaw.projekt2.turnierverwaltung; +import javafx.scene.layout.Pane; + public abstract class FXController { Tournament tournament; Factory factory; FileIO fileIO; + Pane pane; - public void setup(Tournament tournament, FileIO fileIO, Factory factory){ + public void setup(Tournament tournament, FileIO fileIO, Factory factory, Pane pane){ this.tournament = tournament; this.fileIO = fileIO; this.factory = factory; + this.pane = pane; } public abstract void loadContent(); @@ -24,4 +28,8 @@ public abstract class FXController { protected Factory getFactory() { return factory; } + + protected Pane getPane() { + return pane; + } } diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java index a272b0e..06ca006 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java @@ -50,7 +50,7 @@ public class Factory { FXMLLoader loader = new FXMLLoader(location); pane.setCenter(loader.load()); controller = loader.getController(); - controller.setup(tournament, fileIO, this); + controller.setup(tournament, fileIO, this, pane); controller.loadContent(); } catch (IOException e) { e.printStackTrace(); diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java index 6991216..08877c1 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java @@ -11,7 +11,7 @@ import javafx.scene.input.MouseEvent; import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; -public class participantFormularController extends FXController { +public class ParticipantFormularController extends FXController { @FXML private Button addBtn; @@ -76,4 +76,8 @@ public class participantFormularController extends FXController { } + @Override + public void loadContent() { + + } } 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 cb9a548..37c5c7b 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 @@ -1,7 +1,9 @@ package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList; import ch.zhaw.projekt2.turnierverwaltung.FXController; +import ch.zhaw.projekt2.turnierverwaltung.Factory; import ch.zhaw.projekt2.turnierverwaltung.FileIO; +import ch.zhaw.projekt2.turnierverwaltung.Tournament; import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow; import javafx.beans.Observable; import javafx.collections.FXCollections; @@ -12,9 +14,11 @@ import javafx.scene.control.Button; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; import javafx.scene.control.ListView; +import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import java.io.File; +import java.io.IOException; public class TournamentListController extends FXController { @@ -52,7 +56,15 @@ public class TournamentListController extends FXController { @FXML void openTournament(ActionEvent event) { - + try { + File tournamentFile = tournierListView.getSelectionModel().getSelectedItems().get(0); + getFactory().setTournament(getFileIO().loadTournament(tournamentFile)); + getFactory().loadParticipantFormular((BorderPane) getPane()); + } catch (IOException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } } @Override