/** * Update the browser links * * @param event on hyperlink event */ @Override public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (event.getDescription().startsWith("http://") || event.getDescription().startsWith("https://") || event.getDescription().startsWith("ftp://")) { WebBrowser.openUrl(event.getURL(), event.getDescription()); } else if (event.getDescription().startsWith(SCILAB_PROTO)) { if (helpSets == null) { initHelpSets(x.getModel().getHelpSet()); } URL url = resolvScilabLink(event); if (url != null) { super.hyperlinkUpdate( new HyperlinkEvent(event.getSource(), event.getEventType(), url, "")); } } else if (event.getDescription().startsWith(FILE_PROTO)) { String url = event.getDescription(); url = url.replaceFirst("SCI", Matcher.quoteReplacement(SCI)); WebBrowser.openUrl(url); } else { super.hyperlinkUpdate(event); } } }
/** * @param he hiperlik Event. * @see * javax.help.plaf.basic.BasicContentViewerUI#hyperlinkUpdate(javax.swing.event.HyperlinkEvent) */ @Override public void hyperlinkUpdate(final HyperlinkEvent he) { if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL u = he.getURL(); if ("mailto".equalsIgnoreCase(u.getProtocol()) || "http".equalsIgnoreCase(u.getProtocol()) || "ftp".equalsIgnoreCase(u.getProtocol())) { Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.BROWSE)) { try { desktop.browse(u.toURI()); } catch (MalformedURLException e1) { DialogUtils.showGeneralErrorDialog( new Frame(), "MalformedURLException", "Invalid URL."); } catch (IOException e1) { DialogUtils.showGeneralErrorDialog(new Frame(), "IOException", "Resource not found."); } catch (URISyntaxException uriSyntaxEx) { DialogUtils.showGeneralErrorDialog(new Frame(), "URISyntaxException", "Invalid URI."); } } } } else { super.hyperlinkUpdate(he); } } }
/** * Create the UI interface * * @see javax.help.plaf.basic.BasicContentViewerUI#installUI(javax.swing.JComponent) * @param c The component */ @Override public void installUI(JComponent c) { super.installUI(c); this.retrievePrivateFieldFromBasicContentViewerUI(); this.createPopupMenu(c); }