X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;fp=src%2Fjalview%2Fbin%2FJalview.java;h=a988a09d3453b389dff1798e8e36299cb9bfb0e4;hb=0de37d1a047209510bab82225109ae2a47931f79;hp=e259cc238bb6149338c27bfb538edc064ff480aa;hpb=01f8ff469a507604ed961418f7c80f9b245e60ca;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index e259cc2..a988a09 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -49,6 +49,7 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.UnsupportedLookAndFeelException; import com.formdev.flatlaf.FlatLightLaf; import com.formdev.flatlaf.util.SystemInfo; @@ -62,6 +63,8 @@ import jalview.ext.so.SequenceOntology; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.PromptUserConfig; +import jalview.gui.QuitHandler; +import jalview.gui.QuitHandler.QResponse; import jalview.io.AppletFormatAdapter; import jalview.io.BioJsHTMLOutput; import jalview.io.DataSourceType; @@ -272,6 +275,28 @@ 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) + { + // Got to here by a SIGTERM signal. + // Note we will not actually cancel the quit from here -- it's too + // late -- but we can wait for saving files. + 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 @@ -280,6 +305,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) { @@ -301,6 +327,7 @@ public class Jalview // old ArgsParser ArgsParser aparser = new ArgsParser(args); + boolean headless = false; try @@ -315,7 +342,8 @@ public class Jalview } 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( @@ -587,8 +615,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 @@ -602,6 +633,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) @@ -861,6 +893,7 @@ public class Jalview } } } + AlignFrame startUpAlframe = null; // We'll only open the default file if the desktop is visible. // And the user @@ -1030,7 +1063,7 @@ public class Jalview setSystemLookAndFeel(); if (Platform.isLinux()) { - setMetalLookAndFeel(); + setLinuxLookAndFeel(); } if (Platform.isMac()) { @@ -1121,8 +1154,29 @@ public class Jalview private static boolean setFlatLookAndFeel() { - boolean set = setSpecificLookAndFeel("flatlaf light", - "com.formdev.flatlaf.FlatLightLaf", false); + boolean set = false; + if (Platform.isMac()) { + try + { + UIManager.setLookAndFeel("com.formdev.flatlaf.themes.FlatMacLightLaf"); + set = true; + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatMacLightLaf", e); + } + } + if (!set) { + try + { + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); + set = true; + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); + } + } if (set) { if (Platform.isMac()) @@ -1155,6 +1209,8 @@ public class Jalview UIManager.put("TabbedPane.tabWidthMode", "compact"); UIManager.put("TabbedPane.selectedBackground", Color.white); } + + Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true)); return set; } @@ -1191,6 +1247,18 @@ public class Jalview return set; } + private static boolean setLinuxLookAndFeel() + { + boolean set = false; + set = setFlatLookAndFeel(); + if (!set) + set = setMetalLookAndFeel(); + // avoid GtkLookAndFeel -- not good results especially on HiDPI + if (!set) + set = setNimbusLookAndFeel(); + return set; + } + private static void showUsage() { System.out.println( @@ -1401,19 +1469,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()