removeGaps method can record changes in alignment columns to pass to ColumnSelection
[jalview.git] / src / jalview / io / FileLoader.java
index 7db0b90..ac3c5d3 100755 (executable)
@@ -125,7 +125,8 @@ public class FileLoader
 \r
     public void run()\r
     {\r
-      Desktop.instance.startLoading(file);\r
+      if (Desktop.instance != null)\r
+        Desktop.instance.startLoading(file);\r
 \r
       SequenceI[] sequences = null;\r
 \r
@@ -135,9 +136,9 @@ public class FileLoader
       }\r
       else\r
       {\r
-        String errorMessage = AppletFormatAdapter.SUPPORTED_FORMATS;\r
+        String error = AppletFormatAdapter.SUPPORTED_FORMATS;\r
 \r
-        if (FormatAdapter.formats.contains(format))\r
+        if (FormatAdapter.isValidFormat(format))\r
         {\r
           try\r
           {\r
@@ -145,7 +146,7 @@ public class FileLoader
           }\r
           catch (java.io.IOException ex)\r
           {\r
-            errorMessage = ex.getMessage();\r
+            error = ex.getMessage();\r
           }\r
         }\r
 \r
@@ -167,11 +168,6 @@ public class FileLoader
             Desktop.addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH,\r
                                      AlignFrame.NEW_WINDOW_HEIGHT);\r
 \r
-            if(jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false))\r
-            {\r
-              af.wrapMenuItem.setSelected(true);\r
-              af.wrapMenuItem_actionPerformed(null);\r
-            }\r
             try\r
             {\r
               af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));\r
@@ -180,16 +176,24 @@ public class FileLoader
             {\r
             }\r
           }\r
-\r
         }\r
         else\r
         {\r
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
-                                                "Couldn't load file " + file +\r
-                                                "\n"\r
-                                                + errorMessage,\r
-                                                "Error loading file",\r
-                                                JOptionPane.WARNING_MESSAGE);\r
+          if (Desktop.instance != null)\r
+            Desktop.instance.stopLoading();\r
+\r
+          final String errorMessage = "Couldn't load file "+file+"\n"+error;\r
+\r
+          javax.swing.SwingUtilities.invokeLater(new Runnable()\r
+          {\r
+            public void run()\r
+            {\r
+              JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+                                                    errorMessage,\r
+                                                    "Error loading file",\r
+                                                    JOptionPane.WARNING_MESSAGE);\r
+            }\r
+          });\r
         }\r
       }\r
 \r
@@ -198,7 +202,9 @@ public class FileLoader
         updateRecentlyOpened();\r
       }\r
 \r
-      Desktop.instance.stopLoading();\r
+      if (Desktop.instance != null)\r
+        Desktop.instance.stopLoading();\r
+\r
     }\r
   }\r
 \r