JAL-4125 Move confirmation of closing external viewer windows into the quit handler...
[jalview.git] / src / jalview / gui / Desktop.java
index 06afe81..dbc99c0 100644 (file)
@@ -102,6 +102,7 @@ import org.stackoverflowusers.file.WindowsShortcut;
 
 import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
+import jalview.api.structures.JalviewStructureDisplayI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.gui.ImageExporter.ImageWriterI;
@@ -1377,6 +1378,8 @@ public class Desktop extends jalview.jbgui.GDesktop
         storeLastKnownDimensions("JALVIEW_RSS_WINDOW_", jvnews.getBounds());
       }
 
+      // Frames should all close automatically. Keeping external
+      // viewers open should already be decided by user.
       closeAll_actionPerformed(null);
 
       // check for aborted quit
@@ -1551,17 +1554,11 @@ public class Desktop extends jalview.jbgui.GDesktop
   {
     // TODO show a progress bar while closing?
     JInternalFrame[] frames = desktop.getAllFrames();
-    boolean quitting = QuitHandler.quitting();
     for (int i = 0; i < frames.length; i++)
     {
       try
       {
         frames[i].setClosed(true);
-        // check for cancelled quit
-        if (quitting && QuitHandler.quitCancelled())
-        {
-          return;
-        }
       } catch (java.beans.PropertyVetoException ex)
       {
       }
@@ -1581,6 +1578,22 @@ public class Desktop extends jalview.jbgui.GDesktop
     }
   }
 
+  public int structureViewersStillRunningCount()
+  {
+    int count = 0;
+    JInternalFrame[] frames = desktop.getAllFrames();
+    for (int i = 0; i < frames.length; i++)
+    {
+      if (frames[i] != null
+              && frames[i] instanceof JalviewStructureDisplayI)
+      {
+        if (((JalviewStructureDisplayI) frames[i]).stillRunning())
+          count++;
+      }
+    }
+    return count;
+  }
+
   @Override
   public void raiseRelated_actionPerformed(ActionEvent e)
   {