X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FDesktop.java;h=d6c25a857f162e3df1896a425568bb1405d18726;hb=f05332c8cc2a3a1d00a8dae38b8920ae799fb840;hp=9f028abbeefadba8047f1ada2bb8b4b02074c7f6;hpb=47168f025aefdaa044802bd5f8f510ffe43a4808;p=jalview.git
diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java
index 9f028ab..d6c25a8 100644
--- a/src/jalview/gui/Desktop.java
+++ b/src/jalview/gui/Desktop.java
@@ -1,6 +1,6 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
@@ -20,14 +20,32 @@
*/
package jalview.gui;
+import static jalview.util.UrlConstants.SEQUENCE_ID;
+
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
+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.structure.StructureSelectionManager;
+import jalview.urls.IdOrgSettings;
+import jalview.util.ImageMaker;
import jalview.util.MessageManager;
+import jalview.util.Platform;
+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;
@@ -38,6 +56,7 @@ import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
+import java.awt.Window;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
@@ -51,30 +70,35 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
-import java.lang.reflect.Constructor;
+import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.List;
+import java.util.ListIterator;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
+import javax.swing.AbstractAction;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
@@ -82,15 +106,17 @@ import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
+import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
-import javax.swing.event.HyperlinkEvent.EventType;
/**
* Jalview Desktop
@@ -103,6 +129,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
DropTargetListener, ClipboardOwner, IProgressIndicator,
jalview.api.StructureSelectionManagerProvider
{
+ private static int DEFAULT_MIN_WIDTH = 300;
+
+ private static int DEFAULT_MIN_HEIGHT = 250;
private JalviewChangeSupport changeSupport = new JalviewChangeSupport();
@@ -111,6 +140,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
*/
private BlogReader jvnews = null;
+ private File projectFile;
+
/**
* @param listener
* @see jalview.gui.JalviewChangeSupport#addJalviewPropertyChangeListener(java.beans.PropertyChangeListener)
@@ -175,6 +206,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
this.delegate = delegate;
}
+ @Override
public void activateFrame(JInternalFrame f)
{
try
@@ -187,31 +219,37 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
}
+ @Override
public void beginDraggingFrame(JComponent f)
{
delegate.beginDraggingFrame(f);
}
+ @Override
public void beginResizingFrame(JComponent f, int direction)
{
delegate.beginResizingFrame(f, direction);
}
+ @Override
public void closeFrame(JInternalFrame f)
{
delegate.closeFrame(f);
}
+ @Override
public void deactivateFrame(JInternalFrame f)
{
delegate.deactivateFrame(f);
}
+ @Override
public void deiconifyFrame(JInternalFrame f)
{
delegate.deiconifyFrame(f);
}
+ @Override
public void dragFrame(JComponent f, int newX, int newY)
{
if (newY < 0)
@@ -221,40 +259,46 @@ public class Desktop extends jalview.jbgui.GDesktop implements
delegate.dragFrame(f, newX, newY);
}
+ @Override
public void endDraggingFrame(JComponent f)
{
delegate.endDraggingFrame(f);
}
+ @Override
public void endResizingFrame(JComponent f)
{
delegate.endResizingFrame(f);
}
+ @Override
public void iconifyFrame(JInternalFrame f)
{
delegate.iconifyFrame(f);
}
+ @Override
public void maximizeFrame(JInternalFrame f)
{
delegate.maximizeFrame(f);
}
+ @Override
public void minimizeFrame(JInternalFrame f)
{
delegate.minimizeFrame(f);
}
+ @Override
public void openFrame(JInternalFrame f)
{
delegate.openFrame(f);
}
+ @Override
public void resizeFrame(JComponent f, int newX, int newY, int newWidth,
int newHeight)
{
- Rectangle b = desktop.getBounds();
if (newY < 0)
{
newY = 0;
@@ -262,6 +306,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
delegate.resizeFrame(f, newX, newY, newWidth, newHeight);
}
+ @Override
public void setBoundsForFrame(JComponent f, int newX, int newY,
int newWidth, int newHeight)
{
@@ -284,8 +329,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements
*/
instance = this;
doVamsasClientCheck();
- doGroovyCheck();
+ groovyShell = new JMenuItem();
+ groovyShell.setText(MessageManager.getString("label.groovy_console"));
+ groovyShell.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ groovyShell_actionPerformed();
+ }
+ });
+ toolsMenu.add(groovyShell);
+ groovyShell.setVisible(true);
+
+ doConfigureStructurePrefs();
setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
@@ -293,6 +351,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
boolean showjconsole = jalview.bin.Cache.getDefault(
"SHOW_JAVA_CONSOLE", false);
desktop = new MyDesktopPane(selmemusage);
+ if (Platform.isAMac())
+ {
+ desktop.setDoubleBuffered(false);
+ }
showMemusage.setSelected(selmemusage);
desktop.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
@@ -316,14 +378,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements
else
{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- setBounds((int) (screenSize.width - 900) / 2,
- (int) (screenSize.height - 650) / 2, 900, 650);
+ setBounds((screenSize.width - 900) / 2,
+ (screenSize.height - 650) / 2, 900, 650);
}
jconsole = new Console(this, showjconsole);
// add essential build information
- jconsole.setHeader("Jalview Desktop "
+ jconsole.setHeader("Jalview Version: "
+ jalview.bin.Cache.getProperty("VERSION") + "\n"
- + "Build Date: "
+ + "Jalview Installation: "
+ + jalview.bin.Cache.getDefault("INSTALLATION", "unknown")
+ + "\n" + "Build Date: "
+ jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") + "\n"
+ "Java version: " + System.getProperty("java.version") + "\n"
+ System.getProperty("os.arch") + " "
@@ -334,8 +398,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements
showNews.setVisible(false);
+ getIdentifiersOrgData();
+
+ checkURLLinks();
+
this.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent evt)
{
quit();
@@ -345,9 +414,19 @@ public class Desktop extends jalview.jbgui.GDesktop implements
MouseAdapter ma;
this.addMouseListener(ma = new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent evt)
{
- if (SwingUtilities.isRightMouseButton(evt))
+ if (evt.isPopupTrigger()) // Mac
+ {
+ showPasteMenu(evt.getX(), evt.getY());
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
{
showPasteMenu(evt.getX(), evt.getY());
}
@@ -377,25 +456,24 @@ public class Desktop extends jalview.jbgui.GDesktop implements
// Spawn a thread that shows the splashscreen
SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
new SplashScreen();
}
});
- // displayed.
// Thread off a new instance of the file chooser - this reduces the time it
// takes to open it later on.
new Thread(new Runnable()
{
+ @Override
public void run()
{
Cache.log.debug("Filechooser init thread started.");
- 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"));
+ String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
+ JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
+ fileFormat);
Cache.log.debug("Filechooser init thread finished.");
}
}).start();
@@ -415,6 +493,28 @@ public class Desktop extends jalview.jbgui.GDesktop implements
});
}
+ public void doConfigureStructurePrefs()
+ {
+ // configure services
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
+ if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
+ {
+ ssm.setAddTempFacAnnot(jalview.bin.Cache.getDefault(
+ Preferences.ADD_TEMPFACT_ANN, true));
+ ssm.setProcessSecondaryStructure(jalview.bin.Cache.getDefault(
+ Preferences.STRUCT_FROM_PDB, true));
+ ssm.setSecStructServices(jalview.bin.Cache.getDefault(
+ Preferences.USE_RNAVIEW, true));
+ }
+ else
+ {
+ ssm.setAddTempFacAnnot(false);
+ ssm.setProcessSecondaryStructure(false);
+ ssm.setSecStructServices(false);
+ }
+ }
+
public void checkForNews()
{
final Desktop me = this;
@@ -433,6 +533,30 @@ public class Desktop extends jalview.jbgui.GDesktop implements
});
}
+ public void getIdentifiersOrgData()
+ {
+ // Thread off the identifiers fetcher
+ addDialogThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ Cache.log.debug("Downloading data from identifiers.org");
+ UrlDownloadClient client = new UrlDownloadClient();
+ try
+ {
+ client.download(IdOrgSettings.getUrl(),
+ IdOrgSettings.getDownloadLocation());
+ } catch (IOException e)
+ {
+ Cache.log.debug("Exception downloading identifiers.org data"
+ + e.getMessage());
+ }
+ }
+ });
+ }
+
+ @Override
protected void showNews_actionPerformed(ActionEvent e)
{
showNews(showNews.isSelected());
@@ -450,10 +574,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
@Override
public void run()
{
- long instance = System.currentTimeMillis();
- Desktop.instance.setProgressBar("Refreshing news", instance);
+ long now = System.currentTimeMillis();
+ Desktop.instance.setProgressBar(
+ MessageManager.getString("status.refreshing_news"), now);
jvnews.refreshNews();
- Desktop.instance.setProgressBar(null, instance);
+ Desktop.instance.setProgressBar(null, now);
jvnews.showNews();
}
}).start();
@@ -535,16 +660,19 @@ public class Desktop extends jalview.jbgui.GDesktop implements
// reselected again.
boolean refresh = true;
+ @Override
public void menuCanceled(MenuEvent e)
{
refresh = true;
}
+ @Override
public void menuDeselected(MenuEvent e)
{
refresh = true;
}
+ @Override
public void menuSelected(MenuEvent e)
{
if (refresh)
@@ -561,9 +689,11 @@ 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()
{
+ @Override
public void actionPerformed(ActionEvent evt)
{
paste();
@@ -586,10 +716,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
String file = (String) contents
.getTransferData(DataFlavor.stringFlavor);
- String format = new IdentifyFile().Identify(file,
- FormatAdapter.PASTE);
+ FileFormatI format = new IdentifyFile().identify(file,
+ DataSourceType.PASTE);
- new FileLoader().LoadFile(file, FormatAdapter.PASTE, format);
+ new FileLoader().LoadFile(file, DataSourceType.PASTE, format);
}
} catch (Exception ex)
@@ -604,38 +734,84 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* Adds and opens the given frame to the desktop
*
* @param frame
- * DOCUMENT ME!
+ * Frame to show
* @param title
- * DOCUMENT ME!
+ * Visible Title
* @param w
- * DOCUMENT ME!
+ * width
* @param h
- * DOCUMENT ME!
+ * height
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, int w, int h)
{
- addInternalFrame(frame, title, w, h, true);
+ addInternalFrame(frame, title, true, w, h, true);
}
/**
- * DOCUMENT ME!
+ * Add an internal frame to the Jalview desktop
*
* @param frame
- * DOCUMENT ME!
+ * Frame to show
* @param title
- * DOCUMENT ME!
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
* @param w
- * DOCUMENT ME!
+ * width
* @param h
- * DOCUMENT ME!
+ * height
+ */
+ public static synchronized void addInternalFrame(
+ final JInternalFrame frame, String title, boolean makeVisible,
+ int w, int h)
+ {
+ addInternalFrame(frame, title, makeVisible, w, h, true);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop and make it visible
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param w
+ * width
+ * @param h
+ * height
* @param resizable
- * DOCUMENT ME!
+ * Allow resize
*/
public static synchronized void addInternalFrame(
final JInternalFrame frame, String title, int w, int h,
boolean resizable)
{
+ addInternalFrame(frame, title, true, w, h, resizable);
+ }
+
+ /**
+ * Add an internal frame to the Jalview desktop
+ *
+ * @param frame
+ * Frame to show
+ * @param title
+ * Visible Title
+ * @param makeVisible
+ * When true, display frame immediately, otherwise, caller must call
+ * setVisible themselves.
+ * @param w
+ * width
+ * @param h
+ * height
+ * @param resizable
+ * Allow resize
+ */
+ public static synchronized void addInternalFrame(
+ final JInternalFrame frame, String title, boolean makeVisible,
+ int w, int h, boolean resizable)
+ {
// TODO: allow callers to determine X and Y position of frame (eg. via
// bounds object).
@@ -651,51 +827,82 @@ 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;
}
openFrameCount++;
- frame.setVisible(true);
+ frame.setMinimumSize(new Dimension(DEFAULT_MIN_WIDTH,
+ DEFAULT_MIN_HEIGHT));
+ frame.setVisible(makeVisible);
frame.setClosable(true);
frame.setResizable(resizable);
frame.setMaximizable(resizable);
frame.setIconifiable(resizable);
- frame.setFrameIcon(null);
-
+ if (Platform.isAMac())
+ {
+ frame.setIconifiable(false);
+ frame.setFrameIcon(null);
+ // frame.setDesktopIcon(null);
+ frame.setDoubleBuffered(false);
+ }
if (frame.getX() < 1 && frame.getY() < 1)
{
frame.setLocation(xOffset * openFrameCount, yOffset
* ((openFrameCount - 1) % 10) + yOffset);
}
+ /*
+ * add an entry for the new frame in the Window menu
+ * (and remove it when the frame is closed)
+ */
final JMenuItem menuItem = new JMenuItem(title);
- frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+ frame.addInternalFrameListener(new InternalFrameAdapter()
{
- public void internalFrameActivated(
- javax.swing.event.InternalFrameEvent evt)
+ @Override
+ public void internalFrameActivated(InternalFrameEvent evt)
{
JInternalFrame itf = desktop.getSelectedFrame();
if (itf != null)
{
itf.requestFocus();
}
-
}
- public void internalFrameClosed(
- javax.swing.event.InternalFrameEvent evt)
+ @Override
+ public void internalFrameClosed(InternalFrameEvent evt)
{
PaintRefresher.RemoveComponent(frame);
- openFrameCount--;
+
+ /*
+ * defensive check to prevent frames being
+ * added half off the window
+ */
+ if (openFrameCount > 0)
+ {
+ openFrameCount--;
+ }
+
+ /*
+ * ensure no reference to alignFrame retained by menu item listener
+ */
+ if (menuItem.getActionListeners().length > 0)
+ {
+ menuItem.removeActionListener(menuItem.getActionListeners()[0]);
+ }
windowMenu.remove(menuItem);
JInternalFrame itf = desktop.getSelectedFrame();
if (itf != null)
{
itf.requestFocus();
+ if (itf instanceof AlignFrame)
+ {
+ Jalview.setCurrentAlignFrame((AlignFrame) itf);
+ }
}
System.gc();
};
@@ -703,6 +910,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
menuItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
try
@@ -715,51 +923,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
}
});
- menuItem.addMouseListener(new MouseListener()
- {
-
- @Override
- public void mouseReleased(MouseEvent e)
- {
- }
-
- @Override
- public void mousePressed(MouseEvent e)
- {
- }
- @Override
- public void mouseExited(MouseEvent e)
- {
- try
- {
- frame.setSelected(false);
- } catch (PropertyVetoException e1)
- {
- }
- }
-
- @Override
- public void mouseEntered(MouseEvent e)
- {
- try
- {
- frame.setSelected(true);
- } catch (PropertyVetoException e1)
- {
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e)
- {
-
- }
- });
+ desktop.add(frame);
windowMenu.add(menuItem);
- desktop.add(frame);
frame.toFront();
try
{
@@ -775,6 +943,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
}
+ @Override
public void lostOwnership(Clipboard clipboard, Transferable contents)
{
if (!internalCopy)
@@ -785,18 +954,22 @@ public class Desktop extends jalview.jbgui.GDesktop implements
internalCopy = false;
}
+ @Override
public void dragEnter(DropTargetDragEvent evt)
{
}
+ @Override
public void dragExit(DropTargetEvent evt)
{
}
+ @Override
public void dragOver(DropTargetDragEvent evt)
{
}
+ @Override
public void dropActionChanged(DropTargetDragEvent evt)
{
}
@@ -807,58 +980,24 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @param evt
* DOCUMENT ME!
*/
+ @Override
public void drop(DropTargetDropEvent evt)
{
- boolean success=true;
+ boolean success = true;
+ // JAL-1552 - acceptDrop required before getTransferable call for
+ // Java's Transferable for native dnd
+ evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = evt.getTransferable();
- java.util.List files = null;
- java.util.List protocols = null;
+ List It may be that you have invalid JABA URLsVersion: "
- + jalview.bin.Cache.getProperty("VERSION")
- + "
");
+ + jalview.bin.Cache.getProperty("VERSION") + "");
message.append("Last Updated: "
+ jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")
+ "");
@@ -1152,12 +1329,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:"
+ .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"
@@ -1171,24 +1347,21 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @param e
* DOCUMENT ME!
*/
+ @Override
public void documentationMenuItem_actionPerformed(ActionEvent e)
{
try
{
- ClassLoader cl = jalview.gui.Desktop.class.getClassLoader();
- java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help");
- javax.help.HelpSet hs = new javax.help.HelpSet(cl, url);
-
- javax.help.HelpBroker hb = hs.createHelpBroker();
- hb.setCurrentID("home");
- hb.setDisplayed(true);
+ Help.showHelpWindow();
} catch (Exception ex)
{
}
}
+ @Override
public void closeAll_actionPerformed(ActionEvent e)
{
+ // TODO show a progress bar while closing?
JInternalFrame[] frames = desktop.getAllFrames();
for (int i = 0; i < frames.length; i++)
{
@@ -1199,19 +1372,33 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
}
}
+ Jalview.setCurrentAlignFrame(null);
System.out.println("ALL CLOSED");
if (v_client != null)
{
// TODO clear binding to vamsas document objects on close_all
+ }
+ /*
+ * reset state of singleton objects as appropriate (clear down session state
+ * when all windows are closed)
+ */
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
+ if (ssm != null)
+ {
+ ssm.resetAll();
}
+ System.gc();
}
+ @Override
public void raiseRelated_actionPerformed(ActionEvent e)
{
reorderAssociatedWindows(false, false);
}
+ @Override
public void minimizeAssociated_actionPerformed(ActionEvent e)
{
reorderAssociatedWindows(true, false);
@@ -1228,6 +1415,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @seejalview.jbgui.GDesktop#garbageCollect_actionPerformed(java.awt.event.
* ActionEvent)
*/
+ @Override
protected void garbageCollect_actionPerformed(ActionEvent e)
{
// We simply collect the garbage
@@ -1243,6 +1431,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.ActionEvent
* )
*/
+ @Override
protected void showMemusage_actionPerformed(ActionEvent e)
{
desktop.showMemoryUsage(showMemusage.isSelected());
@@ -1255,6 +1444,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* jalview.jbgui.GDesktop#showConsole_actionPerformed(java.awt.event.ActionEvent
* )
*/
+ @Override
protected void showConsole_actionPerformed(ActionEvent e)
{
showConsole(showConsole.isSelected());
@@ -1284,7 +1474,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
return;
}
- AlignViewport source = null, target = null;
+ AlignmentViewport source = null, target = null;
if (frames[0] instanceof AlignFrame)
{
source = ((AlignFrame) frames[0]).getCurrentView();
@@ -1359,6 +1549,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void preferences_actionPerformed(ActionEvent e)
{
new Preferences();
@@ -1370,15 +1561,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements
* @param e
* DOCUMENT ME!
*/
+ @Override
public void saveState_actionPerformed(ActionEvent e)
{
- JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jvp" }, new String[]
- { "Jalview Project" }, "Jalview Project");
+ JalviewFileChooser chooser = new JalviewFileChooser("jvp",
+ "Jalview Project");
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Save State");
+ chooser.setDialogTitle(MessageManager.getString("label.save_state"));
int value = chooser.showSaveDialog(this);
@@ -1386,20 +1576,24 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
final Desktop me = this;
final java.io.File choice = chooser.getSelectedFile();
+ setProjectFile(choice);
+
new Thread(new Runnable()
{
+ @Override
public void run()
{
-
- setProgressBar("Saving jalview project " + choice.getName(),
- choice.hashCode());
+ // TODO: refactor to Jalview desktop session controller action.
+ setProgressBar(MessageManager.formatMessage(
+ "label.saving_jalview_project",
+ new Object[] { choice.getName() }), choice.hashCode());
jalview.bin.Cache.setProperty("LAST_DIRECTORY",
choice.getParent());
// TODO catch and handle errors for savestate
// TODO prevent user from messing with the Desktop whilst we're saving
try
{
- new Jalview2XML().SaveState(choice);
+ new Jalview2XML().saveState(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst saving current state to "
@@ -1409,11 +1603,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
Cache.log.error(
"Problems whilst trying to save to " + choice.getName(),
ex);
- JOptionPane.showMessageDialog(
- me,
- "Error whilst saving current state to "
- + choice.getName(), "Couldn't save project",
- JOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showMessageDialog(me, MessageManager.formatMessage(
+ "label.error_whilst_saving_current_state_to",
+ new Object[] { choice.getName() }), MessageManager
+ .getString("label.couldnt_save_project"),
+ JvOptionPane.WARNING_MESSAGE);
}
setProgressBar(null, choice.hashCode());
}
@@ -1421,37 +1615,53 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
}
+ private void setProjectFile(File choice)
+ {
+ this.projectFile = choice;
+ }
+
+ public File getProjectFile()
+ {
+ return this.projectFile;
+ }
+
/**
* DOCUMENT ME!
*
* @param e
* DOCUMENT ME!
*/
+ @Override
public void loadState_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "jvp","jar" }, new String[]
- { "Jalview Project", "Jalview Project (old)" }, "Jalview Project");
+ Cache.getProperty("LAST_DIRECTORY"), new String[] {
+ "jvp", "jar" }, new String[] { "Jalview Project",
+ "Jalview Project (old)" }, "Jalview Project");
chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Restore state");
+ chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
int value = chooser.showOpenDialog(this);
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- final String choice = chooser.getSelectedFile().getAbsolutePath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
- .getSelectedFile().getParent());
+ final File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ final String choice = selectedFile.getAbsolutePath();
+ Cache.setProperty("LAST_DIRECTORY",
+ selectedFile.getParent());
new Thread(new Runnable()
{
+ @Override
public void run()
{
- setProgressBar("loading jalview project " + choice,
- choice.hashCode());
+ setProgressBar(
+ MessageManager.formatMessage(
+ "label.loading_jalview_project",
+ new Object[] { choice }), choice.hashCode());
try
{
- new Jalview2XML().LoadJalviewAlign(choice);
+ new Jalview2XML().loadJalviewAlign(choice);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Whilst loading project from " + choice, oom);
@@ -1459,9 +1669,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
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);
+ JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
+ .formatMessage(
+ "label.error_whilst_loading_project_from",
+ new Object[] { choice }), MessageManager
+ .getString("label.couldnt_load_project"),
+ JvOptionPane.WARNING_MESSAGE);
}
setProgressBar(null, choice.hashCode());
}
@@ -1469,6 +1682,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
}
}
+ @Override
public void inputSequence_actionPerformed(ActionEvent e)
{
new SequenceFetcher(this);
@@ -1482,8 +1696,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
if (fileLoadingCount == 0)
{
- fileLoadingPanels.add(addProgressPanel("Loading File: " + fileName
- + " "));
+ fileLoadingPanels.add(addProgressPanel(MessageManager.formatMessage(
+ "label.loading_file", new Object[] { fileName })));
}
fileLoadingCount++;
}
@@ -1517,15 +1731,16 @@ public class Desktop extends jalview.jbgui.GDesktop implements
{
if (progressPanel != null)
{
- synchronized(progressPanel) {
- 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();
@@ -1536,7 +1751,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
fileLoadingCount--;
if (fileLoadingCount < 1)
{
- while (fileLoadingPanels.size()>0)
+ while (fileLoadingPanels.size() > 0)
{
removeProgressPanel(fileLoadingPanels.remove(0));
}
@@ -1548,38 +1763,38 @@ public class Desktop extends jalview.jbgui.GDesktop implements
public static int getViewCount(String alignmentId)
{
- AlignViewport[] aps = getViewports(alignmentId);
+ AlignmentViewport[] aps = getViewports(alignmentId);
return (aps == null) ? 0 : aps.length;
}
/**
*
* @param alignmentId
+ * - if null, all sets are returned
* @return all AlignmentPanels concerning the alignmentId sequence set
*/
public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
{
- int count = 0;
if (Desktop.desktop == null)
{
// no frames created and in headless mode
// TODO: verify that frames are recoverable when in headless mode
return null;
}
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
- ArrayList aps = new ArrayList();
- for (int t = 0; t < frames.length; t++)
+ List
in your web service preferences,"
- + " or mis-configured HTTP proxy settings.
or as a command-line argument, or mis-configured HTTP proxy settings.
Check the Connections and Web services tab
of the"
+ " Tools->Preferences dialog box to change them.