X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=3205dab903599882ccd60319274668a1c402bd04;hb=8a6fa9ea9900d0f106529c3f6283e7f9d76dd2cb;hp=6910f280a01abe4a38249c4ceaf7a08179bba7d5;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 6910f28..3205dab 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -83,8 +83,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements /** * @param listener - * @see java.beans.PropertyChangeSupport#addPropertyChangeListener( - * java.beans.PropertyChangeListener) + * @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener) */ public void addJalviewPropertyChangeListener( PropertyChangeListener listener) @@ -414,13 +413,17 @@ 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 (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; + 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 @@ -584,34 +587,33 @@ public class Desktop extends jalview.jbgui.GDesktop implements } final JMenuItem menuItem = new JMenuItem(title); - frame - .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { - public void internalFrameActivated( - javax.swing.event.InternalFrameEvent evt) - { - JInternalFrame itf = desktop.getSelectedFrame(); - if (itf != null) - { - itf.requestFocus(); - } + frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameActivated( + javax.swing.event.InternalFrameEvent evt) + { + JInternalFrame itf = desktop.getSelectedFrame(); + if (itf != null) + { + itf.requestFocus(); + } - } + } - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent evt) - { - PaintRefresher.RemoveComponent(frame); - openFrameCount--; - windowMenu.remove(menuItem); - JInternalFrame itf = desktop.getSelectedFrame(); - if (itf != null) - { - itf.requestFocus(); - } - System.gc(); - }; - }); + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent evt) + { + PaintRefresher.RemoveComponent(frame); + openFrameCount--; + windowMenu.remove(menuItem); + JInternalFrame itf = desktop.getSelectedFrame(); + if (itf != null) + { + itf.requestFocus(); + } + System.gc(); + }; + }); menuItem.addActionListener(new ActionListener() { @@ -763,8 +765,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport) { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS, jalview.io.AppletFormatAdapter.READABLE_FNAMES, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); @@ -944,22 +946,20 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (!jalview.bin.Cache.getProperty("LATEST_VERSION").equals( jalview.bin.Cache.getProperty("VERSION"))) { - message - .append("\n\n!! Jalview version " - + jalview.bin.Cache.getProperty("LATEST_VERSION") - + " is available for download from http://www.jalview.org !!\n"); + message.append("\n\n!! Jalview version " + + jalview.bin.Cache.getProperty("LATEST_VERSION") + + " is available for download from http://www.jalview.org !!\n"); } // TODO: update this text for each release or centrally store it for lite // and application - message - .append("\nAuthors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,\n David Martin & Geoff Barton." - + "\nDevelopment managed by The Barton Group, University of Dundee, Scotland, UK.\n" - + "\nFor help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list\n" - + "\nIf you use Jalview, please cite:" - + "\nWaterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)" - + "\nJalview Version 2 - a multiple sequence alignment editor and analysis workbench" - + "\nBioinformatics doi: 10.1093/bioinformatics/btp033"); + message.append("\nAuthors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,\n David Martin & Geoff Barton." + + "\nDevelopment managed by The Barton Group, University of Dundee, Scotland, UK.\n" + + "\nFor help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list\n" + + "\nIf you use Jalview, please cite:" + + "\nWaterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)" + + "\nJalview Version 2 - a multiple sequence alignment editor and analysis workbench" + + "\nBioinformatics doi: 10.1093/bioinformatics/btp033"); JOptionPane.showInternalMessageDialog(Desktop.desktop, message.toString(), "About Jalview", JOptionPane.INFORMATION_MESSAGE); @@ -1172,10 +1172,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public void saveState_actionPerformed(ActionEvent e) { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "jar" }, new String[] - { "Jalview Project" }, "Jalview Project"); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "jar" }, new String[] + { "Jalview Project" }, "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Save State"); @@ -1185,23 +1185,28 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { java.io.File choice = chooser.getSelectedFile(); - setProgressBar("Saving jalview project " - + choice.getName(), choice.hashCode()); + setProgressBar("Saving jalview project " + choice.getName(), + choice.hashCode()); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); // TODO catch and handle errors for savestate - try { + try + { new Jalview2XML().SaveState(choice); } catch (OutOfMemoryError oom) { - new OOMWarning("Whilst saving current state to "+choice.getName(), oom); - } - catch (Exception ex) + 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); + 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()); - + } } @@ -1213,10 +1218,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public void loadState_actionPerformed(ActionEvent e) { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "jar" }, new String[] - { "Jalview Project" }, "Jalview Project"); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "jar" }, new String[] + { "Jalview Project" }, "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Restore state"); @@ -1227,22 +1232,27 @@ public class Desktop extends jalview.jbgui.GDesktop implements final String choice = chooser.getSelectedFile().getAbsolutePath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); - new Thread(new Runnable() { - public void run() { - setProgressBar("loading jalview project " - + choice, choice.hashCode()); - try { - new Jalview2XML().LoadJalviewAlign(choice); } - catch (OutOfMemoryError oom) + new Thread(new Runnable() { - 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()); + 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(); } @@ -1487,13 +1497,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (v_client == null) { // Load and try to start a session. - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY")); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY")); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Open a saved VAMSAS session"); - chooser - .setToolTipText("select a vamsas session to be opened as a new vamsas session."); + chooser.setToolTipText("select a vamsas session to be opened as a new vamsas session."); int value = chooser.showOpenDialog(this); @@ -1548,8 +1557,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements } bis.close(); fos.close(); - v_client = new jalview.gui.VamsasApplication(this, file, url - .toExternalForm()); + v_client = new jalview.gui.VamsasApplication(this, file, + url.toExternalForm()); } catch (Exception ex) { jalview.bin.Cache.log.error( @@ -1578,8 +1587,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements return false; } - setProgressBar("Importing VAMSAS session from " + file.getName(), file - .hashCode()); + setProgressBar("Importing VAMSAS session from " + file.getName(), + file.hashCode()); try { v_client = new jalview.gui.VamsasApplication(this, file, null); @@ -1593,8 +1602,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements } setupVamsasConnectedGui(); v_client.initial_update(); // TODO: thread ? - setProgressBar("Importing VAMSAS session from " + file.getName(), file - .hashCode()); + setProgressBar("Importing VAMSAS session from " + file.getName(), + file.hashCode()); return v_client.inSession(); } @@ -1744,9 +1753,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements { if (v_client != null) { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "vdj" }, // TODO: VAMSAS DOCUMENT EXTENSION is VDJ + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "vdj" }, // TODO: VAMSAS DOCUMENT EXTENSION is VDJ new String[] { "Vamsas Document" }, "Vamsas Document"); @@ -1917,10 +1926,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements FontMetrics fm = g.getFontMetrics(); if (fm != null) { - g.drawString("Total Free Memory: " + df.format(totalFreeMemory) - + "MB; Max Memory: " + df.format(maxMemory) + "MB; " - + df.format(percentUsage) + "%", 10, getHeight() - - fm.getHeight()); + g.drawString( + "Total Free Memory: " + df.format(totalFreeMemory) + + "MB; Max Memory: " + df.format(maxMemory) + + "MB; " + df.format(percentUsage) + "%", 10, + getHeight() - fm.getHeight()); } } } @@ -2084,8 +2094,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements public void actionPerformed(ActionEvent e) { handler.cancelActivity(id); - us.setProgressBar("Cancelled " - + ((JLabel) progressPanel.getComponent(0)).getText(), id); + us.setProgressBar( + "Cancelled " + + ((JLabel) progressPanel.getComponent(0)) + .getText(), id); } }); progressPanel.add(cancel, BorderLayout.EAST); @@ -2120,13 +2132,15 @@ public class Desktop extends jalview.jbgui.GDesktop implements return v_client; } + /** * flag set if jalview GUI is being operated programmatically */ - private boolean inBatchMode=false; + private boolean inBatchMode = false; /** * check if jalview GUI is being operated programmatically + * * @return inBatchMode */ public boolean isInBatchMode() @@ -2136,14 +2150,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements /** * set flag if jalview GUI is being operated programmatically - * @param inBatchMode + * + * @param inBatchMode */ public void setInBatchMode(boolean inBatchMode) { this.inBatchMode = inBatchMode; } - public void startServiceDiscovery() { startServiceDiscovery(false); @@ -2179,8 +2193,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements } catch (Exception e) { Cache.log - .info( - "Exception when trying to launch Envision2 workflow discovery.", + .info("Exception when trying to launch Envision2 workflow discovery.", e); Cache.log.info(e.getStackTrace()); } @@ -2209,34 +2222,42 @@ 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. + * 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 { + 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); + "Web browser not found", + JOptionPane.WARNING_MESSAGE); ex.printStackTrace(); } } - }).start(); + }).start(); } public static WsParamSetManager wsparamManager = null; + public static ParamManager getUserParameterStore() { - if (wsparamManager==null) + if (wsparamManager == null) { wsparamManager = new WsParamSetManager(); }