+ public void browse(String type) {
+ // TODO: improve presentation of update message
+ final VersionCheck updates = VersionCheck.check();
+ StringBuilder builder = new StringBuilder();
+
+ final JEditorPane updateMessage = new JEditorPane("text/html", "");
+ if (updates.isNewVersionAvailable()) {
+ builder.append("A new version of the program is available at <span style='color: blue;'>https://github.com/nikiroo/fanfix/releases</span>");
+ builder.append("<br>");
+ builder.append("<br>");
+ for (Version v : updates.getNewer()) {
+ builder.append("\t<b>Version " + v + "</b>");
+ builder.append("<br>");
+ builder.append("<ul>");
+ for (String item : updates.getChanges().get(v)) {
+ builder.append("<li>" + item + "</li>");
+ }
+ builder.append("</ul>");
+ }
+
+ // html content
+ updateMessage.setText("<html><body>" //
+ + builder//
+ + "</body></html>");
+
+ // handle link events
+ updateMessage.addHyperlinkListener(new HyperlinkListener() {
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType().equals(
+ HyperlinkEvent.EventType.ACTIVATED))
+ try {
+ Desktop.getDesktop().browse(e.getURL().toURI());
+ } catch (IOException ee) {
+ Instance.syserr(ee);
+ } catch (URISyntaxException ee) {
+ Instance.syserr(ee);
+ }
+ }
+ });
+ updateMessage.setEditable(false);
+ updateMessage.setBackground(new JLabel().getBackground());
+ }
+