From: jprocter Date: Sun, 19 Sep 2010 22:35:29 +0000 (+0000) Subject: progress bar and OOM/Exception traps for project marshalling X-Git-Tag: Release_2_6~27 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1b3efd43049603b63aa43a73c66741f0532ed30c;p=jalview.git progress bar and OOM/Exception traps for project marshalling --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index cf89494..7726179 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1185,13 +1185,23 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { java.io.File choice = chooser.getSelectedFile(); - JProgressBar progpanel = addProgressPanel("Saving jalview project " - + choice.getName()); + setProgressBar("Saving jalview project " + + choice.getName(), choice.hashCode()); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); // TODO catch and handle errors for savestate - new Jalview2XML().SaveState(choice); - removeProgressPanel(progpanel); - + try { + new Jalview2XML().SaveState(choice); + } catch (OutOfMemoryError oom) + { + new OOMWarning("Whilst saving current state to "+choice.getName(), oom); + } + catch (Exception ex) + { + Cache.log.error("Problems whilst trying to save to "+choice.getName(),ex); + JOptionPane.showMessageDialog(this, "Error whilst saving current state to "+choice.getName(), "Couldn't save project", JOptionPane.WARNING_MESSAGE); + } + setProgressBar(null, choice.hashCode()); + } } @@ -1214,13 +1224,27 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { - String choice = chooser.getSelectedFile().getAbsolutePath(); - setProgressBar("loading jalview project " - + chooser.getSelectedFile().getName(), choice.hashCode()); + final String choice = chooser.getSelectedFile().getAbsolutePath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); - new Jalview2XML().LoadJalviewAlign(choice); + new Thread(new Runnable() { + public void run() { + setProgressBar("loading jalview project " + + choice, choice.hashCode()); + try { + new Jalview2XML().LoadJalviewAlign(choice); } + catch (OutOfMemoryError oom) + { + new OOMWarning("Whilst loading project from "+choice, oom); + } + catch (Exception ex) + { + Cache.log.error("Problems whilst loading project from "+choice,ex); + JOptionPane.showMessageDialog(Desktop.desktop, "Error whilst loading project from "+choice, "Couldn't load project", JOptionPane.WARNING_MESSAGE); + } setProgressBar(null, choice.hashCode()); + } + }).start(); } }