X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=1b85dd5c0261dd949faddd021b782f2a60f19713;hb=51b0b157926ed477cb558ca5971126bf9fccbd31;hp=5800a471cf3c201f5fa888e7c355bec9f4a946c2;hpb=17e4ea278bc9a5fb280db1252ce78b7a295215f5;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 5800a47..1b85dd5 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -20,37 +20,6 @@ */ package jalview.gui; -import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.bin.Cache; -import jalview.bin.Jalview; -import jalview.gui.ImageExporter.ImageWriterI; -import jalview.io.BackupFiles; -import jalview.io.DataSourceType; -import jalview.io.FileFormat; -import jalview.io.FileFormatException; -import jalview.io.FileFormatI; -import jalview.io.FileFormats; -import jalview.io.FileLoader; -import jalview.io.FormatAdapter; -import jalview.io.IdentifyFile; -import jalview.io.JalviewFileChooser; -import jalview.io.JalviewFileView; -import jalview.jbgui.GSplitFrame; -import jalview.jbgui.GStructureViewer; -import jalview.project.Jalview2XML; -import jalview.structure.StructureSelectionManager; -import jalview.urls.IdOrgSettings; -import jalview.util.BrowserLauncher; -import jalview.util.ImageMaker.TYPE; -import jalview.util.MessageManager; -import jalview.util.Platform; -import jalview.util.ShortcutKeyMaskExWrapper; -import jalview.util.UrlConstants; -import jalview.viewmodel.AlignmentViewport; -import jalview.ws.params.ParamManager; -import jalview.ws.utils.UrlDownloadClient; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -123,6 +92,37 @@ import javax.swing.event.InternalFrameEvent; import org.stackoverflowusers.file.WindowsShortcut; +import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; +import jalview.bin.Cache; +import jalview.bin.Jalview; +import jalview.gui.ImageExporter.ImageWriterI; +import jalview.io.BackupFiles; +import jalview.io.DataSourceType; +import jalview.io.FileFormat; +import jalview.io.FileFormatException; +import jalview.io.FileFormatI; +import jalview.io.FileFormats; +import jalview.io.FileLoader; +import jalview.io.FormatAdapter; +import jalview.io.IdentifyFile; +import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; +import jalview.jbgui.GSplitFrame; +import jalview.jbgui.GStructureViewer; +import jalview.project.Jalview2XML; +import jalview.structure.StructureSelectionManager; +import jalview.urls.IdOrgSettings; +import jalview.util.BrowserLauncher; +import jalview.util.ImageMaker.TYPE; +import jalview.util.MessageManager; +import jalview.util.Platform; +import jalview.util.ShortcutKeyMaskExWrapper; +import jalview.util.UrlConstants; +import jalview.viewmodel.AlignmentViewport; +import jalview.ws.params.ParamManager; +import jalview.ws.utils.UrlDownloadClient; + /** * Jalview Desktop * @@ -134,6 +134,15 @@ public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener, ClipboardOwner, IProgressIndicator, jalview.api.StructureSelectionManagerProvider { + private static final String CITATION = "

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"; + + private static final String DEFAULT_AUTHORS = "The Jalview Authors (See AUTHORS file for current list)"; + private static int DEFAULT_MIN_WIDTH = 300; private static int DEFAULT_MIN_HEIGHT = 250; @@ -146,7 +155,7 @@ public class Desktop extends jalview.jbgui.GDesktop protected static final String CONFIRM_KEYBOARD_QUIT = "CONFIRM_KEYBOARD_QUIT"; - public static HashMap savingFiles = new HashMap<>(); + public static HashMap savingFiles = new HashMap(); private JalviewChangeSupport changeSupport = new JalviewChangeSupport(); @@ -195,6 +204,16 @@ public class Desktop extends jalview.jbgui.GDesktop /** Singleton Desktop instance */ public static Desktop instance; + /** + * BH TEMPORARY ONLY -- should use ApplicationSingleton + * + * @return + */ + public static Desktop getInstance() + { + return instance; + } + public static MyDesktopPane desktop; public static MyDesktopPane getDesktop() @@ -370,17 +389,12 @@ public class Desktop extends jalview.jbgui.GDesktop try { APQHandlers.setAPQHandlers(this); - } catch (Exception e) - { - System.out.println("Cannot set APQHandlers"); - // e.printStackTrace(); } catch (Throwable t) { - System.out.println("Cannot set APQHandlers"); + System.out.println("Error setting APQHandlers: " + t.toString()); // t.printStackTrace(); } - addWindowListener(new WindowAdapter() { @@ -445,20 +459,8 @@ public class Desktop extends jalview.jbgui.GDesktop * @j2sIgnore */ { - jconsole = new Console(this, showjconsole); - // add essential build information - jconsole.setHeader("Jalview Version: " - + Cache.getProperty("VERSION") + "\n" - + "Jalview Installation: " - + Cache.getDefault("INSTALLATION", "unknown") - + "\n" + "Build Date: " - + Cache.getDefault("BUILD_DATE", "unknown") + "\n" - + "Java version: " + System.getProperty("java.version") + "\n" - + System.getProperty("os.arch") + " " - + System.getProperty("os.name") + " " - + System.getProperty("os.version")); - + jconsole.setHeader(Cache.getVersionDetailsForConsole()); showConsole(showjconsole); showNews.setVisible(false); @@ -476,7 +478,7 @@ public class Desktop extends jalview.jbgui.GDesktop @Override public void run() { - new SplashScreen(); + new SplashScreen(true); } }); @@ -879,8 +881,8 @@ public class Desktop extends jalview.jbgui.GDesktop frame.setMaximizable(resizable); frame.setIconifiable(resizable); frame.setOpaque(Platform.isJS()); - - if (frame.getX() < 1 && frame.getY() < 1) + boolean isEmbedded = (Platform.getDimIfEmbedded(frame, -1, -1) != null); + if (!isEmbedded && frame.getX() < 1 && frame.getY() < 1) { frame.setLocation(xOffset * openFrameCount, yOffset * ((openFrameCount - 1) % 10) + yOffset); @@ -1351,52 +1353,40 @@ public class Desktop extends jalview.jbgui.GDesktop @Override public void aboutMenuItem_actionPerformed(ActionEvent e) { - // StringBuffer message = getAboutMessage(false); - // JvOptionPane.showInternalMessageDialog(Desktop.desktop, - // - // message.toString(), "About Jalview", JvOptionPane.INFORMATION_MESSAGE); new Thread(new Runnable() { @Override public void run() { - new SplashScreen(true); + new SplashScreen(false); } }).start(); } - public StringBuffer getAboutMessage(boolean shortv) + /** + * Returns the html text for the About screen, including any available version + * number, build details, author details and citation reference, but without + * the enclosing {@code html} tags + * + * @return + */ + public String getAboutMessage() { - StringBuffer message = new StringBuffer(); - message.append(""); - if (shortv) - { - message.append("

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

"); - message.append("Built: " - + Cache.getDefault("BUILD_DATE", "unknown") + " from " - + Cache.getBuildDetailsForSplash() - + ""); + StringBuilder message = new StringBuilder(1024); + message.append("

Version: ") + .append(Cache.getProperty("VERSION")).append("

") + .append("Built: ") + .append(Cache.getDefault("BUILD_DATE", "unknown")) + .append(" from ").append(Cache.getBuildDetailsForSplash()) + .append(""); - } - else - { - - message.append("Version " - + Cache.getProperty("VERSION") - + "; last updated: " - + Cache.getDefault("BUILD_DATE", "unknown")); - } - - if (Cache.getDefault("LATEST_VERSION", "Checking") - .equals("Checking")) + String latestVersion = Cache.getDefault("LATEST_VERSION", "Checking"); + if (latestVersion.equals("Checking")) { // JBP removed this message for 2.11: May be reinstated in future version // message.append("
...Checking latest version...
"); } - else if (!Cache.getDefault("LATEST_VERSION", "Checking") - .equals(Cache.getProperty("VERSION"))) + else if (!latestVersion.equals(Cache.getProperty("VERSION"))) { boolean red = false; if (Cache.getProperty("VERSION").toLowerCase() @@ -1408,29 +1398,22 @@ public class Desktop extends jalview.jbgui.GDesktop message.append("
"); } - message.append("
!! Version " - + Cache.getDefault("LATEST_VERSION", - "..Checking..") - + " is available for download from " - + Cache.getDefault("www.jalview.org", - "http://www.jalview.org") - + " !!"); + message.append("
!! Version ") + .append(Cache.getDefault("LATEST_VERSION", "..Checking..")) + .append(" is available for download from ") + .append(Cache.getDefault("www.jalview.org", + "http://www.jalview.org")) + .append(" !!"); if (red) { message.append("
"); } } - message.append("
Authors: " + Cache.getDefault( - "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" - + ""); - return message; + message.append("
Authors: "); + message.append(Cache.getDefault("AUTHORFNAMES", DEFAULT_AUTHORS)); + message.append(CITATION); + + return message.toString(); } /** @@ -1794,7 +1777,7 @@ public class Desktop extends jalview.jbgui.GDesktop { try { - new Jalview2XML().loadJalviewAlign(choice); + new Jalview2XML().loadJalviewAlign(selectedFile); } catch (OutOfMemoryError oom) { new OOMWarning("Whilst loading project from " + choice, oom); @@ -2001,11 +1984,28 @@ public class Desktop extends jalview.jbgui.GDesktop return; } + // FIXME: ideally should use UI interface API + FeatureSettings viewFeatureSettings = (af.featureSettings != null + && af.featureSettings.isOpen()) + ? af.featureSettings + : null; + Rectangle fsBounds = af.getFeatureSettingsGeometry(); for (int i = 0; i < size; i++) { AlignmentPanel ap = af.alignPanels.get(i); + AlignFrame newaf = new AlignFrame(ap); + // transfer reference for existing feature settings to new alignFrame + if (ap == af.alignPanel) + { + if (viewFeatureSettings != null && viewFeatureSettings.fr.ap == ap) + { + newaf.featureSettings = viewFeatureSettings; + } + newaf.setFeatureSettingsGeometry(fsBounds); + } + /* * Restore the view's last exploded frame geometry if known. Multiple * views from one exploded frame share and restore the same (frame) @@ -2021,8 +2021,17 @@ public class Desktop extends jalview.jbgui.GDesktop addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + // and materialise a new feature settings dialog instance for the new alignframe + // (closes the old as if 'OK' was pressed) + if (ap == af.alignPanel && newaf.featureSettings != null + && newaf.featureSettings.isOpen() + && af.alignPanel.getAlignViewport().isShowSequenceFeatures()) + { + newaf.showFeatureSettingsUI(); + } } + af.featureSettings = null; af.alignPanels.clear(); af.closeMenuItem_actionPerformed(true); @@ -2042,7 +2051,6 @@ public class Desktop extends jalview.jbgui.GDesktop source.viewport.setExplodedGeometry(source.getBounds()); JInternalFrame[] frames = desktop.getAllFrames(); String viewId = source.viewport.getSequenceSetId(); - for (int t = 0; t < frames.length; t++) { if (frames[t] instanceof AlignFrame && frames[t] != source) @@ -2063,11 +2071,33 @@ public class Desktop extends jalview.jbgui.GDesktop if (gatherThis) { + if (af.featureSettings != null && af.featureSettings.isOpen()) + { + if (source.featureSettings == null) + { + // preserve the feature settings geometry for this frame + source.featureSettings = af.featureSettings; + source.setFeatureSettingsGeometry( + af.getFeatureSettingsGeometry()); + } + else + { + // close it and forget + af.featureSettings.close(); + } + } af.alignPanels.clear(); af.closeMenuItem_actionPerformed(true); } } } + + // refresh the feature setting UI for the source frame if it exists + if (source.featureSettings != null + && source.featureSettings.isOpen()) + { + source.showFeatureSettingsUI(); + } } public JInternalFrame[] getAllFrames() @@ -2469,7 +2499,7 @@ public class Desktop extends jalview.jbgui.GDesktop @Override public void setProgressBar(String message, long id) { - Platform.timeCheck("Desktop " + message, Platform.TIME_MARK); + // Platform.timeCheck("Desktop " + message, Platform.TIME_MARK); if (progressBars == null) { @@ -3344,4 +3374,5 @@ public class Desktop extends jalview.jbgui.GDesktop } return result; } + }