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
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ jlink {
'--copyright', 'Copyright (c) 2023 CodeDead',
'--description', 'Opal is a free and open-source JavaFX application that can play relaxing music in the background',
'--vendor', 'CodeDead',
'--license-file', 'LICENSE'
'--license-file', 'LICENSE',
'--app-version', "${project.version.toString()}"
]
}
} else if (currentOS.isLinux()) {
Expand All @@ -72,7 +73,8 @@ jlink {
'--copyright', 'Copyright (c) 2023 CodeDead',
'--description', 'Opal is a free and open-source JavaFX application that can play relaxing music in the background',
'--vendor', 'CodeDead',
'--license-file', 'LICENSE'
'--license-file', 'LICENSE',
'--app-version', "${project.version.toString()}"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ private void licenseAction() {
*/
@FXML
private void codeDeadAction() {
helpUtils.openCodeDeadWebSite(translationBundle);
helpUtils.openWebsite("https://codedead.com", translationBundle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public void run() {
*/
@FXML
private void homepageAction() {
helpUtils.openCodeDeadWebSite(translationBundle);
helpUtils.openWebsite("https://codedead.com", translationBundle);
}

/**
Expand All @@ -476,27 +476,7 @@ private void licenseAction() {
*/
@FXML
private void donateAction() {
logger.info("Opening the CodeDead donation website");

final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener("https://codedead.com/donate", 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 donation website", ex);
FxUtils.showErrorAlert(translationBundle.getString("WebsiteError"), ex.toString(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
}
});
}
});

new Thread(runnableSiteOpener).start();
helpUtils.openWebsite("https://codedead.com/donate", translationBundle);
}

/**
Expand Down Expand Up @@ -564,9 +544,12 @@ public void fired() {
final String result = builder.toString();
logger.info("Shutdown command result: {}", result);
}
exitAction();
} catch (final IOException ex) {
logger.error("Unable to execute shutdown command", ex);
}
} else {
logger.error("Unable to execute shutdown command, unsupported platform {}", platformName);
}
}

Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/codedead/opal/utils/HelpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,20 @@ public void run() {
}

/**
* Open the CodeDead website
* Open a website
*
* @param translationBundle The {@link ResourceBundle} object that contains translations
* @param url The URL of the website
* @param resourceBundle The {@link ResourceBundle} object that contains translations
*/
public void openCodeDeadWebSite(final ResourceBundle translationBundle) {
logger.info("Opening the CodeDead website");
public void openWebsite(final String url, final ResourceBundle resourceBundle) {
if (url == null)
throw new NullPointerException("URL cannot be null!");
if (url.isEmpty())
throw new IllegalArgumentException("URL cannot be empty!");

logger.info("Opening the website {}", url);

final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener("https://codedead.com", new IRunnableHelper() {
final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener(url, new IRunnableHelper() {
@Override
public void executed() {
Platform.runLater(() -> logger.info("Successfully opened website"));
Expand All @@ -133,8 +139,8 @@ 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.toString(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
logger.error("Error opening the website {}", url, ex);
FxUtils.showErrorAlert(resourceBundle.getString("WebsiteError"), ex.toString(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public RunnableSiteOpener(final String url, final IRunnableHelper iRunnableHelpe
@Override
public void run() {
try {
Desktop.getDesktop().browse(new URI(url));
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(new URI(url));
}
if (iRunnableHelper != null) {
iRunnableHelper.executed();
}
Expand Down