[izpack-changes] r1850 - izpack-src/trunk/src/lib/com/izforge/izpack/panels

noreply at berlios.de noreply at berlios.de
Tue May 29 22:31:42 CEST 2007


Author: vralev
Date: 2007-05-29 22:31:39 +0200 (Tue, 29 May 2007)
New Revision: 1850

Modified:
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java
Log:
Launch HTMLInfo panel external links in the system browser.

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java	2007-05-28 13:21:27 UTC (rev 1849)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/HTMLInfoPanel.java	2007-05-29 20:31:39 UTC (rev 1850)
@@ -62,6 +62,7 @@
         try
         {
             textArea = new JEditorPane();
+            textArea.setContentType("text/html; charset=utf-8");
             textArea.setEditable(false);
             textArea.addHyperlinkListener(this);
             JScrollPane scroller = new JScrollPane(textArea);
@@ -113,8 +114,38 @@
     {
         try
         {
-            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
-                textArea.setPage(e.getURL());
+             if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
+             {
+                String urls = e.getURL().toExternalForm();
+                // if the link points to a chapter in the same page
+                // don't open a browser
+                if(urls.contains("HTMLInfoPanel.info#"))
+                   textArea.setPage(e.getURL());
+                else
+                {
+                   if(com.izforge.izpack.util.OsVersion.IS_UNIX)
+                   {
+                      String[] launchers = {"htmlview QqzURL", "xdg-open QqzURL", "gnome-open QqzURL", "kfmclient openURL QqzURL", "call-browser QqzURL", "firefox QqzURL", "opera QqzURL", "konqueror QqzURL", "epiphany QqzURL", "mozilla QqzURL", "netscape QqzURL"};
+                      //String launchers = "/bin/sh -c \"htmlview QqzURL || xdg-open QqzURL || gnome-open QqzURL || kfmclient openURL QqzURL || call-browser QqzURL || firefox QqzURL || opera QqzURL || konqueror QqzURL || epiphany QqzURL || mozilla QqzURL || netscape QqzURL\"";
+                      for(int q=0; q<launchers.length; q++)
+                      {
+                         
+                         try
+                         {
+                            Runtime.getRuntime().exec(launchers[q].replaceAll("QqzURL", urls));
+                            System.out.println("OK");
+                            break;
+                         }
+                         catch(Exception ignore)
+                         {
+                            System.out.println(launchers[q]+" NOT OK");
+                         }
+                      }
+                   }
+                   else // windows
+                      Runtime.getRuntime().exec("cmd /C start "+urls);
+                }
+            }
         }
         catch (Exception err)
         {




More information about the izpack-changes mailing list