Open a website @param url The URL of the website @param resourceBundle The ResourceBundle object that contains translations
(final String url, final ResourceBundle resourceBundle)
| 121 | * @param resourceBundle The {@link ResourceBundle} object that contains translations |
| 122 | */ |
| 123 | public void openWebsite(final String url, final ResourceBundle resourceBundle) { |
| 124 | if (url == null) |
| 125 | throw new NullPointerException("URL cannot be null!"); |
| 126 | if (url.isBlank()) |
| 127 | throw new IllegalArgumentException("URL cannot be blank!"); |
| 128 | |
| 129 | logger.info("Opening the website {}", url); |
| 130 | |
| 131 | final RunnableSiteOpener runnableSiteOpener = new RunnableSiteOpener(url, new IRunnableHelper() { |
| 132 | @Override |
| 133 | public void executed() { |
| 134 | Platform.runLater(() -> logger.info("Successfully opened website")); |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public void exceptionOccurred(final Exception ex) { |
| 139 | Platform.runLater(new Runnable() { |
| 140 | @Override |
| 141 | public void run() { |
| 142 | logger.error("Error opening the website {}", url, ex); |
| 143 | FxUtils.showErrorAlert(resourceBundle.getString("WebsiteError"), ex.toString(), getClass().getResourceAsStream(SharedVariables.ICON_URL)); |
| 144 | } |
| 145 | }); |
| 146 | } |
| 147 | }); |
| 148 | |
| 149 | new Thread(runnableSiteOpener).start(); |
| 150 | } |
| 151 | } |
no test coverage detected