Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #72

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.version>21</javafx.version> <!-- Version 16 is used to resolve conflicts with monacoFX -->
<junit.version>5.8.2</junit.version>
<javafx.version>22.0.1</javafx.version> <!-- Version 16 is used to resolve conflicts with monacoFX -->
<junit.version>5.10.2</junit.version>
<derby.version>10.17.1.0</derby.version>
<lombok.version>1.18.30</lombok.version>
<hibernate.version>6.4.2.Final</hibernate.version>
<lombok.version>1.18.32</lombok.version>
<hibernate.version>6.5.2.Final</hibernate.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand Down Expand Up @@ -55,10 +55,11 @@
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>9.0.10</version>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.2.1</version>
</dependency>

<dependency>
<groupId>eu.mihosoft.monacofx</groupId>
<artifactId>monacofx</artifactId>
Expand Down Expand Up @@ -93,14 +94,14 @@
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.2</version>
<artifactId>jaxb-core</artifactId>
<version>4.0.5</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.22.1</version>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -111,13 +112,13 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.3.1</version>
<version>5.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.3.1</version>
<version>5.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
182 changes: 89 additions & 93 deletions src/main/java/com/JayPi4c/RobbiSimulator/App.java
Original file line number Diff line number Diff line change
@@ -1,117 +1,113 @@
package com.JayPi4c.RobbiSimulator;

import static com.JayPi4c.RobbiSimulator.utils.I18nUtils.i18n;

import java.util.ResourceBundle;

import com.JayPi4c.RobbiSimulator.controller.program.ProgramController;
import com.JayPi4c.RobbiSimulator.controller.tutor.TutorController;
import com.JayPi4c.RobbiSimulator.utils.AlertHelper;
import com.JayPi4c.RobbiSimulator.utils.HibernateUtils;
import com.JayPi4c.RobbiSimulator.utils.I18nUtils;
import com.JayPi4c.RobbiSimulator.utils.PropertiesLoader;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;

import javax.swing.*;
import java.util.ResourceBundle;

import static com.JayPi4c.RobbiSimulator.utils.I18nUtils.i18n;

/**
*
* Hauptklasse des Robbi Simulators.<br>
* Javaversion: 17 <br>
*
* @author Jonas Pohl
* Application entry point.<br>
* Java version: 21
*
* @author Jonas Pohl
*/
@Slf4j
public class App extends Application {

private static final String INIT_ERROR_MESSAGE = "Init.error.message";
private static final String INIT_ERROR_TITLE = "Init.error.title";
private static final String INIT_ERROR_HEADER = "Init.error.header";

/**
* Application entry point
*
* @param args the arguments from the command line
*/
public static void main(String[] args) {
try {
launch(args);
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, """
Failed to load application.
Further information can be obtained running the
application in the command line.
Please consider submitting your error.
""");
}
}

@Override
public void init() {
logger.info("Initialize application");

logger.debug("Initializing properties...");
if (PropertiesLoader.initialize()) {
logger.debug("Loaded properties successfully");
} else
logger.debug("Failed to load properties.");

I18nUtils.setBundle(ResourceBundle.getBundle("lang.messages", PropertiesLoader.getLocale()));

logger.debug("Loading Program Controller");
if (!ProgramController.initialize()) {
logger.error("Failed to load Program Controller");
AlertHelper.showAlertAndWait(AlertType.ERROR, i18n(INIT_ERROR_MESSAGE), null, null, i18n(INIT_ERROR_TITLE),
i18n(INIT_ERROR_HEADER));
Platform.exit();
}
logger.debug("loading Program Controller successfully");

if (PropertiesLoader.isTutor()) {
logger.debug("Starting Tutor RMI server");
if (TutorController.initialize())
logger.debug("RMI server started");
else
logger.debug("Failed to initialize RMI server.");
}
}

@Override
public void start(Stage primaryStage) {
logger.info("Starting application");
logger.debug("Creating scene");
ProgramController.createAndShow(ProgramController.DEFAULT_ROBBI_FILE_NAME);
logger.debug("Scene creation done");
}

@Override
public void stop() {

logger.debug("Shutting down database connection");
HibernateUtils.shutdown();

if (PropertiesLoader.isTutor()) {
logger.debug("Stopping Tutor-Server.");
if (TutorController.shutdown())
logger.debug("Tutor RMI server stopped successfully.");
else
logger.debug("Failed to shutdown Tutor RMI server");
}

logger.debug("saving properties...");
if (PropertiesLoader.finish())
logger.debug("Properties saved");
else
logger.debug("Failed to save properties");

logger.info("Quitting application");
}
private static final String INIT_ERROR_MESSAGE = "Init.error.message";
private static final String INIT_ERROR_TITLE = "Init.error.title";
private static final String INIT_ERROR_HEADER = "Init.error.header";

/**
* Application entry point
*
* @param args the arguments from the command line
*/
public static void main(String[] args) {
try {
launch(args);
} catch (Exception e) {
logger.error("Failed to load application", e);
JOptionPane.showMessageDialog(null, """
Failed to load application.
Further information can be obtained running the
application in the command line.
Please consider submitting your error.
""");
}
}

@Override
public void init() {
logger.info("Initialize application");

logger.debug("Initializing properties...");
if (PropertiesLoader.initialize()) {
logger.debug("Loaded properties successfully");
} else
logger.debug("Failed to load properties.");

I18nUtils.setBundle(ResourceBundle.getBundle("lang.messages", PropertiesLoader.getLocale()));

logger.debug("Loading Program Controller");
if (!ProgramController.initialize()) {
logger.error("Failed to load Program Controller");
AlertHelper.showAlertAndWait(AlertType.ERROR, i18n(INIT_ERROR_MESSAGE), null, null, i18n(INIT_ERROR_TITLE),
i18n(INIT_ERROR_HEADER));
Platform.exit();
}
logger.debug("loading Program Controller successfully");

if (PropertiesLoader.isTutor()) {
logger.debug("Starting Tutor RMI server");
if (TutorController.initialize())
logger.debug("RMI server started");
else
logger.debug("Failed to initialize RMI server.");
}
}

@Override
public void start(Stage primaryStage) {
logger.info("Starting application");
logger.debug("Creating scene");
ProgramController.createAndShow(ProgramController.DEFAULT_ROBBI_FILE_NAME);
logger.debug("Scene creation done");
}

@Override
public void stop() {

logger.debug("Shutting down database connection");
HibernateUtils.shutdown();

if (PropertiesLoader.isTutor()) {
logger.debug("Stopping Tutor-Server.");
if (TutorController.shutdown())
logger.debug("Tutor RMI server stopped successfully.");
else
logger.debug("Failed to shutdown Tutor RMI server");
}

logger.debug("saving properties...");
if (PropertiesLoader.finish())
logger.debug("Properties saved");
else
logger.debug("Failed to save properties");

logger.info("Quitting application");
}

}
Loading