private void renderInfo() { if (sel.rsc == null) { try { infoView.setPage(BLANK_PAGE); } catch (IOException e) { e.printStackTrace(); } return; } try { infoView.setPage(sel.rsc); } catch (IOException e) { e.printStackTrace(); } }
public TOSDialog() { super(null, false, IdeModalityType.IDE); init(); setTitle("eddy - Logging preferences"); setCrossClosesWindow(false); // get TOS page out of our jar or directory final String pathname = PathUtil.getJarPathForClass(TOSDialog.class); final File path = new File(pathname); try { final URL url; if (path.isDirectory()) { url = new File(path, "intro.html").toURI().toURL(); } else { url = ResourceUtil.getResource(TOSDialog.class, "", "intro.html"); } TOSTextPane.setPage(url); } catch (MalformedURLException e) { throw new RuntimeException("Cannot load intro text. Please try reinstalling.", e); } catch (IOException e) { throw new RuntimeException("Cannot load intro text. Please try reinstalling.", e); } HyperlinkListener l = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { log("got link event: " + e); if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) { try { java.awt.Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException e1) { // wtf, do nothing log("exception: " + e1); } catch (URISyntaxException e2) { // broken link, do nothing log("exception: " + e2); } } } }; TOSTextPane.addHyperlinkListener(l); }
public boolean loadResource(String resourceName, Class<?> location) { Resource res = null; try { res = ResourceLoader.getResource(resourceName, location); } catch (Exception ex) { OSPLog.fine("Error getting resource: " + resourceName); // $NON-NLS-1$ return false; } if (res == null) { OSPLog.fine("Resource not found: " + resourceName); // $NON-NLS-1$ return false; } try { textPane.setPage(res.getURL()); } catch (IOException ex) { OSPLog.fine("Resource not loadeded: " + resourceName); // $NON-NLS-1$ return false; } setTitle(resourceName); return true; }
private void setPageOnly(URL baseUrl, String anchorName) { try { URL url; if (anchorName != null) { url = new URL(baseUrl + "#" + anchorName); } else { url = baseUrl; } super.setPage(url); // if anchor is present - scroll to it String stringUrl = url.toString(); if (stringUrl.contains("#")) { scrollToReference(stringUrl.substring(stringUrl.indexOf("#"))); } } catch (IOException ex) { if (baseUrl == null) { LOGGER.error("Error: Help file not set"); } else { LOGGER.error("Error: Help file not found '" + baseUrl.getFile() + '\''); } } }