created Abstract Class FXController.java

This commit is contained in:
schrom01 2022-04-29 17:30:26 +02:00
parent 9c7d62b260
commit 7af48449e0
5 changed files with 27 additions and 3 deletions

View File

@ -0,0 +1,19 @@
package ch.zhaw.projekt2.turnierverwaltung;
public abstract class FXController {
Tournament tournament;
Factory factory;
public void setup(Tournament tournament, Factory factory){
this.tournament = tournament;
this.factory = factory;
}
protected Tournament getTournament() {
return tournament;
}
protected Factory getFactory() {
return factory;
}
}

View File

@ -51,6 +51,8 @@ public class Factory {
try { try {
FXMLLoader loader = new FXMLLoader(location); FXMLLoader loader = new FXMLLoader(location);
pane.setCenter(loader.load()); pane.setCenter(loader.load());
FXController controller = loader.getController();
controller.setup(tournament, this);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
//TODO handle and logging? //TODO handle and logging?

View File

@ -1,9 +1,10 @@
package ch.zhaw.projekt2.turnierverwaltung.main; package ch.zhaw.projekt2.turnierverwaltung.main;
import ch.zhaw.projekt2.turnierverwaltung.FXController;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
public class MainWindowController { public class MainWindowController extends FXController {
@FXML @FXML
void changeLangToGerman(ActionEvent event) { void changeLangToGerman(ActionEvent event) {

View File

@ -1,5 +1,6 @@
package ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular; package ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular;
import ch.zhaw.projekt2.turnierverwaltung.FXController;
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;
@ -10,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 { public class participantFormularController extends FXController {
@FXML @FXML
private Button addBtn; private Button addBtn;

View File

@ -1,5 +1,6 @@
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.main.MainWindow; import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -9,7 +10,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
public class tournamentListController { public class tournamentListController extends FXController {
@FXML @FXML
private Button createBtn; private Button createBtn;