@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (java.awt.Desktop.isDesktopSupported()) { try { java.awt.Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { log.error("Error opening URL in browser:" + e.getURL()); } } } }
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { HyperlinkEvent.EventType type = hyperlinkEvent.getEventType(); final URL url = hyperlinkEvent.getURL(); // if (type == HyperlinkEvent.EventType.ENTERED) { // Utility.debugPrintln("patterns","Entered " + url.toString()); // } else if (type == HyperlinkEvent.EventType.EXITED) { // Utility.debugPrintln("patterns","Exited"); // } if (type == HyperlinkEvent.EventType.ACTIVATED) { // Utility.debugPrintln("Activated"); Runnable runner = new Runnable() { public void run() { // Retain reference to original Document doc = editorPane.getDocument(); try { editorPane.setPage(url); } catch (IOException ioException) { JOptionPane.showMessageDialog( frame, "Error following link " + url.toString(), "GIPO Error", JOptionPane.ERROR_MESSAGE); editorPane.setDocument(doc); } } }; SwingUtilities.invokeLater(runner); } }
/** * 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); } } }
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return; Tab tabee = tabAccess.get(tab.getSelectedIndex()); addressBar.setText(e.getURL().toString()); MyEditorPane pane = new MyEditorPane(addressBar.getText()); pane.addHyperlinkListener(HYHandler); JScrollPane scPane = new JScrollPane(pane); tabee.addPane(pane); pane.setEditable(false); int i = tab.getSelectedIndex(); tabcreate = false; change = false; tab.remove(i); change = false; tabcreate = false; tab.insertTab(tabee.getPane().getAddress(), null, scPane, null, i); addCloseButton(i, tabee.getPane().getAddress()); change = false; tabcreate = false; tab.setSelectedIndex(i); change = false; tabcreate = false; loadPage(pane, tabee.getPane().getAddress()); tabcreate = true; }
/** * @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); } } }
/** @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent) */ public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (event.getURL().toString().startsWith("http")) { return; } if (event.getURL().toString().endsWith("sdx")) { String file = event.getURL().toString(); file = file.substring(file.lastIndexOf('/') + 1); fireHyperlinkClicked("example:" + file); } else if (event.getURL().toString().indexOf('#') > 0) { try { JEditorPane pane = (JEditorPane) event.getSource(); pane.setPage(event.getURL()); } catch (Exception e) { /* empty */ } } else if (event.getURL().toString().endsWith("html")) { String file = event.getURL().toString(); file = file.substring(file.lastIndexOf('/') + 1); fireHyperlinkClicked("help:" + file); } } }
/* * Obsluha kliknuti na odkaz * * @param event Udalost odkazu */ public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { htmlPane.setPage(event.getURL()); } catch (IOException ioe) { System.err.println("Page doesn't exist!"); } } }
private void _htmlPaneUserFeed_hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { try { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { WebBrowser.openURL(hyperlinkEvent.getURL().toString()); } } catch (Exception exception) { Debug.displayStack(this, exception); } }
/* * (non-Javadoc) * * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent) */ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { OpenBrowser openBrowser = ServiceController.getInstance() .getAdapter() .getCyServiceRegistrar() .getService(OpenBrowser.class); openBrowser.openURL(e.getURL().toString()); } }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = e.getURL(); // String protocol = e.getURL().getProtocol(); int index = url.getPort(); gotoIndex(index + 1); if (!timeWarpMode) { activateTimeWarp(); } } }
/** Changes the cursor on hyperlink actions */ public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { // Load some cursors Cursor cursor = output.getCursor(); Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); output.setCursor(waitCursor); // Handle the hyperlink change SwingUtilities.invokeLater(new LinkLoader(output, event.getURL(), cursor)); } }
public void hyperlinkUpdate(HyperlinkEvent e) { HyperlinkEvent.EventType type = e.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { String[] path = e.getURL().getPath().split("/"); if (FreeColObject.ID_ATTRIBUTE_TAG.equals(path[1])) { select(path[2]); } else if ("action".equals(path[1])) { getFreeColClient().getActionManager().getFreeColAction(path[2]).actionPerformed(null); } } }
public void hyperlinkUpdate(HyperlinkEvent event) { HTMLDocument documentHTML = null; if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { m_sPageCourante = event.getURL().toString(); if (event instanceof HTMLFrameHyperlinkEvent) { documentHTML = (HTMLDocument) jEditorPaneHTML.getDocument(); documentHTML.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) event); } else ChargerPageActive(); } }
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return; if (e.getURL() == null || e.getURL().toString().startsWith(url + "#")) { // Probably hyperlink event on a an A-element with a href consisting of // a fragment only, i.e. "#ALocalFragment". // String fragment = getUrlFragment(e); if (fragment != null) { // first try to scroll to an element with id==fragment. This is the way // table of contents are built in the JOSM wiki. If this fails, try to // scroll to a <A name="..."> element. // if (!scrollToElementWithId(fragment)) { help.scrollToReference(fragment); } } else { HelpAwareOptionPane.showOptionDialog( Main.parent, tr("Failed to open help page. The target URL is empty."), tr("Failed to open help page"), JOptionPane.ERROR_MESSAGE, null, /* no icon */ null, /* standard options, just OK button */ null, /* default is standard */ null /* no help context */); } } else if (e.getURL().toString().endsWith("action=edit")) { OpenBrowser.displayUrl(e.getURL().toString()); } else { url = e.getURL().toString(); openUrl(e.getURL().toString()); } }
/** * User has clicked on a HyperLink. * * @param evt HyperLink Event Object. */ public void hyperlinkUpdate(HyperlinkEvent evt) { URL url = evt.getURL(); if (url != null) { if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { // CytoscapeWrapper.setStatusBarMsg(url.toString()); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { // CytoscapeWrapper.clearStatusBar(); } else if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { browser.openURL(url.toString()); } } }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane pane = (JEditorPane) e.getSource(); if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) pane.getDocument(); doc.processHTMLFrameHyperlinkEvent(evt); } else { String url = e.getURL().toString(); Loader loader = LoaderFactory.getInstance().newLoader(); loader.download(url, new Target(Library.PRIMARY_FRAME, null)); } } }
/** Notification of a change relative to a hyperlink. From: java.swing.event.HyperlinkListener */ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL target = e.getURL(); // System.out.println("linkto: " + target); // Get the help panel's cursor and the wait cursor Cursor oldCursor = help.getCursor(); Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); help.setCursor(waitCursor); // Now arrange for the page to get loaded asynchronously, // and the cursor to be set back to what it was. SwingUtilities.invokeLater(new PageLoader(target, oldCursor)); } }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) this.getDocument(); doc.processHTMLFrameHyperlinkEvent(evt); } else { try { URL url = e.getURL(); if (url != null) this.setPage(url); } catch (Throwable t) { t.printStackTrace(); } } } }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { openUrl(e.getURL()); } catch (UnsupportedOperationException ex) { Logger.log.error("Unable to open URL", ex); JOptionPane.showMessageDialog( mainPanel, "No browser launcher specified", "Unable to open link", JOptionPane.ERROR_MESSAGE); } } else { // TODO: show URL in status bar when mousing over } }
// {{{ hyperlinkUpdate() method public void hyperlinkUpdate(HyperlinkEvent evt) { if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (evt instanceof HTMLFrameHyperlinkEvent) { ((HTMLDocument) viewer.getDocument()) .processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); historyUpdated(); } else { URL url = evt.getURL(); if (url != null) { gotoURL(url.toString(), true, 0); } } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { viewer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { viewer.setCursor(Cursor.getDefaultCursor()); } } // }}}
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e instanceof FormSubmitEvent) { FormSubmitEvent event = (FormSubmitEvent) e; // Just pushed the download the file button... LOG.debugf("File offer download requested. FileId: {0}", event.getData()); try { String dataStr = event.getData(); String fileIdEncoded = dataStr.substring(dataStr.indexOf("=") + 1).trim(); String fileId = URLDecoder.decode(fileIdEncoded, "UTF-8"); downloadFileOffer(fileId); } catch (UnsupportedEncodingException uee) { throw new RuntimeException(uee); // impossible } } else if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) { handleLinkClick(e.getDescription(), e.getURL()); } }
/** {@inheritDoc} */ public void urlClicked(HyperlinkEvent e, Completion c, DescWindowCallback callback) { // A "real" URL (starts with http://, for example) should be opened // in the system browser, not the completion description window. URL url = e.getURL(); if (url != null) { // Try loading in external browser (Java 6+ only). try { Util.browse(new URI(url.toString())); } catch (/*IO*/ URISyntaxException ioe) { UIManager.getLookAndFeel().provideErrorFeedback(null); ioe.printStackTrace(); } return; } // A relative path URL (no leading "http://") results in a null URL. // Class should be in the same package as the one we're currently // viewing. Example: java.lang.String class documentation String desc = e.getDescription(); Logger.log(desc); if (desc != null) { if (isRelativeUrl(desc)) { int ext = desc.indexOf(".htm"); if (ext > -1) { // Could be <a href="Character.html#section"> link. A // popular href format is "../../util/Formatter.html#syntax". // We must determine "relative" package location. String anchor = getAnchor(desc); String clazz = desc.substring(0, ext); int backups = 0; while (clazz.startsWith("../")) { backups++; clazz = clazz.substring(3); } clazz = clazz.replace('/', '.'); String pkg = getPackage(c, desc); if (pkg != null) { clazz = doBackups(pkg, backups) + "." + clazz; JavaScriptLanguageSupport jls = getJavaScriptLanguageSupport(); ClassFile cf = jls.getJarManager().getClassEntry(clazz); if (cf != null) { JSClassCompletion cc = new JSClassCompletion(c.getProvider(), cf); callback.showSummaryFor(cc, anchor); } } } } // Could be format "com.mycompany.pkg.MyClass", with optional // #method() (for example, @see's). else { JavaScriptLanguageSupport jls = getJavaScriptLanguageSupport(); String clazz = desc; String member = null; int pound = desc.indexOf('#'); if (pound > -1) { // TODO: Handle properly member = clazz.substring(pound + 1); clazz = clazz.substring(0, pound); } // Just a class name, i.e. "String", "java.util.regex.Pattern". if (member == null) { boolean guessedPackage = false; if (clazz.indexOf('.') == -1) { String pkg = getPackage(c, desc); if (pkg != null) { clazz = pkg + "." + clazz; } guessedPackage = true; } ClassFile cf = jls.getJarManager().getClassEntry(clazz); if (cf == null && guessedPackage) { // Wasn't in the same package as "c", try java.lang int lastDot = clazz.lastIndexOf('.'); clazz = "java.lang." + clazz.substring(lastDot + 1); cf = jls.getJarManager().getClassEntry(clazz); } if (cf != null) { JSClassCompletion cc = new JSClassCompletion(c.getProvider(), cf); callback.showSummaryFor(cc, null); } else { UIManager.getLookAndFeel().provideErrorFeedback(null); Logger.log("Unknown class: " + clazz); } } // Member specified, such as "String#format(...)", // "java.util.regex.Pattern.compile(...)", or "#method()". else { boolean guessedPackage = false; if (pound == 0) { // Member of this class (i.e. "#foobar(bas)") // "clazz" was incorrect previously in this case clazz = getClass(c, desc); } else { // i.e. "String#CASE_INSENSITIVE_ORDER" // If no package specified, assume clazz is in the same // package as the currently displayed completion. if (clazz.indexOf('.') == -1) { String pkg = getPackage(c, desc); if (pkg != null) { clazz = pkg + "." + clazz; } guessedPackage = true; } } ClassFile cf = clazz != null ? jls.getJarManager().getClassEntry(clazz) : null; if (cf == null && guessedPackage) { // Wasn't in the same package as "c", try java.lang int lastDot = clazz.lastIndexOf('.'); clazz = "java.lang." + clazz.substring(lastDot + 1); cf = jls.getJarManager().getClassEntry(clazz); } if (cf != null) { Completion memberCompletion = null; int lparen = member.indexOf('('); if (lparen == -1) { // A field, or method with args omitted FieldInfo fi = cf.getFieldInfoByName(member); if (fi != null) { // Try fields first, it's most likely memberCompletion = new JSFieldCompletion(c.getProvider(), fi); } else { // Try methods second List miList = cf.getMethodInfoByName(member, -1); if (miList != null && miList.size() > 0) { MethodInfo mi = (MethodInfo) miList.get(0); // Just show the first if multiple memberCompletion = new JSFunctionCompletion(c.getProvider(), mi); } } } else { String[] args = getArgs(member); String methodName = member.substring(0, lparen); List miList = cf.getMethodInfoByName(methodName, args.length); if (miList != null && miList.size() > 0) { if (miList.size() > 1) { // TODO: Pick correct overload based on args Logger.log("Multiple overload support not yet implemented"); } else { MethodInfo mi = (MethodInfo) miList.get(0); memberCompletion = new JSFunctionCompletion(c.getProvider(), mi); } } } if (memberCompletion != null) { callback.showSummaryFor(memberCompletion, null); } } else { UIManager.getLookAndFeel().provideErrorFeedback(null); Logger.logError("Unknown class: " + clazz + " (href: " + desc + ")"); } } } } }
/** * Method to handle hyper link events. * * @param event hyper link event */ public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { setCursor(cbusy); try { URL url = event.getURL(); int ind1 = event.getDescription().indexOf("["); int ind2 = event.getDescription().lastIndexOf("]"); String search = ""; if (ind1 > -1 && ind2 > -1) search = event.getDescription().substring(ind1 + 1, ind2); else { ind1 = event.getDescription().indexOf("=") + 1; // genedb if (ind1 > -1) search = event.getDescription().substring(ind1); } if (desktop != null) { if (BigPane.srsTabPane.isSelected()) setUpSRSFrame(url, search); if (BigPane.srsWin.isSelected()) { int hgt = (2 * desktop.getHeight()) / 3; Annotation edPane = new Annotation(url); JScrollPane jsp = new JScrollPane(edPane); JInternalFrame jif = new JInternalFrame( "SRS " + search, true, // resizable true, // closable true, // maximizable true); // iconifiable); JMenuBar menuBar = new JMenuBar(); menuBar.add(new CommonMenu(jif)); jif.setJMenuBar(menuBar); jif.getContentPane().add(jsp); jif.setLocation(0, 0); jif.setSize(800, hgt); jif.setVisible(true); desktop.add(jif); } if (BigPane.srsBrowser.isSelected()) BrowserControl.displayURL(event.getDescription()); } else { setPage(url); back.add(url); } } catch (IOException ioe) { String msg = event.getDescription(); if (msg.length() > 50) msg = msg.substring(0, 50) + "...."; JOptionPane.showMessageDialog( this, "Cannot reach URL:\n" + msg, "Cannot Connect", JOptionPane.INFORMATION_MESSAGE); // ioe.printStackTrace(); // ("Can't follow link to " + // event.getURL().toExternalForm() ); } setCursor(cdone); } else if (event.getEventType() == HyperlinkEvent.EventType.ENTERED) { try { JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1); statusField.setText(event.getDescription()); } catch (Exception exp) { } } else if (event.getEventType() == HyperlinkEvent.EventType.EXITED) { try { JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1); statusField.setText(""); } catch (Exception exp) { } } }
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) NetworkUtil.openBrowser(e.getURL()); }
/** * Hyperlink events handler. * * @param e The event. */ public void hyperlinkUpdate(HyperlinkEvent e) { try { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) textArea.setPage(e.getURL()); } catch (Exception err) { } }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { getAppletContext().showDocument(e.getURL(), "_blank"); } }
@Override public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { BrowserControl.displayURL(hyperlinkEvent.getURL().toString()); } }
/** Notification of a change relative to a hyperlink. */ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { linkActivated(e.getURL()); } }
/** * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent) */ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { handleSeeURL(e.getURL()); } }
@Override protected void loadPage(JEditorPane pane, HyperlinkEvent evt) { browser.loadPage(evt.getURL().toString()); }