From 9c7d62b26091f3e8b969520b7f240cf865b9f606 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 29 Apr 2022 17:11:50 +0200 Subject: [PATCH] created Class Factory and refactoring of MainWindow.java --- .../projekt2/turnierverwaltung/Factory.java | 63 ++++++++++ .../turnierverwaltung/main/MainWindow.java | 26 +--- .../participantFormularController.java | 2 +- .../tournamentListController.java | 3 +- .../turnierverwaltung}/MainWindow.fxml | 0 .../projekt2/turnierverwaltung}/Style.css | 0 .../turnierverwaltung/main/MainWindow.fxml | 37 ------ .../projekt2/turnierverwaltung/main/Style.css | 10 -- .../participandFormular.fxml | 114 ------------------ .../participantFormular.fxml} | 2 +- .../tournamentList/tournamentList.fxml | 2 +- 11 files changed, 74 insertions(+), 185 deletions(-) create mode 100644 app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java rename app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/{participandAddFormular => participantAddFormular}/participantFormularController.java (95%) rename app/{build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main => src/main/resources/ch/zhaw/projekt2/turnierverwaltung}/MainWindow.fxml (100%) rename app/{build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main => src/main/resources/ch/zhaw/projekt2/turnierverwaltung}/Style.css (100%) delete mode 100644 app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.fxml delete mode 100644 app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/Style.css delete mode 100644 app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml rename app/{build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml => src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml} (98%) rename app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/{main => }/tournamentList/tournamentList.fxml (99%) diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java new file mode 100644 index 0000000..2b671d1 --- /dev/null +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java @@ -0,0 +1,63 @@ +package ch.zhaw.projekt2.turnierverwaltung; + +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; + +import java.io.IOException; +import java.net.URL; + +public class Factory { + private Tournament tournament; + + + public Factory(){ + + } + + public Tournament getTournament() { + return tournament; + } + + public void setTournament(Tournament tournament) { + this.tournament = tournament; + } + + public BorderPane loadMainWindow(){ + FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml")); + try { + return loader.load(); + } catch (IOException e) { + e.printStackTrace(); + //TODO handle and logging + } + return null; + } + + public void loadTournamentList(BorderPane pane){ + setCenterOfBorderPane(pane, getClass().getResource("tournamentList/tournamentList.fxml")); + } + + //Can be used to Open new Scene in same Stage. + //This way possible to later give object to Controller + public void loadParticipantFormular(BorderPane pane) { + setCenterOfBorderPane(pane, getClass().getResource("participantAddFormular/participantFormular.fxml")); + } + + private void setCenterOfBorderPane(BorderPane pane, URL location) { + try { + FXMLLoader loader = new FXMLLoader(location); + pane.setCenter(loader.load()); + } catch (IOException e) { + e.printStackTrace(); + //TODO handle and logging? + } + } + + + + +} diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java index c124308..c0f80f4 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java @@ -1,5 +1,6 @@ package ch.zhaw.projekt2.turnierverwaltung.main; +import ch.zhaw.projekt2.turnierverwaltung.Factory; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; @@ -11,36 +12,21 @@ import java.awt.*; import java.io.IOException; public class MainWindow extends Application { + private Factory factory = new Factory(); //TODO make it private! @Override public void start(Stage primaryStage) throws Exception { - FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml")); - BorderPane pane = loader.load(); + BorderPane pane = factory.loadMainWindow(); + factory.loadTournamentList(pane); - //test add center pane - loader = new FXMLLoader(getClass().getResource("tournamentList/tournamentList.fxml")); - pane.setCenter(loader.load()); Scene scene = new Scene(pane); primaryStage.setScene(scene); primaryStage.setMaximized(true); primaryStage.setResizable(false); + primaryStage.setFullScreen(false); primaryStage.show(); } - //Can be used to Open new Scene in same Stage. - //This way possible to later give object to Controller - public void startParticipand(Stage stage) { - FXMLLoader loader = new FXMLLoader(getClass().getResource("participandAddFormular/participandFormular.fxml")); - try { - Pane pane = loader.load(); - Scene scene = new Scene(pane); - stage.setScene(scene); - stage.setFullScreen(true); - stage.setResizable(false); - stage.show(); - } catch (IOException e) { - e.printStackTrace(); - } - } + } diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participantFormularController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java similarity index 95% rename from app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participantFormularController.java rename to app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java index adc2c20..8056644 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participantFormularController.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java @@ -1,4 +1,4 @@ -package ch.zhaw.projekt2.turnierverwaltung.main.participandAddFormular; +package ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular; import javafx.event.ActionEvent; import javafx.fxml.FXML; 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 916b5d6..cb8799f 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,5 +1,6 @@ package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList; +import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; @@ -43,7 +44,7 @@ public class tournamentListController { } @FXML - void openTournier(ActionEvent event) { + void openTournament(ActionEvent event) { } diff --git a/app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/MainWindow.fxml similarity index 100% rename from app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.fxml rename to app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/MainWindow.fxml diff --git a/app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/Style.css b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/Style.css similarity index 100% rename from app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/Style.css rename to app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/Style.css diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.fxml deleted file mode 100644 index af04e72..0000000 --- a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.fxml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/Style.css b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/Style.css deleted file mode 100644 index d69b698..0000000 --- a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/Style.css +++ /dev/null @@ -1,10 +0,0 @@ -#mainContainer { - -fx-min-height: 100%; - -fx-min-width: 100%; - -fx-background-color: #f8f8f8; - -} - -/* -Formular Right Side - */ diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml deleted file mode 100644 index df5040e..0000000 --- a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml similarity index 98% rename from app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml rename to app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml index df5040e..0441e61 100644 --- a/app/build/resources/main/ch/zhaw/projekt2/turnierverwaltung/main/participandAddFormular/participandFormular.fxml +++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml @@ -17,7 +17,7 @@ - + diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/tournamentList.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/tournamentList/tournamentList.fxml similarity index 99% rename from app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/tournamentList.fxml rename to app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/tournamentList/tournamentList.fxml index 9a52479..5f5aac6 100644 --- a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/tournamentList.fxml +++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/tournamentList/tournamentList.fxml @@ -31,7 +31,7 @@ -