import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
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.themes.FlatMacLightLaf;
import com.formdev.flatlaf.util.SystemInfo;
import com.threerings.getdown.util.LaunchUtil;
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;
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
System.out.println(System.getProperty("os.arch") + " "
+ System.getProperty("os.name") + " "
+ System.getProperty("os.version"));
+
String val = System.getProperty("sys.install4jVersion");
if (val != null)
{
System.out.println("Launcher version: " + val);
}
+ if (Platform.isLinux() && LaunchUtils.getJavaVersion() < 11)
+ {
+ System.setProperty("flatlaf.uiScale", "1");
+ }
+
// report Jalview version
Cache.loadBuildProperties(true);
// old ArgsParser
ArgsParser aparser = new ArgsParser(args);
+
boolean headless = false;
try
}
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(
System.setProperty("http.agent",
"Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
+ try
+ {
+ Console.initLogger();
+ } catch (
+
+ NoClassDefFoundError error)
+ {
+ error.printStackTrace();
+ System.out.println("\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
+ System.exit(0);
+ }
+
desktop = null;
setLookAndFeel();
}
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
System.out.println("No files to open!");
System.exit(1);
}
+
long progress = -1;
// Finally, deal with the remaining input data.
if (file != null)
}
}
}
+
AlignFrame startUpAlframe = null;
// We'll only open the default file if the desktop is visible.
// And the user
startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
format);
+ // don't ask to save when quitting if only the startup file has been
+ // opened
+ Console.debug("Resetting up-to-date flag for startup file");
+ startUpAlframe.getViewport().setSavedUpToDate(true);
// extract groovy arguments before anything else.
}
Console.error("Could not set requested laf=" + laf);
}
break;
- case "quaqua":
- lafSet = setQuaquaLookAndFeel();
- if (!lafSet)
- {
- Console.error("Could not set requested laf=" + laf);
- }
- break;
- case "vaqua":
- lafSet = setVaquaLookAndFeel();
- if (!lafSet)
- {
- Console.error("Could not set requested laf=" + laf);
- }
- break;
case "mac":
lafSet = setMacLookAndFeel();
if (!lafSet)
setSystemLookAndFeel();
if (Platform.isLinux())
{
- setMetalLookAndFeel();
+ setLinuxLookAndFeel();
}
if (Platform.isMac())
{
private static boolean setFlatLookAndFeel()
{
- boolean set = setSpecificLookAndFeel("flatlaf light",
- "com.formdev.flatlaf.FlatLightLaf", false);
- if (set)
+ boolean set = false;
+ if (SystemInfo.isMacOS)
{
- if (Platform.isMac())
+ try
{
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- System.setProperty("apple.awt.application.name",
- ChannelProperties.getProperty("app_name"));
- System.setProperty("apple.awt.application.appearance", "system");
- if (SystemInfo.isMacFullWindowContentSupported
- && Desktop.desktop != null)
- {
- Desktop.desktop.getRootPane()
- .putClientProperty("apple.awt.fullWindowContent", true);
- Desktop.desktop.getRootPane()
- .putClientProperty("apple.awt.transparentTitleBar", true);
- }
+ UIManager.setLookAndFeel(
+ "com.formdev.flatlaf.themes.FlatMacLightLaf");
+ set = true;
+ Console.debug("Using FlatMacLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ System.setProperty("apple.awt.application.name",
+ ChannelProperties.getProperty("app_name"));
+ System.setProperty("apple.awt.application.appearance", "system");
+ if (SystemInfo.isMacFullWindowContentSupported
+ && Desktop.desktop != null)
+ {
+ Console.debug("Setting transparent title bar");
+ Desktop.desktop.getRootPane()
+ .putClientProperty("apple.awt.fullWindowContent", true);
+ Desktop.desktop.getRootPane()
+ .putClientProperty("apple.awt.transparentTitleBar", true);
+ Desktop.desktop.getRootPane()
+ .putClientProperty("apple.awt.fullscreenable", true);
+ }
+ SwingUtilities.invokeLater(() -> {
+ FlatMacLightLaf.setup();
+ });
+ Console.debug("Using FlatMacLightLaf");
+ set = true;
+ }
+ if (!set)
+ {
+ try
+ {
+ UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+ set = true;
+ Console.debug("Using FlatLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ // Windows specific properties here
+ SwingUtilities.invokeLater(() -> {
+ FlatLightLaf.setup();
+ });
+ Console.debug("Using FlatLightLaf");
+ set = true;
+ }
+ else if (SystemInfo.isLinux)
+ {
+ try
+ {
+ UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+ set = true;
+ Console.debug("Using FlatLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
+ }
+ // enable custom window decorations
+ JFrame.setDefaultLookAndFeelDecorated(true);
+ JDialog.setDefaultLookAndFeelDecorated(true);
+ SwingUtilities.invokeLater(() -> {
+ FlatLightLaf.setup();
+ });
+ Console.debug("Using FlatLightLaf");
+ set = true;
+ }
- SwingUtilities.invokeLater(() -> {
- FlatLightLaf.setup();
- });
+ if (!set)
+ {
+ try
+ {
+ UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf");
+ set = true;
+ Console.debug("Using FlatLightLaf");
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | UnsupportedLookAndFeelException e)
+ {
+ Console.debug("Exception loading FlatLightLaf", e);
}
+ }
+ if (set)
+ {
+ UIManager.put("TabbedPane.tabType", "card");
UIManager.put("TabbedPane.showTabSeparators", true);
+ UIManager.put("TabbedPane.showContentSeparator", true);
UIManager.put("TabbedPane.tabSeparatorsFullHeight", true);
UIManager.put("TabbedPane.tabsOverlapBorder", true);
- // UIManager.put("TabbedPane.hasFullBorder", true);
+ UIManager.put("TabbedPane.hasFullBorder", true);
UIManager.put("TabbedPane.tabLayoutPolicy", "scroll");
UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded");
UIManager.put("TabbedPane.smoothScrolling", true);
UIManager.put("TabbedPane.tabWidthMode", "compact");
UIManager.put("TabbedPane.selectedBackground", Color.white);
}
- return set;
- }
- private static boolean setQuaquaLookAndFeel()
- {
- return setSpecificLookAndFeel("quaqua",
- ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass()
- .getName(),
- false);
- }
-
- private static boolean setVaquaLookAndFeel()
- {
- return setSpecificLookAndFeel("vaqua",
- "org.violetlib.aqua.AquaLookAndFeel", false);
+ Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true));
+ return set;
}
private static boolean setMacLookAndFeel()
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(
}
/**
- * 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()