added pane to FXController.java

This commit is contained in:
schrom01 2022-04-30 18:03:11 +02:00
parent a103174739
commit 6245e32f73
4 changed files with 28 additions and 4 deletions

View File

@ -1,14 +1,18 @@
package ch.zhaw.projekt2.turnierverwaltung; package ch.zhaw.projekt2.turnierverwaltung;
import javafx.scene.layout.Pane;
public abstract class FXController { public abstract class FXController {
Tournament tournament; Tournament tournament;
Factory factory; Factory factory;
FileIO fileIO; 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.tournament = tournament;
this.fileIO = fileIO; this.fileIO = fileIO;
this.factory = factory; this.factory = factory;
this.pane = pane;
} }
public abstract void loadContent(); public abstract void loadContent();
@ -24,4 +28,8 @@ public abstract class FXController {
protected Factory getFactory() { protected Factory getFactory() {
return factory; return factory;
} }
protected Pane getPane() {
return pane;
}
} }

View File

@ -50,7 +50,7 @@ public class Factory {
FXMLLoader loader = new FXMLLoader(location); FXMLLoader loader = new FXMLLoader(location);
pane.setCenter(loader.load()); pane.setCenter(loader.load());
controller = loader.getController(); controller = loader.getController();
controller.setup(tournament, fileIO, this); controller.setup(tournament, fileIO, this, pane);
controller.loadContent(); controller.loadContent();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -11,7 +11,7 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
public class participantFormularController extends FXController { public class ParticipantFormularController extends FXController {
@FXML @FXML
private Button addBtn; private Button addBtn;
@ -76,4 +76,8 @@ public class participantFormularController extends FXController {
} }
@Override
public void loadContent() {
}
} }

View File

@ -1,7 +1,9 @@
package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList; package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList;
import ch.zhaw.projekt2.turnierverwaltung.FXController; import ch.zhaw.projekt2.turnierverwaltung.FXController;
import ch.zhaw.projekt2.turnierverwaltung.Factory;
import ch.zhaw.projekt2.turnierverwaltung.FileIO; import ch.zhaw.projekt2.turnierverwaltung.FileIO;
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow; import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow;
import javafx.beans.Observable; import javafx.beans.Observable;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
@ -12,9 +14,11 @@ import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox; import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import java.io.File; import java.io.File;
import java.io.IOException;
public class TournamentListController extends FXController { public class TournamentListController extends FXController {
@ -52,7 +56,15 @@ public class TournamentListController extends FXController {
@FXML @FXML
void openTournament(ActionEvent event) { 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 @Override