From: Ben Soares Date: Mon, 27 Feb 2023 15:05:09 +0000 (+0000) Subject: JAL-629 Fix Exceptions when running with CLI not headless X-Git-Tag: Release_2_11_4_0~466 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a67002917b669aaff650904ec4353f8c70866cc8;p=jalview.git JAL-629 Fix Exceptions when running with CLI not headless --- diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index f8481f5..429c692 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -19,12 +19,16 @@ import jalview.bin.ArgParser.ArgValuesMap; import jalview.bin.ArgParser.SubVals; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.datamodel.annotations.AlphaFoldAnnotationRowBuilder; import jalview.gui.AlignFrame; import jalview.gui.AlignmentPanel; +import jalview.gui.AssociatePdbFileWithSeq; import jalview.gui.Desktop; +import jalview.gui.Preferences; import jalview.gui.StructureChooser; +import jalview.gui.StructureViewer; import jalview.io.AppletFormatAdapter; import jalview.io.DataSourceType; import jalview.io.FileFormatException; @@ -144,7 +148,7 @@ public class Commands if (first) { first = false; - if (!headless) + if (!headless && desktop != null) { desktop.setProgressBar( MessageManager.getString( @@ -424,8 +428,17 @@ public class Commands Console.debug("Using structure file " + structureFile.getAbsolutePath()); + PDBEntry fileEntry = new AssociatePdbFileWithSeq() + .associatePdbWithSeq(structureFile.getAbsolutePath(), + DataSourceType.FILE, seq, true, Desktop.instance); + // open structure view AlignmentPanel ap = af.alignPanel; + if (headless) + { + Cache.setProperty(Preferences.STRUCTURE_DISPLAY, + StructureViewer.ViewerType.JMOL.toString()); + } StructureChooser.openStructureFileForSequence(ap, seq, structureFile); } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 99ae815..3cc71af 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -378,19 +378,6 @@ public class Jalview if (argparser.isSet(Arg.HEADLESS)) headless = argparser.getBool(Arg.HEADLESS); - boolean commandsSuccess = Commands.processArgs(argparser, headless); - if (commandsSuccess) - { - Console.info("Successfully completed commands"); - if (headless) - System.exit(0); - } - else - { - Console.warn("Error when running commands"); - if (headless) - System.exit(1); - } if (!Platform.isJS()) /** @@ -613,6 +600,20 @@ public class Jalview } } } + // Run Commands from cli + boolean commandsSuccess = Commands.processArgs(argparser, headless); + if (commandsSuccess) + { + Console.info("Successfully completed commands"); + if (headless) + System.exit(0); + } + else + { + Console.warn("Error when running commands"); + if (headless) + System.exit(1); + } // Check if JVM and compile version might cause problems and log if it // might. diff --git a/src/jalview/gui/JvOptionPane.java b/src/jalview/gui/JvOptionPane.java index 3c942ce..020890b 100644 --- a/src/jalview/gui/JvOptionPane.java +++ b/src/jalview/gui/JvOptionPane.java @@ -1066,9 +1066,12 @@ public class JvOptionPane extends JOptionPane ourOptions = Arrays.asList(options); int response; - if (parentComponent != this) + if (parentComponent != this + && !(parentComponent == null && Desktop.instance == null)) { - JInternalFrame jif = this.createInternalFrame(parentComponent, title); + JInternalFrame jif = this.createInternalFrame( + parentComponent != null ? parentComponent : Desktop.instance, + title); jif.setFrameIcon(null); jif.addInternalFrameListener(new InternalFrameListener() {