diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b8a4f2..4899fa7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Test build +name: Test on: pull_request: @@ -26,9 +26,14 @@ jobs: - name: Set up JDK 20 uses: actions/setup-java@v3 with: - java-version: 20 + java-version: '20' distribution: 'temurin' + - name: Test + uses: gradle/gradle-build-action@v2 + with: + arguments: test + - name: Build uses: gradle/gradle-build-action@v2 with: diff --git a/src/main/java/com/codedead/opal/controller/AboutWindowController.java b/src/main/java/com/codedead/opal/controller/AboutWindowController.java index 515e675..8dd6083 100644 --- a/src/main/java/com/codedead/opal/controller/AboutWindowController.java +++ b/src/main/java/com/codedead/opal/controller/AboutWindowController.java @@ -1,8 +1,6 @@ package com.codedead.opal.controller; -import com.codedead.opal.interfaces.IRunnableHelper; import com.codedead.opal.utils.*; -import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; @@ -10,7 +8,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.io.IOException; import java.util.ResourceBundle; public final class AboutWindowController { @@ -55,31 +52,7 @@ private void closeAction(final ActionEvent event) { */ @FXML private void licenseAction() { - logger.info("Attempting to open the license file"); - - try { - helpUtils.openFileFromResources(new RunnableFileOpener(SharedVariables.LICENSE_FILE_LOCATION, new IRunnableHelper() { - @Override - public void executed() { - Platform.runLater(() -> logger.info("Successfully opened the license file")); - } - - @Override - public void exceptionOccurred(final Exception ex) { - Platform.runLater(new Runnable() { - @Override - public void run() { - logger.error("Error opening the license file", ex); - FxUtils.showErrorAlert(translationBundle.getString("LicenseFileError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); - } - }); - - } - }), SharedVariables.LICENSE_RESOURCE_LOCATION); - } catch (final IOException ex) { - logger.error("Error opening the license file", ex); - FxUtils.showErrorAlert(translationBundle.getString("LicenseFileError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); - } + helpUtils.openLicenseFile(translationBundle); } /** @@ -87,26 +60,6 @@ public void run() { */ @FXML private void codeDeadAction() { - logger.info("Opening the CodeDead website"); - - final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener("https://codedead.com", new IRunnableHelper() { - @Override - public void executed() { - Platform.runLater(() -> logger.info("Successfully opened website")); - } - - @Override - public void exceptionOccurred(final Exception ex) { - Platform.runLater(new Runnable() { - @Override - public void run() { - logger.error("Error opening the CodeDead website", ex); - FxUtils.showErrorAlert(translationBundle.getString("WebsiteError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); - } - }); - } - }); - - new Thread(runnableSiteOpener).start(); + helpUtils.openCodeDeadWebSite(translationBundle); } } diff --git a/src/main/java/com/codedead/opal/controller/MainWindowController.java b/src/main/java/com/codedead/opal/controller/MainWindowController.java index e362653..6bfb6ae 100644 --- a/src/main/java/com/codedead/opal/controller/MainWindowController.java +++ b/src/main/java/com/codedead/opal/controller/MainWindowController.java @@ -523,27 +523,7 @@ public void run() { */ @FXML private void homepageAction() { - logger.info("Opening the CodeDead website"); - - final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener("https://codedead.com", new IRunnableHelper() { - @Override - public void executed() { - Platform.runLater(() -> logger.info("Successfully opened website")); - } - - @Override - public void exceptionOccurred(final Exception ex) { - Platform.runLater(new Runnable() { - @Override - public void run() { - logger.error("Error opening the CodeDead website", ex); - FxUtils.showErrorAlert(translationBundle.getString("WebsiteError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); - } - }); - } - }); - - new Thread(runnableSiteOpener).start(); + helpUtils.openCodeDeadWebSite(translationBundle); } /** @@ -551,30 +531,7 @@ public void run() { */ @FXML private void licenseAction() { - logger.info("Attempting to open the license file"); - - try { - helpUtils.openFileFromResources(new RunnableFileOpener(SharedVariables.LICENSE_FILE_LOCATION, new IRunnableHelper() { - @Override - public void executed() { - Platform.runLater(() -> logger.info("Successfully opened the license file")); - } - - @Override - public void exceptionOccurred(final Exception ex) { - Platform.runLater(new Runnable() { - @Override - public void run() { - logger.error("Error opening the license file", ex); - FxUtils.showErrorAlert(translationBundle.getString("LicenseFileError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); - } - }); - } - }), SharedVariables.LICENSE_RESOURCE_LOCATION); - } catch (final IOException ex) { - logger.error("Error opening the license file", ex); - FxUtils.showErrorAlert(translationBundle.getString("LicenseFileError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); - } + helpUtils.openLicenseFile(translationBundle); } /** diff --git a/src/main/java/com/codedead/opal/domain/PlatformUpdate.java b/src/main/java/com/codedead/opal/domain/PlatformUpdate.java index 7e19cd8..dfea765 100644 --- a/src/main/java/com/codedead/opal/domain/PlatformUpdate.java +++ b/src/main/java/com/codedead/opal/domain/PlatformUpdate.java @@ -173,6 +173,9 @@ public void setExtraAttributes(final Map extraAttributes) { */ @Override public int compareTo(final PlatformUpdate o) { + if (o == null) + return -1; + if (getMajorVersion() < o.getMajorVersion()) { return 1; } else if (getMajorVersion() > o.getMajorVersion()) { diff --git a/src/main/java/com/codedead/opal/utils/HelpUtils.java b/src/main/java/com/codedead/opal/utils/HelpUtils.java index fccc38c..879032e 100644 --- a/src/main/java/com/codedead/opal/utils/HelpUtils.java +++ b/src/main/java/com/codedead/opal/utils/HelpUtils.java @@ -1,5 +1,7 @@ package com.codedead.opal.utils; +import com.codedead.opal.interfaces.IRunnableHelper; +import javafx.application.Platform; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,6 +12,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ResourceBundle; public final class HelpUtils { @@ -77,4 +80,66 @@ public void openFileFromResources(final RunnableFileOpener runnableFileOpener, f new Thread(runnableFileOpener).start(); } + + /** + * Open the license file + * + * @param translationBundle The {@link ResourceBundle} object that contains translations + */ + public void openLicenseFile(final ResourceBundle translationBundle) { + logger.info("Attempting to open the license file"); + + try { + openFileFromResources(new RunnableFileOpener(SharedVariables.LICENSE_FILE_LOCATION, new IRunnableHelper() { + @Override + public void executed() { + Platform.runLater(() -> logger.info("Successfully opened the license file")); + } + + @Override + public void exceptionOccurred(final Exception ex) { + Platform.runLater(new Runnable() { + @Override + public void run() { + logger.error("Error opening the license file", ex); + FxUtils.showErrorAlert(translationBundle.getString("LicenseFileError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); + } + }); + + } + }), SharedVariables.LICENSE_RESOURCE_LOCATION); + } catch (final IOException ex) { + logger.error("Error opening the license file", ex); + FxUtils.showErrorAlert(translationBundle.getString("LicenseFileError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); + } + } + + /** + * Open the CodeDead website + * + * @param translationBundle The {@link ResourceBundle} object that contains translations + */ + public void openCodeDeadWebSite(final ResourceBundle translationBundle) { + logger.info("Opening the CodeDead website"); + + final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener("https://codedead.com", new IRunnableHelper() { + @Override + public void executed() { + Platform.runLater(() -> logger.info("Successfully opened website")); + } + + @Override + public void exceptionOccurred(final Exception ex) { + Platform.runLater(new Runnable() { + @Override + public void run() { + logger.error("Error opening the CodeDead website", ex); + FxUtils.showErrorAlert(translationBundle.getString("WebsiteError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); + } + }); + } + }); + + new Thread(runnableSiteOpener).start(); + } } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index ad06c02..9abdc1c 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -4,7 +4,8 @@ requires javafx.fxml; requires java.desktop; requires javafx.media; - requires jdk.crypto.ec; + //noinspection Java9RedundantRequiresStatement + requires jdk.crypto.ec; // Added for SSL handshakes requires org.apache.logging.log4j; requires org.apache.logging.log4j.core; requires com.fasterxml.jackson.core;