X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalview.java;h=7535f6013fa00b77eea606728b0f7d45abcc17b4;hb=84ff3a3c7824890b0a201e6a4ec8fa1c9b6e9e64;hp=8fa4ac7dba652ebd041230745aadb187b281a925;hpb=3e8516c59908e9f9f791cf820321c5007bdd58ec;p=jalview.git diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 8fa4ac7..7535f60 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -451,11 +451,14 @@ public class Jalview .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false) || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false); StructureViewerBase.setQuitClose(closeExternal); - for (JInternalFrame frame : Desktop.desktop.getAllFrames()) + if (desktop != null) { - if (frame instanceof StructureViewerBase) + for (JInternalFrame frame : Desktop.desktop.getAllFrames()) { - ((StructureViewerBase) frame).closeViewer(closeExternal); + if (frame instanceof StructureViewerBase) + { + ((StructureViewerBase) frame).closeViewer(closeExternal); + } } } @@ -532,17 +535,17 @@ public class Jalview 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! @@ -1883,4 +1886,26 @@ public class Jalview 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; + } }