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(); } }
final void setPage(HtmlPage page) throws IOException { this.page = page; final Document doc = textPane.getDocument(); doc.putProperty(Document.TitleProperty, page.getTitle()); // Clearing stream forces refresh. doc.putProperty(Document.StreamDescriptionProperty, null); textPane.setPage(page.getPath().toURI().toURL()); find(find.getText()); }
public void run() { try { editorPane.setPage(new URL("http://devteam-unicraft.tumblr.com/")); } catch (Exception e) { e.printStackTrace(); editorPane.setText( "Impossible de charger les news du serveur..." + e.toString() + "</center></font></body></html>"); } }
@Override protected Object doInBackground() { URL url = null; try { url = new URL(this.url); if (MirrorUtils.isAddressReachable(url.toString())) { editorPane.setVisible(false); editorPane.setContentType("text/html"); // editorPane.setEditable(false); ToolTipManager.sharedInstance().registerComponent(editorPane); editorPane.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(e.getURL().toURI()); } } catch (IOException e1) { e1.printStackTrace(); } catch (URISyntaxException e1) { e1.printStackTrace(); } } } }); editorPane.addPropertyChangeListener(this); editorPane.setPage(url); } else { editorPane.setText("Oh Noes! Our Tumblr Feed is Down!"); } } catch (MalformedURLException e1) { e1.printStackTrace(); } catch (IOException e1) { editorPane.setText("Oh Noes! Our Tumblr Server is Down!"); Util.log("Tumbler log @ '%' not avaliable.", url); } return null; }
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() + '\''); } } }
private void showLicense(int page) { String localUrl = null; switch (page) { // String remoteUrl = // "http://www.statistica.unimib.it/utenti/dellavedova/software/artistic2.html"; case 0: localUrl = "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "license/TheClarifiedArtisticLicense.htm"; break; } try { txtLicense.setPage(localUrl); } catch (final IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog( new JFrame(), "Error: setting file is missing. Program will exit."); System.exit(0); } }