X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=6910f280a01abe4a38249c4ceaf7a08179bba7d5;hb=153dd62dc91da13ae732600e6ea55ddbe15eab39;hp=23b18b011f8073c13c30e730973e2346e6bbb002;hpb=d25930a1576379cd45940caa9c1f0e4cf01fbc2c;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 23b18b0..6910f28 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1,5 +1,5 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * * This file is part of Jalview. @@ -19,6 +19,7 @@ package jalview.gui; import jalview.bin.Cache; import jalview.io.*; +import jalview.ws.params.ParamManager; import java.awt.*; import java.awt.datatransfer.*; @@ -54,7 +55,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements private class JalviewChangeSupport implements PropertyChangeListener { - @Override public void propertyChange(PropertyChangeEvent evt) { // Handle change events - most are simply routed to other sources @@ -414,6 +414,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements iw = (int) (iw * sw); iy = (int) (iy * sh); ih = (int) (ih * sh); + while (ix>=screenSize.width) { + jalview.bin.Cache.log.debug("Window geometry location recall error: shifting horizontal to within screenbounds."); + ix-=screenSize.width; + } + while (iy>=screenSize.height) { + jalview.bin.Cache.log.debug("Window geometry location recall error: shifting vertical to within screenbounds."); + iy-=screenSize.height; + } jalview.bin.Cache.log.debug("Got last known dimensions for " + windowName + ": x:" + ix + " y:" + iy + " width:" + iw + " height:" + ih); @@ -1177,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()); + } } @@ -1206,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(); } } @@ -2088,6 +2120,29 @@ public class Desktop extends jalview.jbgui.GDesktop implements return v_client; } + /** + * flag set if jalview GUI is being operated programmatically + */ + private boolean inBatchMode=false; + + /** + * check if jalview GUI is being operated programmatically + * @return inBatchMode + */ + public boolean isInBatchMode() + { + return inBatchMode; + } + + /** + * set flag if jalview GUI is being operated programmatically + * @param inBatchMode + */ + public void setInBatchMode(boolean inBatchMode) + { + this.inBatchMode = inBatchMode; + } + public void startServiceDiscovery() { @@ -2113,7 +2168,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements try { - if (Cache.getDefault("SHOW_ENVISION2_SERVICES", true)) + if (Cache.getDefault("SHOW_ENFIN_SERVICES", true)) { // EnfinEnvision web service menu entries are rebuild every time the // menu is shown, so no changeSupport events are needed. @@ -2153,4 +2208,39 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } + /** + * start a thread to open a URL in the configured browser. Pops up a warning dialog to the user if there is an exception when calling out to the browser to open the URL. + * @param url + */ + public static void showUrl(final String url) + { + new Thread(new Runnable() { + public void run() { + try { + jalview.util.BrowserLauncher.openURL(url); + } catch (Exception ex) + { + JOptionPane + .showInternalMessageDialog( + Desktop.desktop, + "Unixers: Couldn't find default web browser." + + "\nAdd the full path to your browser in Preferences.", + "Web browser not found", JOptionPane.WARNING_MESSAGE); + + ex.printStackTrace(); + } + } + }).start(); + } + + public static WsParamSetManager wsparamManager = null; + public static ParamManager getUserParameterStore() + { + if (wsparamManager==null) + { + wsparamManager = new WsParamSetManager(); + } + return wsparamManager; + } + }