flag to indicate if errors are raised as warning dialog boxes or not.
[jalview.git] / src / jalview / gui / Jalview2XML.java
index 4f76445..9a56150 100755 (executable)
@@ -52,6 +52,14 @@ public class Jalview2XML
   Hashtable seqRefIds = null;
 
   Vector frefedSequence = null;
+  boolean raiseGUI = true; // whether errors are raised in dialog boxes or not
+  public Jalview2XML()
+  {
+  }
+  public Jalview2XML(boolean raiseGUI)
+  {
+    this.raiseGUI = raiseGUI;
+  }
 
   public void resolveFrefedSequences()
   {
@@ -1227,8 +1235,18 @@ public class Jalview2XML
     } catch (Exception ex)
     {
       //Is Version 1 Jar file?
-      af = new Jalview2XML_V1().LoadJalviewAlign(file);
+      try {
+        af = new Jalview2XML_V1(raiseGUI).LoadJalviewAlign(file);
+      } catch (Exception ex2) {
+        System.err.println("Exception whilst loading as jalviewXMLV1:");
+        ex2.printStackTrace();
+        af = null;
+      }
 
+      if (Desktop.instance != null)
+      {
+        Desktop.instance.stopLoading();
+      }
       if (af != null)
       {
         System.out.println("Successfully loaded archive file");
@@ -1254,15 +1272,20 @@ public class Jalview2XML
     if (errorMessage != null)
     {
       final String finalErrorMessage = errorMessage;
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
-      {
-        public void run()
+      if (raiseGUI)
+        {
+        javax.swing.SwingUtilities.invokeLater(new Runnable()
+        {
+          public void run()
         {
           JOptionPane.showInternalMessageDialog(Desktop.desktop,
                   finalErrorMessage, "Error loading Jalview file",
                   JOptionPane.WARNING_MESSAGE);
         }
       });
+        } else {
+          System.err.println("Problem loading Jalview file: "+errorMessage);
+        }
     }
 
     return af;