Merge branch 'patch/JAL-4196_structure_viewer_synchronising' into develop
[jalview.git] / src / jalview / gui / Desktop.java
index cfc56b2..b901ae4 100644 (file)
@@ -626,6 +626,12 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
     });
     desktop.addMouseListener(ma);
+
+    if (Platform.isJS())
+    {
+      // used for jalviewjsTest
+      jalview.bin.Console.info("JALVIEWJS: CREATED DESKTOP");
+    }
   }
 
   /**
@@ -3159,10 +3165,14 @@ public class Desktop extends jalview.jbgui.GDesktop
     String title = "View of desktop";
     ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS,
             title);
-    try {
+    try
+    {
       exporter.doExport(of, this, width, height, title);
-    } catch (ImageOutputException ioex) {
-      jalview.bin.Console.error("Unexpected error whilst writing Jalview desktop snapshot as EPS",ioex);
+    } catch (ImageOutputException ioex)
+    {
+      jalview.bin.Console.error(
+              "Unexpected error whilst writing Jalview desktop snapshot as EPS",
+              ioex);
     }
   }
 
@@ -3609,11 +3619,32 @@ public class Desktop extends jalview.jbgui.GDesktop
    */
   public static void closeDesktop()
   {
-    if (Desktop.instance != null) {
+    if (Desktop.instance != null)
+    {
       Desktop.instance.closeAll_actionPerformed(null);
       Desktop.instance.setVisible(false);
       Desktop.instance.dispose();
       Desktop.instance = null;
     }
   }
+
+  /**
+   * checks if any progress bars are being displayed in any of the windows managed by the desktop
+   * @return
+   */
+  public boolean operationsAreInProgress()
+  {
+    JInternalFrame[] frames = getAllFrames();
+    for (JInternalFrame frame:frames)
+    {
+      if (frame instanceof IProgressIndicator)
+      {
+        if (((IProgressIndicator)frame).operationInProgress())
+        {
+          return true;
+        }
+      }
+    }
+    return operationInProgress();
+  }
 }