JAL-1988 Investigating...
authorBen Soares <bsoares@dundee.ac.uk>
Mon, 5 Nov 2018 16:47:41 +0000 (16:47 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Mon, 5 Nov 2018 16:47:41 +0000 (16:47 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/gui/Desktop.java
src/jalview/jbgui/GDesktop.java

index 94b38ed..96b7960 100644 (file)
@@ -1188,9 +1188,26 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         try
         {
-          PrintWriter out = new PrintWriter(new FileWriter(file));
+          // PrintWriter out = new PrintWriter(new FileWriter(file));
+          PrintWriter out = new PrintWriter(new FileWriter(file), true);
 
+          // TESTING code here
+          boolean TESTING = true;
+          if (TESTING)
+          {
+            out.print("; TESTSTART\n");
+            int count = 20;
+            for (int i = 0; i < count; i++)
+            {
+              Thread.sleep(1000);
+              out.println("; TEST: " + (count - 1 - i));
+            }
+          }
           out.print(output);
+          if (TESTING)
+          {
+            out.print("; TESTEND\n");
+          }
           out.close();
           this.setTitle(file);
           statusBar.setText(MessageManager.formatMessage(
index 8d9e366..41dba91 100644 (file)
@@ -80,9 +80,11 @@ import java.beans.PropertyChangeListener;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.ListIterator;
@@ -105,7 +107,6 @@ import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDesktopPane;
-import javax.swing.JFrame;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JMenuItem;
@@ -114,6 +115,7 @@ import javax.swing.JPopupMenu;
 import javax.swing.JProgressBar;
 import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkEvent.EventType;
 import javax.swing.event.InternalFrameAdapter;
@@ -122,7 +124,6 @@ import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 
 import org.stackoverflowusers.file.WindowsShortcut;
-
 /**
  * Jalview Desktop
  * 
@@ -144,6 +145,8 @@ public class Desktop extends jalview.jbgui.GDesktop
 
   private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES";
 
+  public static HashMap<String, FileWriter> savingFiles = new HashMap<>();
+
   private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
 
   /**
@@ -345,7 +348,17 @@ public class Desktop extends jalview.jbgui.GDesktop
 
     doConfigureStructurePrefs();
     setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
-    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    if (!Platform.isAMac())
+    {
+      this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+    }
+    else
+    {
+      this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+      this.addQuitHandler();
+
+    }
     boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
             false);
     boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
@@ -1251,6 +1264,8 @@ public class Desktop extends jalview.jbgui.GDesktop
   @Override
   public void quit()
   {
+    System.out.println("********** Desktop.quit()");
+    System.out.println(savingFiles.toString());
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
     jalview.bin.Cache.setProperty("SCREENGEOMETRY_WIDTH",
             screen.width + "");
index a4afb74..1e51541 100755 (executable)
@@ -538,6 +538,7 @@ public class GDesktop extends JFrame
    */
   protected void quit()
   {
+    System.out.println("********** GDesktop.quit()");
   }
 
   /**