JAL-1130 refactored standard hyperlink handler code to desktop
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 1 Aug 2012 15:19:23 +0000 (16:19 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 19 Sep 2012 12:17:30 +0000 (13:17 +0100)
src/jalview/gui/Desktop.java
src/jalview/gui/WebserviceInfo.java

index 6018b28..3c34deb 100644 (file)
@@ -80,8 +80,10 @@ import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JProgressBar;
 import javax.swing.SwingUtilities;
+import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
+import javax.swing.event.HyperlinkEvent.EventType;
 
 /**
  * Jalview Desktop
@@ -2574,5 +2576,33 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     return wsparamManager;
   }
 
+  /**
+   * static hyperlink handler proxy method for use by Jalview's internal windows 
+   * @param e
+   */
+  public static void hyperlinkUpdate(HyperlinkEvent e)
+  {
+    if (e.getEventType() == EventType.ACTIVATED)
+    {
+      String url=null;
+      try
+      {
+        url = e.getURL().toString();
+        Desktop.showUrl(url);
+      } catch (Exception x)
+      {
+        if (url!=null) { 
+          if (Cache.log!=null) { 
+            Cache.log.error("Couldn't handle string "+url+" as a URL.");
+          } else {
+            System.err.println("Couldn't handle string "+url+" as a URL.");
+          }
+        }
+        // ignore any exceptions due to dud links.
+      }
+
+    }    
+  }
+
 
 }
index 9f8a8a8..51c8e83 100755 (executable)
@@ -822,21 +822,6 @@ public class WebserviceInfo extends GWebserviceInfo implements
 
   public void hyperlinkUpdate(HyperlinkEvent e)
   {
-    if (e.getEventType() == EventType.ACTIVATED)
-    {
-      String url=null;
-      try
-      {
-        url = e.getURL().toString();
-        Desktop.showUrl(url);
-      } catch (Exception x)
-      {
-        if (url!=null) { 
-          Cache.log.error("Couldn't handle string "+url+" as a URL.");
-        }
-        // ignore any exceptions due to dud links.
-      }
-
-    }
+    Desktop.hyperlinkUpdate(e);
   }
 }