JAL-4285 JAL-4262 Added a scrollable dialog to display errors. Moved old-style CLI...
[jalview.git] / src / jalview / bin / Jalview.java
index 51e8a82..dbc1d88 100755 (executable)
@@ -76,6 +76,7 @@ import jalview.bin.argparser.BootstrapArgs;
 import jalview.ext.so.SequenceOntology;
 import jalview.gui.AlignFrame;
 import jalview.gui.Desktop;
+import jalview.gui.JvOptionPane;
 import jalview.gui.PromptUserConfig;
 import jalview.gui.QuitHandler;
 import jalview.gui.QuitHandler.QResponse;
@@ -673,6 +674,8 @@ public class Jalview
       desktop = new Desktop();
       desktop.setInBatchMode(true); // indicate we are starting up
 
+      mixedCliWarning();
+
       try
       {
         JalviewTaskbar.setTaskbar(this);
@@ -838,6 +841,8 @@ public class Jalview
     cmds.processArgs();
     boolean commandsSuccess = cmds.argsWereParsed();
 
+    cliWarning();
+
     if (commandsSuccess)
     {
       if (headlessArg)
@@ -2020,4 +2025,63 @@ public class Jalview
             || getInstance().desktop.isInBatchMode());
   }
 
+  /**
+   * Warning about old or mixed command line arguments
+   */
+  private void mixedCliWarning()
+  {
+    Jalview j = Jalview.getInstance();
+    boolean mixedStyle = j.getArgParser() != null
+            && j.getArgParser().isMixedStyle();
+    String title = MessageManager.getString("label.command_line_arguments");
+    if (mixedStyle)
+    {
+      String warning = MessageManager.formatMessage(
+              "warning.using_mixed_command_line_arguments",
+              j.getArgParser().getMixedExamples());
+      String quit = MessageManager.getString("action.quit");
+
+      Desktop.instance.nonBlockingDialog(title, warning, quit,
+              JvOptionPane.WARNING_MESSAGE, false, true);
+
+      Jalview.exit(
+              "Exiting due to mixed old and new command line arguments.",
+              ExitCode.MIXED_CLI_ARGUMENTS);
+    }
+  }
+
+  private void cliWarning()
+  {
+    Jalview j = Jalview.getInstance();
+    Commands c = j.getCommands();
+    boolean oldStyle = j.getArgParser() != null
+            && j.getArgParser().isOldStyle();
+    String title = MessageManager.getString("label.command_line_arguments");
+    if (oldStyle)
+    {
+      String warning = MessageManager
+              .getString("warning.using_old_command_line_arguments")
+              + "https://www.jalview.org/help/html/features/commandline.html";
+      if (Desktop.instance != null)
+      {
+        String cont = MessageManager.getString("label.continue");
+
+        Desktop.instance.nonBlockingDialog(32, 2, title, warning, cont,
+                JvOptionPane.WARNING_MESSAGE, false, false);
+      }
+    }
+    if (j.getCommands() != null && j.getCommands().getErrors().size() > 0)
+    {
+      if (Desktop.instance != null)
+      {
+        String message = MessageManager
+                .getString("warning.the_following_errors");
+        String ok = MessageManager.getString("action.ok");
+        Desktop.instance.nonBlockingDialog(60, 16, title,
+                message + "\n" + j.getCommands().errorsToString(), ok,
+                JvOptionPane.WARNING_MESSAGE, true, true);
+      }
+    }
+  }
+
 }