Skip to content
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
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test build
name: Test

on:
pull_request:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
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;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.ResourceBundle;

public final class AboutWindowController {
Expand Down Expand Up @@ -55,58 +52,14 @@ 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);
}

/**
* Method that is called when the CodeDead button is selected
*/
@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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,58 +523,15 @@ 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);
}

/**
* Method that is called when the license should be opened
*/
@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);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/codedead/opal/domain/PlatformUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ public void setExtraAttributes(final Map<String, String> extraAttributes) {
*/
@Override
public int compareTo(final PlatformUpdate o) {
if (o == null)
return -1;

if (getMajorVersion() < o.getMajorVersion()) {
return 1;
} else if (getMajorVersion() > o.getMajorVersion()) {
Expand Down
65 changes: 65 additions & 0 deletions src/main/java/com/codedead/opal/utils/HelpUtils.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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 {

Expand Down Expand Up @@ -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();
}
}
3 changes: 2 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down