Added MainWindow and MainWindowController javadoc and logger

This commit is contained in:
Leonardo Brandenberger 2022-05-13 22:10:41 +02:00
parent c7d9fd0908
commit 784cbfdd76
2 changed files with 22 additions and 10 deletions

View File

@ -19,7 +19,7 @@ public class Factory {
private TournamentDecorator tournamentDecorator; private TournamentDecorator tournamentDecorator;
private FileIO fileIO; 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) { public Factory(FileIO fileIO, TournamentDecorator tournamentDecorator) {
this.fileIO = fileIO; this.fileIO = fileIO;

View File

@ -5,25 +5,34 @@ import ch.zhaw.projekt2.turnierverwaltung.FactoryDecorator;
import ch.zhaw.projekt2.turnierverwaltung.FileIO; import ch.zhaw.projekt2.turnierverwaltung.FileIO;
import ch.zhaw.projekt2.turnierverwaltung.TournamentDecorator; import ch.zhaw.projekt2.turnierverwaltung.TournamentDecorator;
import javafx.application.Application; import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import java.util.logging.Logger; 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 { 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 FactoryDecorator factoryDecorator;
private TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO); private final TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO);
private Factory factory = new Factory(fileIO, tournamentDecorator); private final Factory factory = new Factory(fileIO, tournamentDecorator);
private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName());
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 @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(); BorderPane pane = factory.loadMainWindow();
factoryDecorator = new FactoryDecorator(fileIO, factory, pane); factoryDecorator = new FactoryDecorator(fileIO, factory, pane);
factory.loadAllViews(factoryDecorator, pane); factory.loadAllViews(factoryDecorator, pane);
@ -40,6 +49,9 @@ public class MainWindow extends Application {
primaryStage.show(); primaryStage.show();
} }
/**
* Method used to safely shut down the application
*/
@Override @Override
public void stop() { public void stop() {
try { try {