From 784cbfdd76932ce225847459e3d1de25051595e4 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 13 May 2022 22:10:41 +0200 Subject: [PATCH] Added MainWindow and MainWindowController javadoc and logger --- .../projekt2/turnierverwaltung/Factory.java | 2 +- .../turnierverwaltung/main/MainWindow.java | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) 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 dbf6ae5..04fcef3 100644 --- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java +++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java @@ -19,7 +19,7 @@ public class Factory { private TournamentDecorator tournamentDecorator; private FileIO fileIO; - private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName()); + private static final Logger logger = Logger.getLogger(Factory.class.getCanonicalName()); public Factory(FileIO fileIO, TournamentDecorator tournamentDecorator) { this.fileIO = fileIO; 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 82d4c0a..28f5ed2 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 @@ -5,25 +5,34 @@ import ch.zhaw.projekt2.turnierverwaltung.FactoryDecorator; import ch.zhaw.projekt2.turnierverwaltung.FileIO; import ch.zhaw.projekt2.turnierverwaltung.TournamentDecorator; import javafx.application.Application; -import javafx.event.EventHandler; -import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; -import javafx.stage.WindowEvent; import java.util.logging.Logger; - +/** + * Class Main window is used to initialize the GUI Elements, Creating several Decorators and also getting the Factories + * ready + */ public class MainWindow extends Application { - private FileIO fileIO = new FileIO(System.getProperty("user.dir") + System.getProperty("file.separator") + "tournierverwaltung_angrynerds"); + private final FileIO fileIO = new FileIO(System.getProperty("user.dir") + + System.getProperty("file.separator") + "tournierverwaltung_angrynerds"); private FactoryDecorator factoryDecorator; - private TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO); - private Factory factory = new Factory(fileIO, tournamentDecorator); - private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName()); + private final TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO); + private final Factory factory = new Factory(fileIO, tournamentDecorator); + private static final Logger logger = Logger.getLogger(MainWindow.class.getCanonicalName()); + + /** + * Start method used to initialize the main window and load it's needed component + * Also sets the scene and set some values like min width and height + * + * @param primaryStage to be displayed + */ @Override - public void start(Stage primaryStage) throws Exception { + public void start(Stage primaryStage) { + logger.fine("Starting up the main window with the primary Stage"); BorderPane pane = factory.loadMainWindow(); factoryDecorator = new FactoryDecorator(fileIO, factory, pane); factory.loadAllViews(factoryDecorator, pane); @@ -40,6 +49,9 @@ public class MainWindow extends Application { primaryStage.show(); } + /** + * Method used to safely shut down the application + */ @Override public void stop() { try {