import javax.swing.JDialog;
import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import jalview.gui.PromptUserConfig;
import jalview.gui.QuitHandler;
import jalview.gui.QuitHandler.QResponse;
+import jalview.gui.StructureViewerBase;
import jalview.io.AppletFormatAdapter;
import jalview.io.BioJsHTMLOutput;
import jalview.io.DataSourceType;
public void run()
{
Console.debug("Running shutdown hook");
+ QuitHandler.startForceQuit();
+ boolean closeExternal = Cache
+ .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false)
+ || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false);
+ StructureViewerBase.setQuitClose(closeExternal);
+ if (desktop != null)
+ {
+ for (JInternalFrame frame : Desktop.desktop.getAllFrames())
+ {
+ if (frame instanceof StructureViewerBase)
+ {
+ ((StructureViewerBase) frame).closeViewer(closeExternal);
+ }
+ }
+ }
+
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.
+ // late -- but we can wait for saving files and close external viewers
+ // if configured.
+ // Close viewers/Leave viewers open
Console.debug("Checking for saving files");
QuitHandler.getQuitResponse(false);
}
Jalview.exit(null, 0);
}
- if (bootstrapArgs.contains(Arg.HEADLESS))
+ // new CLI
+ headlessArg = isHeadless(bootstrapArgs);
+ if (headlessArg)
{
System.setProperty("java.awt.headless", "true");
- // new
- headlessArg = bootstrapArgs.getBoolean(Arg.HEADLESS);
}
+ // old CLI
if (aparser.contains("nodisplay") || aparser.contains("nogui")
|| aparser.contains("headless"))
{
System.setProperty("java.awt.headless", "true");
- // old
headless = true;
}
// anything else!
System.out.println("[TESTOUTPUT] arg "
+ (yes ? a.argString() : a.negateArgString()) + " was set");
}
+
+ private static boolean isHeadless(BootstrapArgs bootstrapArgs)
+ {
+ if (bootstrapArgs == null)
+ {
+ return false;
+ }
+ boolean isHeadless = false;
+ if (bootstrapArgs.contains(Arg.GUI))
+ {
+ isHeadless = !bootstrapArgs.getBoolean(Arg.GUI);
+ }
+ else if (bootstrapArgs.contains(Arg.HEADLESS))
+ {
+ isHeadless = bootstrapArgs.getBoolean(Arg.HEADLESS);
+ }
+ else if (bootstrapArgs.argsHaveOption(Opt.OUTPUTFILE))
+ {
+ isHeadless = true;
+ }
+ return isHeadless;
+ }
}