JAL-1337 plugin flag to prevent Jalview from quitting the VM
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 28 Jun 2013 06:30:16 +0000 (07:30 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 28 Jun 2013 06:30:16 +0000 (07:30 +0100)
src/jalview/bin/Cache.java
src/jalview/gui/Desktop.java

index 5d26b85..43619f8 100755 (executable)
@@ -200,7 +200,15 @@ public class Cache
   static String propertiesFile;
 
   private static boolean propsAreReadOnly = false;
-
+  private static boolean plugin=false;
+  public static void setPlugin(boolean plugin)
+  {
+    Cache.plugin=plugin;
+  }
+  public static boolean isPlugin()
+  {
+    return plugin;
+  }
   public static void initLogger()
   {
     if (log != null)
index 877aebb..0a56da2 100644 (file)
@@ -283,7 +283,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     doGroovyCheck();
 
     setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION"));
-    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    setDefaultCloseOperation(!jalview.bin.Cache.isPlugin() ? JFrame.EXIT_ON_CLOSE : JFrame.DISPOSE_ON_CLOSE);
     boolean selmemusage = jalview.bin.Cache.getDefault("SHOW_MEMUSAGE",
             false);
     boolean showjconsole = jalview.bin.Cache.getDefault(
@@ -1054,7 +1054,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       dialogExecutor.shutdownNow();
     }
 
-    System.exit(0);
+    if (!jalview.bin.Cache.isPlugin()) {
+      System.exit(0);
+    } else {
+      setVisible(false);
+      dispose();
+    }
   }
 
   private void storeLastKnownDimensions(String string, Rectangle jc)