X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=3d3e99f63e36932397444462666b07492bcf87fb;hb=072176426bbe5af5d6588b3a6eb6d5969fe1b01e;hp=d1056bf42f10c30228b746512c49463c406499cc;hpb=53fe06e7ae7a8c00ec902413391cea15362bdbf2;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index d1056bf..3d3e99f 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -73,6 +73,8 @@ import jalview.io.HtmlSvgOutput; import jalview.io.IdentifyFile; import jalview.io.NewickFile; import jalview.io.gff.SequenceOntologyFactory; +import jalview.jbgui.QuitHandler; +import jalview.jbgui.QuitHandler.QResponse; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.util.ChannelProperties; @@ -271,6 +273,25 @@ public class Jalview if (!Platform.isJS()) { System.setSecurityManager(null); + + Runtime.getRuntime().addShutdownHook(new Thread() + { + public void run() + { + Console.debug("Running shutdown hook"); + if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT) + { + Console.debug("Checking for saving files"); + QuitHandler.getQuitResponse(false); + } + else + { + Console.debug("Nothing more to do"); + } + Console.debug("Exiting, bye!"); + // shutdownHook cannot be cancelled, JVM will now halt + } + }); } System.out @@ -279,6 +300,7 @@ public class Jalview System.out.println(System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version")); + String val = System.getProperty("sys.install4jVersion"); if (val != null) { @@ -299,10 +321,12 @@ public class Jalview Cache.loadBuildProperties(true); ArgsParser aparser = new ArgsParser(args); + boolean headless = false; String usrPropsFile = aparser.getValue("props"); - Cache.loadProperties(usrPropsFile); // must do this before + Cache.loadProperties(usrPropsFile); // must do this + // before if (usrPropsFile != null) { System.out.println( @@ -380,7 +404,9 @@ public class Jalview try { Console.initLogger(); - } catch (NoClassDefFoundError error) + } catch ( + + NoClassDefFoundError error) { error.printStackTrace(); System.out.println("\nEssential logging libraries not found." @@ -555,8 +581,11 @@ public class Jalview } String file = null, data = null; + FileFormatI format = null; + DataSourceType protocol = null; + FileLoader fileLoader = new FileLoader(!headless); String groovyscript = null; // script to execute after all loading is @@ -570,6 +599,7 @@ public class Jalview System.out.println("No files to open!"); System.exit(1); } + long progress = -1; // Finally, deal with the remaining input data. if (file != null) @@ -829,6 +859,7 @@ public class Jalview } } } + AlignFrame startUpAlframe = null; // We'll only open the default file if the desktop is visible. // And the user @@ -1365,19 +1396,12 @@ public class Jalview } /** - * Quit method delegates to Desktop.quit - unless running in headless mode - * when it just ends the JVM + * jalview.bin.Jalview.quit() will just run the non-GUI shutdownHook and exit */ public void quit() { - if (desktop != null) - { - desktop.quit(); - } - else - { - System.exit(0); - } + // System.exit will run the shutdownHook first + System.exit(0); } public static AlignFrame getCurrentAlignFrame()