progress when saving state (JAL-870) and hack to trap possible gui race condition...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Sun, 10 Jul 2011 15:32:40 +0000 (16:32 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Sun, 10 Jul 2011 15:33:31 +0000 (16:33 +0100)
src/jalview/gui/Desktop.java

index 03b2005..afae5fb 100644 (file)
@@ -635,6 +635,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     } catch (java.beans.PropertyVetoException ve)
     {
     }
+    catch (java.lang.ClassCastException cex)
+    {
+      Cache.log.warn("Squashed a possible GUI implementation error. If you can recreate this, please look at http://issues.jalview.org/browse/JAL-869",cex);
+    }
   }
 
   public void lostOwnership(Clipboard clipboard, Transferable contents)
@@ -1178,11 +1182,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     if (value == JalviewFileChooser.APPROVE_OPTION)
     {
-      java.io.File choice = chooser.getSelectedFile();
+      final Desktop me = this;
+      final java.io.File choice = chooser.getSelectedFile();
+      new Thread(new Runnable()
+      {
+        public void run()
+        {
+
       setProgressBar("Saving jalview project " + choice.getName(),
               choice.hashCode());
       jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
       // TODO catch and handle errors for savestate
+      // TODO prevent user from messing with the Desktop whilst we're saving
       try
       {
         new Jalview2XML().SaveState(choice);
@@ -1195,12 +1206,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         Cache.log
                 .error("Problems whilst trying to save to "
                         + choice.getName(), ex);
-        JOptionPane.showMessageDialog(this,
+        JOptionPane.showMessageDialog(me,
                 "Error whilst saving current state to " + choice.getName(),
                 "Couldn't save project", JOptionPane.WARNING_MESSAGE);
       }
       setProgressBar(null, choice.hashCode());
-
+        }
+      }).start();
     }
   }