X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FDesktop.java;h=b7057d17e11216a8b99c9bfe1f556f561a4e18dc;hb=5c33de4092732a61c2bc4ab3cb76b773752ad37a;hp=67155370b4cc5fb7b306db5acce65f14d20ddddd;hpb=cb5d856b1304448cae13a333cbd9017f81520d90;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 6715537..b7057d1 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1,19 +1,21 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.gui; @@ -24,6 +26,7 @@ import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; +import jalview.util.ImageMaker; import jalview.util.MessageManager; import jalview.ws.params.ParamManager; @@ -559,7 +562,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements void showPasteMenu(int x, int y) { JPopupMenu popup = new JPopupMenu(); - JMenuItem item = new JMenuItem(MessageManager.getString("label.paste_new_window")); + JMenuItem item = new JMenuItem( + MessageManager.getString("label.paste_new_window")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) @@ -649,8 +653,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN // IF JALVIEW IS RUNNING HEADLESS // /////////////////////////////////////////////// - if (instance == null || (System.getProperty("java.awt.headless") != null - && System.getProperty("java.awt.headless").equals("true"))) + if (instance == null + || (System.getProperty("java.awt.headless") != null && System + .getProperty("java.awt.headless").equals("true"))) { return; } @@ -807,6 +812,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public void drop(DropTargetDropEvent evt) { + boolean success = true; Transferable t = evt.getTransferable(); java.util.List files = null; java.util.List protocols = null; @@ -855,6 +861,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } catch (Exception e) { + success = false; } if (files != null) @@ -883,8 +890,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } catch (Exception ex) { + success = false; } } + evt.dropComplete(success); // need this to ensure input focus is properly + // transfered to any new windows created } /** @@ -902,7 +912,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle(MessageManager.getString("label.open_local_file")); + chooser.setDialogTitle(MessageManager + .getString("label.open_local_file")); chooser.setToolTipText(MessageManager.getString("action.open")); int value = chooser.showOpenDialog(this); @@ -914,7 +925,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements .getSelectedFile().getParent()); String format = null; - if (chooser.getSelectedFormat().equals("Jalview")) + if (chooser.getSelectedFormat() != null + && chooser.getSelectedFormat().equals("Jalview")) { format = "Jalview"; } @@ -945,7 +957,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements { // This construct allows us to have a wider textfield // for viewing - JLabel label = new JLabel(MessageManager.getString("label.input_file_url")); + JLabel label = new JLabel( + MessageManager.getString("label.input_file_url")); final JComboBox history = new JComboBox(); JPanel panel = new JPanel(new GridLayout(2, 1)); @@ -970,7 +983,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements } int reply = JOptionPane.showInternalConfirmDialog(desktop, panel, - MessageManager.getString("label.input_alignment_from_url"), JOptionPane.OK_CANCEL_OPTION); + MessageManager.getString("label.input_alignment_from_url"), + JOptionPane.OK_CANCEL_OPTION); if (reply != JOptionPane.OK_OPTION) { @@ -1100,7 +1114,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements { message.append("

Version: " + jalview.bin.Cache.getProperty("VERSION") - + "


"); + + ""); message.append("Last Updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + ""); @@ -1147,11 +1161,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements message.append("
Authors: " + jalview.bin.Cache .getDefault( - "AUTHORNAMES", - "Jim Procter, Andrew Waterhouse, Jan Engelhardt, Lauren Lui, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton") - + "
Development managed by The Barton Group, University of Dundee, Scotland, UK.
" - + "
For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list" - + "
If you use Jalview, please cite:" + "AUTHORFNAMES", + "The Jalview Authors (See AUTHORS file for current list)") + + "

Development managed by The Barton Group, University of Dundee, Scotland, UK.
" + + "

For help, see the FAQ at www.jalview.org/faq and/or join the jalview-discuss@jalview.org mailing list" + + "

If you use Jalview, please cite:" + "
Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)" + "
Jalview Version 2 - a multiple sequence alignment editor and analysis workbench" + "
Bioinformatics doi: 10.1093/bioinformatics/btp033" @@ -1368,7 +1382,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements { JalviewFileChooser chooser = new JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] - { "jar" }, new String[] + { "jvp" }, new String[] { "Jalview Project" }, "Jalview Project"); chooser.setFileView(new JalviewFileView()); @@ -1425,8 +1439,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements { JalviewFileChooser chooser = new JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] - { "jar" }, new String[] - { "Jalview Project" }, "Jalview Project"); + { "jvp", "jar" }, new String[] + { "Jalview Project", "Jalview Project (old)" }, + "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Restore state"); @@ -1511,13 +1526,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements { if (progressPanel != null) { - progressPanel.remove(progbar); - GridLayout gl = (GridLayout) progressPanel.getLayout(); - gl.setRows(gl.getRows() - 1); - if (--totalProgressCount < 1) + synchronized (progressPanel) { - this.getContentPane().remove(progressPanel); - progressPanel = null; + progressPanel.remove(progbar); + GridLayout gl = (GridLayout) progressPanel.getLayout(); + gl.setRows(gl.getRows() - 1); + if (--totalProgressCount < 1) + { + this.getContentPane().remove(progressPanel); + progressPanel = null; + } } } validate(); @@ -1528,9 +1546,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements fileLoadingCount--; if (fileLoadingCount < 1) { - for (JPanel flp : fileLoadingPanels) + while (fileLoadingPanels.size() > 0) { - removeProgressPanel(flp); + removeProgressPanel(fileLoadingPanels.remove(0)); } fileLoadingPanels.clear(); fileLoadingCount = 0; @@ -1713,7 +1731,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Open a saved VAMSAS session"); - chooser.setToolTipText(MessageManager.getString("label.select_vamsas_session_opened_as_new_vamsas_session")); + chooser.setToolTipText(MessageManager + .getString("label.select_vamsas_session_opened_as_new_vamsas_session")); int value = chooser.showOpenDialog(this); @@ -1722,10 +1741,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements String fle = chooser.getSelectedFile().toString(); if (!vamsasImport(chooser.getSelectedFile())) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.formatMessage("label.couldnt_import_as_vamsas_session", new String[]{fle}), - MessageManager.getString("label.vamsas_document_import_failed"), - JOptionPane.ERROR_MESSAGE); + JOptionPane + .showInternalMessageDialog( + Desktop.desktop, + MessageManager.formatMessage( + "label.couldnt_import_as_vamsas_session", + new String[] + { fle }), + MessageManager + .getString("label.vamsas_document_import_failed"), + JOptionPane.ERROR_MESSAGE); } } } @@ -1879,7 +1904,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements vamsasSave.setVisible(false); vamsasStop.setVisible(false); vamsasImport.setVisible(true); - vamsasStart.setText(MessageManager.getString("label.new_vamsas_session")); + vamsasStart.setText(MessageManager + .getString("label.new_vamsas_session")); } public void vamsasStop_actionPerformed(ActionEvent e) @@ -1915,7 +1941,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements { JMenuItem sessit = new JMenuItem(); sessit.setText(sess[i]); - sessit.setToolTipText(MessageManager.formatMessage("label.connect_to_session", new String[]{sess[i]})); + sessit.setToolTipText(MessageManager.formatMessage( + "label.connect_to_session", new String[] + { sess[i] })); final Desktop dsktp = this; final String mysesid = sess[i]; sessit.addActionListener(new ActionListener() @@ -2137,8 +2165,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements FontMetrics fm = g.getFontMetrics(); if (fm != null) { - g.drawString( - MessageManager.formatMessage("label.memory_stats", new String[]{df.format(totalFreeMemory),df.format(maxMemory),df.format(percentUsage)}), 10, + g.drawString(MessageManager.formatMessage( + "label.memory_stats", + new String[] + { df.format(totalFreeMemory), df.format(maxMemory), + df.format(percentUsage) }), 10, getHeight() - fm.getHeight()); } } @@ -2341,7 +2372,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); if (handler.canCancel()) { - JButton cancel = new JButton(MessageManager.getString("action.cancel")); + JButton cancel = new JButton( + MessageManager.getString("action.cancel")); final IProgressIndicator us = this; cancel.addActionListener(new ActionListener() { @@ -2439,15 +2471,15 @@ public class Desktop extends jalview.jbgui.GDesktop implements // JAL-940 - JALVIEW 1 services are now being EOLed as of JABA 2.1 release if (true) { - // todo: changesupport handlers need to be transferred - if (discoverer == null) - { - discoverer = new jalview.ws.jws1.Discoverer(); - // register PCS handler for desktop. - discoverer.addPropertyChangeListener(changeSupport); - } - // JAL-940 - disabled JWS1 service configuration - always start discoverer - // until we phase out completely + // todo: changesupport handlers need to be transferred + if (discoverer == null) + { + discoverer = new jalview.ws.jws1.Discoverer(); + // register PCS handler for desktop. + discoverer.addPropertyChangeListener(changeSupport); + } + // JAL-940 - disabled JWS1 service configuration - always start discoverer + // until we phase out completely (t0 = new Thread(discoverer)).start(); } @@ -2740,4 +2772,20 @@ public class Desktop extends jalview.jbgui.GDesktop implements dialogPause = false; block.release(); } + @Override + protected void snapShotWindow_actionPerformed(ActionEvent e) + { + invalidate(); + File of; + ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.EPS, "View of Desktop", getWidth(), getHeight(), of=new File("Jalview_snapshot"+System.currentTimeMillis()+".eps"), "View of desktop"); + try { + paintAll(im.getGraphics()); + im.writeImage(); + } catch (Exception q) + { + Cache.log.error("Couldn't write snapshot to "+of.getAbsolutePath(),q); + return; + } + Cache.log.info("Successfully written snapshot to file "+of.getAbsolutePath()); + } }