JAL-725 - show progress when opening URL in browser
authorjprocter <Jim Procter>
Tue, 14 Dec 2010 17:56:25 +0000 (17:56 +0000)
committerjprocter <Jim Procter>
Tue, 14 Dec 2010 17:56:25 +0000 (17:56 +0000)
src/jalview/gui/Desktop.java

index 5e6c341..580fceb 100755 (executable)
@@ -1274,18 +1274,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     validate();
   }
 
-  public static int getViewCount(String viewId)
+  public static int getViewCount(String alignmentId)
   {
-    AlignViewport[] aps = getViewports(viewId);
+    AlignViewport[] aps = getViewports(alignmentId);
     return (aps == null) ? 0 : aps.length;
   }
 
   /**
    * 
-   * @param viewId
-   * @return all AlignmentPanels concerning the viewId sequence set
+   * @param alignmentId
+   * @return all AlignmentPanels concerning the alignmentId sequence set
    */
-  public static AlignmentPanel[] getAlignmentPanels(String viewId)
+  public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
   {
     int count = 0;
     if (Desktop.desktop == null)
@@ -1303,7 +1303,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         AlignFrame af = (AlignFrame) frames[t];
         for (int a = 0; a < af.alignPanels.size(); a++)
         {
-          if (viewId
+          if (alignmentId
                   .equals(((AlignmentPanel) af.alignPanels.elementAt(a)).av
                           .getSequenceSetId()))
           {
@@ -2155,6 +2155,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
               changeSupport);
       
     }
+    Thread t3=null;
+    {
+      // TODO: do rest service discovery
+    }
     if (blocking)
     {
       while (alive)
@@ -2167,6 +2171,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         }
         alive = (t1 != null && t1.isAlive())
                 || (t2 != null && t2.isAlive())
+                || (t3 != null && t3.isAlive())
                 || (t0 != null && t0.isAlive());
       }
     }
@@ -2230,12 +2235,24 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    */
   public static void showUrl(final String url)
   {
+    showUrl(url, Desktop.instance);
+  }
+  /**
+   * Like showUrl but allows progress handler to be specified
+   * @param url
+   * @param progress (null) or object implementing IProgressIndicator
+   */
+  public static void showUrl(final String url, final IProgressIndicator progress)
+  {
     new Thread(new Runnable()
     {
       public void run()
       {
         try
         {
+          if (progress!=null) {
+            progress.setProgressBar("Opening "+url, this.hashCode());
+          }
           jalview.util.BrowserLauncher.openURL(url);
         } catch (Exception ex)
         {
@@ -2249,6 +2266,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
           ex.printStackTrace();
         }
+        if (progress!=null) {
+          progress.setProgressBar(null, this.hashCode());
+        }
       }
     }).start();
   }