X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=ed968f89b942ea534c9daaeede74e8dc890e8ddb;hb=ccc0d91abe38690088a6050faba8ef66cde1f271;hp=fb2c65f76959d2764e4bacd49102e1d702dd40ad;hpb=e42d3ebcc571ec3fd765de7ceccd8d125e70002f;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index fb2c65f..ed968f8 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -45,8 +45,8 @@ public class Desktop //Need to decide if the Memory Usage is to be included in //Next release or not. - // public static MyDesktopPane desktop; - public static JDesktopPane desktop; + public static MyDesktopPane desktop; + // public static JDesktopPane desktop; static int openFrameCount = 0; @@ -64,6 +64,11 @@ public class Desktop */ public Desktop() { + /** + * A note to implementors. It is ESSENTIAL that any + * activities that might block are spawned off as threads rather + * than waited for during this constructor. + */ instance = this; doVamsasClientCheck(); doGroovyCheck(); @@ -71,8 +76,9 @@ public class Desktop setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - desktop = new JDesktopPane(); + boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",false); + desktop = new MyDesktopPane(selmemusage); + showMemusage.setSelected(selmemusage); desktop.setBackground(Color.white); getContentPane().setLayout(new BorderLayout()); getContentPane().add(desktop, BorderLayout.CENTER); @@ -120,10 +126,9 @@ public class Desktop this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); + // Spawn a thread that shows the splashscreen + new SplashScreen(); - /////////Add a splashscreen on startup - /////////Add a splashscreen on startup - new SplashScreen(); discoverer = new jalview.ws.Discoverer(); // Only gets started if gui is displayed. @@ -663,6 +668,25 @@ public class Desktop reorderAssociatedWindows(false, true); } + /* (non-Javadoc) + * @see jalview.jbgui.GDesktop#garbageCollect_actionPerformed(java.awt.event.ActionEvent) + */ + protected void garbageCollect_actionPerformed(ActionEvent e) + { + // We simply collect the garbage + jalview.bin.Cache.log.debug("Collecting garbage..."); + System.gc(); + jalview.bin.Cache.log.debug("Finished garbage collection."); + } + + /* (non-Javadoc) + * @see jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.ActionEvent) + */ + protected void showMemusage_actionPerformed(ActionEvent e) + { + desktop.showMemoryUsage(showMemusage.isSelected()); + } + void reorderAssociatedWindows(boolean minimize, boolean close) { JInternalFrame[] frames = desktop.getAllFrames(); @@ -739,7 +763,6 @@ public class Desktop } } } - /** * DOCUMENT ME! * @@ -1198,12 +1221,18 @@ public class Desktop public void checkForQuestionnaire(String url) { UserQuestionnaireCheck jvq = new UserQuestionnaireCheck(url); - javax.swing.SwingUtilities.invokeLater(jvq); + //javax.swing.SwingUtilities.invokeLater(jvq); + new Thread(jvq).start(); } - - /*DISABLED - class MyDesktopPane extends JDesktopPane implements Runnable + /** + * Proxy class for JDesktopPane which optionally + * displays the current memory usage and highlights + * the desktop area with a red bar if free memory runs low. + * @author AMW + */ + public class MyDesktopPane extends JDesktopPane implements Runnable { + boolean showMemoryUsage = false; Runtime runtime; java.text.NumberFormat df; @@ -1224,7 +1253,10 @@ public class Desktop worker.start(); } } - + public boolean isShowMemoryUsage() + { + return showMemoryUsage; + } public void run() { df = java.text.NumberFormat.getNumberInstance(); @@ -1271,13 +1303,16 @@ public class Desktop getHeight() - g.getFontMetrics().getHeight()); } } - }*/ + + + + } protected JMenuItem groovyShell; public void doGroovyCheck() { if (jalview.bin.Cache.groovyJarsPresent()) { groovyShell = new JMenuItem(); - groovyShell.setText("Groovy Shell..."); + groovyShell.setText("Groovy Console..."); groovyShell.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -1292,7 +1327,7 @@ public class Desktop * Accessor method to quickly get all the AlignmentFrames * loaded. */ - protected AlignFrame[] getAlignframes() { + public static AlignFrame[] getAlignframes() { JInternalFrame[] frames = Desktop.desktop.getAllFrames(); if (frames == null)