From 6a5989ae85978375935578c0d8fc375d014b567c Mon Sep 17 00:00:00 2001 From: jprocter Date: Sun, 10 Jul 2011 16:32:40 +0100 Subject: [PATCH] progress when saving state (JAL-870) and hack to trap possible gui race condition (JAL-869) --- src/jalview/gui/Desktop.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 03b2005..afae5fb 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -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(); } } -- 1.7.10.2