diff --git a/src/main/java/mediathek/gui/actions/ShowOnlineHelpAction.java b/src/main/java/mediathek/gui/actions/ShowOnlineHelpAction.java index 0d9e3e4e06..3d66c952a3 100644 --- a/src/main/java/mediathek/gui/actions/ShowOnlineHelpAction.java +++ b/src/main/java/mediathek/gui/actions/ShowOnlineHelpAction.java @@ -25,7 +25,7 @@ public ShowOnlineHelpAction() { private void openUrl() { try { - UrlHyperlinkAction.openURL(null, Konstanten.ADRESSE_ONLINE_HELP); + UrlHyperlinkAction.openURL(Konstanten.ADRESSE_ONLINE_HELP); } catch (URISyntaxException ex) { logger.warn(ex); } diff --git a/src/main/java/mediathek/gui/actions/UrlHyperlinkAction.java b/src/main/java/mediathek/gui/actions/UrlHyperlinkAction.java index 1a2cce0ca8..61596c8cfc 100644 --- a/src/main/java/mediathek/gui/actions/UrlHyperlinkAction.java +++ b/src/main/java/mediathek/gui/actions/UrlHyperlinkAction.java @@ -3,6 +3,7 @@ import mediathek.config.MVConfig; import mediathek.gui.dialog.DialogProgrammOrdnerOeffnen; import mediathek.gui.messages.ProgramLocationChangedEvent; +import mediathek.mainwindow.MediathekGui; import mediathek.tool.MessageBus; import org.apache.commons.lang3.SystemUtils; import org.apache.logging.log4j.LogManager; @@ -18,20 +19,17 @@ public class UrlHyperlinkAction extends AbstractAction { - private final JFrame jFrameParent; - - public UrlHyperlinkAction(JFrame jjFrameParent, String url) { - jFrameParent = jjFrameParent; + public UrlHyperlinkAction(String url) { super.putValue(Action.NAME, url); super.putValue(SHORT_DESCRIPTION, url); } - private static void configureAndStartCustomWebBrowser(JFrame paFrame, String url) { + private static void configureAndStartCustomWebBrowser(String url) { try { String programm = ""; if (MVConfig.get(MVConfig.Configs.SYSTEM_URL_OEFFNEN).isEmpty()) { String text = "\n Der Browser zum Anzeigen der URL wird nicht gefunden.\n Browser selbst auswählen."; - DialogProgrammOrdnerOeffnen dialog = new DialogProgrammOrdnerOeffnen(paFrame, true, "", "Browser suchen", text); + DialogProgrammOrdnerOeffnen dialog = new DialogProgrammOrdnerOeffnen(MediathekGui.ui(), true, "", "Browser suchen", text); dialog.setVisible(true); if (dialog.ok) { programm = dialog.ziel; @@ -66,17 +64,16 @@ private static void launchMacDefaultBrowser(String url) throws IOException { private static final Logger logger = LogManager.getLogger(UrlHyperlinkAction.class); - public static void openURI(@NotNull JFrame parent, @NotNull URI uri) throws URISyntaxException { - openURL(parent, uri.toString()); + public static void openURI(@NotNull URI uri) throws URISyntaxException { + openURL(uri.toString()); } /** * Try to open a browser window. * - * @param paFrame the parent window. * @param url URL to be opened. Here in string format. * @throws URISyntaxException when URL is malformed. */ - public static void openURL(JFrame paFrame, String url) throws URISyntaxException { + public static void openURL(String url) throws URISyntaxException { boolean launchFailed = false; if (SystemUtils.IS_OS_MAC_OSX) { @@ -110,18 +107,18 @@ public static void openURL(JFrame paFrame, String url) throws URISyntaxException } else { logger.trace("trying to launch custom web browser"); //Desktop not supported, we need to work custom - configureAndStartCustomWebBrowser(paFrame, url); + configureAndStartCustomWebBrowser(url); } } if (launchFailed) - configureAndStartCustomWebBrowser(paFrame,url); + configureAndStartCustomWebBrowser(url); } @Override public void actionPerformed(ActionEvent e) { try { - openURL(jFrameParent, e.getActionCommand()); + openURL(e.getActionCommand()); } catch (URISyntaxException ignored) { } } diff --git a/src/main/java/mediathek/gui/dialog/AboutDialog.java b/src/main/java/mediathek/gui/dialog/AboutDialog.java index 80099e088a..520fd822e3 100644 --- a/src/main/java/mediathek/gui/dialog/AboutDialog.java +++ b/src/main/java/mediathek/gui/dialog/AboutDialog.java @@ -5,6 +5,7 @@ package mediathek.gui.dialog; import mediathek.config.Konstanten; +import mediathek.gui.actions.UrlHyperlinkAction; import net.miginfocom.layout.AC; import net.miginfocom.layout.CC; import net.miginfocom.layout.LC; @@ -15,7 +16,7 @@ import javax.swing.*; import java.awt.*; -import java.net.URI; +import java.net.URISyntaxException; /** * @author Christian Franzke @@ -48,20 +49,9 @@ private void showError() { } private void browseToUrl(@NotNull String url) { - if (Desktop.isDesktopSupported()) { - var desktop = Desktop.getDesktop(); - if (desktop.isSupported(Desktop.Action.BROWSE)) { - try { - desktop.browse(new URI(url)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - else { - showError(); - } - } - else { + try { + UrlHyperlinkAction.openURL(url); + } catch (URISyntaxException e) { showError(); } } diff --git a/src/main/java/mediathek/gui/filmInformation/FilmInfoDialog.java b/src/main/java/mediathek/gui/filmInformation/FilmInfoDialog.java index 722c53ad92..6d80e16ac7 100644 --- a/src/main/java/mediathek/gui/filmInformation/FilmInfoDialog.java +++ b/src/main/java/mediathek/gui/filmInformation/FilmInfoDialog.java @@ -146,7 +146,7 @@ private void saveLocation() { private void openUrl(String url) { try { - UrlHyperlinkAction.openURL(null, url); + UrlHyperlinkAction.openURL(url); } catch (URISyntaxException ex) { logger.warn(ex); } diff --git a/src/main/java/mediathek/gui/tabs/tab_film/FilmDescriptionPanel.java b/src/main/java/mediathek/gui/tabs/tab_film/FilmDescriptionPanel.java index a3fde03d8a..571e4e4e72 100644 --- a/src/main/java/mediathek/gui/tabs/tab_film/FilmDescriptionPanel.java +++ b/src/main/java/mediathek/gui/tabs/tab_film/FilmDescriptionPanel.java @@ -177,7 +177,7 @@ private void setAllFieldsEmpty() { private void openUrl(String url) { try { - UrlHyperlinkAction.openURL(null, url); + UrlHyperlinkAction.openURL(url); } catch (URISyntaxException ex) { logger.warn(ex); } diff --git a/src/main/java/mediathek/gui/tabs/tab_film/GuiFilme.java b/src/main/java/mediathek/gui/tabs/tab_film/GuiFilme.java index a28219e3c0..d6f5164387 100644 --- a/src/main/java/mediathek/gui/tabs/tab_film/GuiFilme.java +++ b/src/main/java/mediathek/gui/tabs/tab_film/GuiFilme.java @@ -1555,7 +1555,7 @@ private void setupSearchEntries(@NotNull JPopupMenu popupMenu, @NotNull DatenFil miThema.addActionListener(l -> { var url = item.getQueryUrl() + URLEncoder.encode(film.getThema(), StandardCharsets.UTF_8); try { - UrlHyperlinkAction.openURL(MediathekGui.ui(), url); + UrlHyperlinkAction.openURL(url); } catch (URISyntaxException ex) { logger.error("Failed to launch online search for url {}", url); } @@ -1566,7 +1566,7 @@ private void setupSearchEntries(@NotNull JPopupMenu popupMenu, @NotNull DatenFil miTitel.addActionListener(l -> { var url = item.getQueryUrl() + URLEncoder.encode(film.getTitle(), StandardCharsets.UTF_8); try { - UrlHyperlinkAction.openURL(MediathekGui.ui(), url); + UrlHyperlinkAction.openURL(url); } catch (URISyntaxException ex) { logger.error("Failed to launch online search for url {}", url); } diff --git a/src/main/java/mediathek/javafx/bookmark/BookmarkWindowController.java b/src/main/java/mediathek/javafx/bookmark/BookmarkWindowController.java index f1866dfd4e..7a1905fb4e 100644 --- a/src/main/java/mediathek/javafx/bookmark/BookmarkWindowController.java +++ b/src/main/java/mediathek/javafx/bookmark/BookmarkWindowController.java @@ -238,7 +238,7 @@ private void hyperLinkSelected(Event e) { String url = tbBookmarks.getSelectionModel().getSelectedItem().getWebUrl(); try { if (url != null) { - UrlHyperlinkAction.openURL(null,url); + UrlHyperlinkAction.openURL(url); } } catch (URISyntaxException ex) { diff --git a/src/main/java/mediathek/update/DialogHinweisUpdate.java b/src/main/java/mediathek/update/DialogHinweisUpdate.java index 64c1b1b502..6b5e9c50d7 100644 --- a/src/main/java/mediathek/update/DialogHinweisUpdate.java +++ b/src/main/java/mediathek/update/DialogHinweisUpdate.java @@ -50,7 +50,7 @@ public DialogHinweisUpdate(JFrame parent, String ttext) { hyperLink.addActionListener(l -> { try { - UrlHyperlinkAction.openURL(parent, Konstanten.ADRESSE_DOWNLOAD); + UrlHyperlinkAction.openURL(Konstanten.ADRESSE_DOWNLOAD); } catch (URISyntaxException ex) { logger.error(ex); } diff --git a/src/main/java/mediathek/update/UpdateNotificationDialog.kt b/src/main/java/mediathek/update/UpdateNotificationDialog.kt index 47a019a96e..0cf4b70502 100644 --- a/src/main/java/mediathek/update/UpdateNotificationDialog.kt +++ b/src/main/java/mediathek/update/UpdateNotificationDialog.kt @@ -5,7 +5,6 @@ import mediathek.gui.actions.DisposeDialogAction import mediathek.gui.actions.UrlHyperlinkAction import mediathek.gui.dialog.ButtonFlowPanel import mediathek.gui.dialog.ButtonPanel -import mediathek.mainwindow.MediathekGui import mediathek.tool.EscapeKeyHandler import mediathek.tool.GuiFunktionen import mediathek.tool.Version @@ -26,7 +25,7 @@ class UpdateNotificationDialog(owner: Frame?, title: String?, private val versio val dlBtn = JButton("Zur Download-Seite") dlBtn.addActionListener { try { - UrlHyperlinkAction.openURI(MediathekGui.ui(), URI(Konstanten.ADRESSE_DOWNLOAD)) + UrlHyperlinkAction.openURI(URI(Konstanten.ADRESSE_DOWNLOAD)) dispose() } catch (e: URISyntaxException) { logger.error(e) diff --git a/src/main/kotlin/mediathek/mainwindow/AustrianVlcCheck.kt b/src/main/kotlin/mediathek/mainwindow/AustrianVlcCheck.kt index b15ca0ab31..b774981eae 100644 --- a/src/main/kotlin/mediathek/mainwindow/AustrianVlcCheck.kt +++ b/src/main/kotlin/mediathek/mainwindow/AustrianVlcCheck.kt @@ -30,7 +30,7 @@ class AustrianVlcCheck(val owner: JFrame) { if (e.eventType == HyperlinkEvent.EventType.ACTIVATED) { try { ApplicationConfiguration.getConfiguration().setProperty(ApplicationConfiguration.APPLICATION_SHOW_ORF_CONFIG_HELP, false) - UrlHyperlinkAction.openURL(MediathekGui.ui(), Konstanten.ORF_TUTORIAL_LINK) + UrlHyperlinkAction.openURL(Konstanten.ORF_TUTORIAL_LINK) } catch (ex: Exception) { logger.error("Failed to display ORF tutorial", ex) }