X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=b7057d17e11216a8b99c9bfe1f556f561a4e18dc;hb=d8ddf2968124b3518e567a91411357b1d291ff77;hp=322365c110acc473de63ee00468fa0fa7585c040;hpb=be7129c40859bc2434e59ad0a54149c99ea569ef;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 322365c..b7057d1 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1,19 +1,22 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) - * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle + * 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; @@ -23,6 +26,8 @@ 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; import java.awt.BorderLayout; @@ -557,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("Paste To New Window"); + JMenuItem item = new JMenuItem( + MessageManager.getString("label.paste_new_window")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) @@ -647,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; } @@ -805,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; @@ -853,6 +861,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } catch (Exception e) { + success = false; } if (files != null) @@ -881,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 } /** @@ -900,8 +912,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Open local file"); - chooser.setToolTipText("Open"); + chooser.setDialogTitle(MessageManager + .getString("label.open_local_file")); + chooser.setToolTipText(MessageManager.getString("action.open")); int value = chooser.showOpenDialog(this); @@ -912,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"; } @@ -943,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("Enter URL of Input File"); + JLabel label = new JLabel( + MessageManager.getString("label.input_file_url")); final JComboBox history = new JComboBox(); JPanel panel = new JPanel(new GridLayout(2, 1)); @@ -968,7 +983,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements } int reply = JOptionPane.showInternalConfirmDialog(desktop, panel, - "Input Alignment From URL", JOptionPane.OK_CANCEL_OPTION); + MessageManager.getString("label.input_alignment_from_url"), + JOptionPane.OK_CANCEL_OPTION); if (reply != JOptionPane.OK_OPTION) { @@ -1098,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") + ""); @@ -1145,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" @@ -1366,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()); @@ -1423,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"); @@ -1509,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(); @@ -1526,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; @@ -1711,7 +1731,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements 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(MessageManager + .getString("label.select_vamsas_session_opened_as_new_vamsas_session")); int value = chooser.showOpenDialog(this); @@ -1720,10 +1741,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements String fle = chooser.getSelectedFile().toString(); if (!vamsasImport(chooser.getSelectedFile())) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Couldn't import '" + fle + "' as a new vamsas session.", - "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); } } } @@ -1865,7 +1892,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements protected void setupVamsasConnectedGui() { - vamsasStart.setText("Session Update"); + vamsasStart.setText(MessageManager.getString("label.session_update")); vamsasSave.setVisible(true); vamsasStop.setVisible(true); vamsasImport.setVisible(false); // Document import to existing session is @@ -1877,7 +1904,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements vamsasSave.setVisible(false); vamsasStop.setVisible(false); vamsasImport.setVisible(true); - vamsasStart.setText("New Vamsas Session"); + vamsasStart.setText(MessageManager + .getString("label.new_vamsas_session")); } public void vamsasStop_actionPerformed(ActionEvent e) @@ -1913,7 +1941,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements { JMenuItem sessit = new JMenuItem(); sessit.setText(sess[i]); - sessit.setToolTipText("Connect to session " + 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() @@ -2135,10 +2165,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, + g.drawString(MessageManager.formatMessage( + "label.memory_stats", + new String[] + { df.format(totalFreeMemory), df.format(maxMemory), + df.format(percentUsage) }), 10, getHeight() - fm.getHeight()); } } @@ -2161,7 +2192,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (jalview.bin.Cache.groovyJarsPresent()) { groovyShell = new JMenuItem(); - groovyShell.setText("Groovy Console..."); + groovyShell.setText(MessageManager.getString("label.groovy_console")); groovyShell.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -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("Cancel"); + JButton cancel = new JButton( + MessageManager.getString("action.cancel")); final IProgressIndicator us = this; cancel.addActionListener(new ActionListener() { @@ -2436,38 +2468,43 @@ public class Desktop extends jalview.jbgui.GDesktop implements { boolean alive = true; Thread t0 = null, t1 = null, t2 = null; - - // 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 + // 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 (t0 = new Thread(discoverer)).start(); } - try + // ENFIN services are EOLed as of Jalview 2.8.1 release + if (false) { - if (Cache.getDefault("SHOW_ENFIN_SERVICES", true)) + try { - // EnfinEnvision web service menu entries are rebuild every time the - // menu is shown, so no changeSupport events are needed. - jalview.ws.EnfinEnvision2OneWay.getInstance(); - (t1 = new Thread(jalview.ws.EnfinEnvision2OneWay.getInstance())) - .start(); + 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. + jalview.ws.EnfinEnvision2OneWay.getInstance(); + (t1 = new Thread(jalview.ws.EnfinEnvision2OneWay.getInstance())) + .start(); + } + } catch (Exception e) + { + Cache.log + .info("Exception when trying to launch Envision2 workflow discovery.", + e); + Cache.log.info(e.getStackTrace()); } - } catch (Exception e) - { - Cache.log - .info("Exception when trying to launch Envision2 workflow discovery.", - e); - Cache.log.info(e.getStackTrace()); } + if (Cache.getDefault("SHOW_JWS2_SERVICES", true)) { if (jalview.ws.jws2.Jws2Discoverer.getDiscoverer().isRunning()) @@ -2735,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()); + } }