Author: rozagh
Date: 2012-02-14 14:51:14 -0800 (Tue, 14 Feb 2012)
New Revision: 28271

Modified:
   
core3/api/trunk/swing-util-api/src/main/java/org/cytoscape/util/swing/internal/OpenBrowserImpl.java
Log:
fixes #658 Modified the openBowserImpl class by using java.awt.Desktop browse 
function for handling linkouts. The previous implementation limited Unix based 
systems to htmlview package which caused a bug in case the package was not 
installed.

Modified: 
core3/api/trunk/swing-util-api/src/main/java/org/cytoscape/util/swing/internal/OpenBrowserImpl.java
===================================================================
--- 
core3/api/trunk/swing-util-api/src/main/java/org/cytoscape/util/swing/internal/OpenBrowserImpl.java
 2012-02-14 22:37:33 UTC (rev 28270)
+++ 
core3/api/trunk/swing-util-api/src/main/java/org/cytoscape/util/swing/internal/OpenBrowserImpl.java
 2012-02-14 22:51:14 UTC (rev 28271)
@@ -43,7 +43,10 @@
 package org.cytoscape.util.swing.internal;
 
 
+import java.awt.Desktop;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Properties;
 
 import org.cytoscape.property.CyProperty;
@@ -74,45 +77,25 @@
         * @param url DOCUMENT ME!
         */
        public boolean openURL(String url) {
-               String defBrowser = 
props.getProperty(OpenBrowser.DEF_WEB_BROWSER_PROP_NAME);
-               String osName = System.getProperty("os.name");
-
-               try {
-                       String cmd;
-
-                       if (osName.startsWith("Windows")) {
-                               cmd = WIN_PATH + " " + url;
-                       } else if (osName.startsWith("Mac")) {
-                               cmd = MAC_PATH + " " + url;
-                       } else {
-                               if (defBrowser != null && 
!defBrowser.equals("")) {
-                                       cmd = defBrowser + " " + url;
-                               } else {
-                                       cmd = UNIX_PATH + " " + url;
-                               }
-                       }
-
-                       logger.debug("Opening URL by command \"" + cmd + "\"");
-
-                       Process p = Runtime.getRuntime().exec(cmd);
-
-                       try {
-                               int exitCode = p.waitFor();
-
-                               if (exitCode != 0) {
-                                       logger.warn("Open browser command (" + 
cmd + ") failed!");
-                                       return false;
-                               }
-
-                       } catch (InterruptedException ex) {
-                               logger.warn("Open browser exception",ex);       
-                               return false;
-                       }
-               } catch (IOException ioe) {
+               
+               Desktop desktop  = Desktop.getDesktop();
+               
+               try{
+                       URI uri = new URI(url);
+                       desktop.browse(uri);
+               }catch (IOException ioe) {
+                       
                        logger.warn("Open browser IOException",ioe);    
                        return false;
+                       
+               } catch (URISyntaxException e) {
+                       
+                       logger.warn("Url conversion to URI exception", e);
+                       return false;
+                       
                }
-
+               
                return true;
        }
+
 }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to