FormatAdapter throws exception
authoramwaterhouse <Andrew Waterhouse>
Wed, 8 Feb 2006 15:25:50 +0000 (15:25 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 8 Feb 2006 15:25:50 +0000 (15:25 +0000)
src/jalview/bin/JalviewLite.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/jbgui/GFinder.java

index a26b9d0..c4e17fb 100755 (executable)
@@ -127,8 +127,13 @@ public class JalviewLite extends Applet
       }\r
 \r
       String format = jalview.io.IdentifyFile.Identify(args[0],"File");\r
-      SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format);\r
-\r
+      SequenceI[] sequences = null;\r
+     try{\r
+       sequences = new AppletFormatAdapter().readFile(args[0], "File", format);\r
+     }catch(java.io.IOException ex)\r
+     {\r
+       ex.printStackTrace();\r
+     }\r
       if ( (sequences != null) && (sequences.length > 0))\r
       {\r
         AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]);\r
@@ -247,8 +252,13 @@ public class JalviewLite extends Applet
         public void run()\r
         {\r
             SequenceI[] sequences = null;\r
-            sequences = new AppletFormatAdapter().readFile(file, protocol, format);\r
-\r
+            try{\r
+              sequences = new AppletFormatAdapter().readFile(file, protocol,\r
+                  format);\r
+            }catch(java.io.IOException ex)\r
+            {\r
+              ex.printStackTrace();\r
+            }\r
             if ((sequences != null) && (sequences.length > 0))\r
             {\r
               currentAlignFrame = new AlignFrame(new Alignment(sequences),\r
@@ -263,12 +273,11 @@ public class JalviewLite extends Applet
                 if (treeFile != null)\r
                 {\r
                   if (treeFile.indexOf("://") == -1)\r
-                  treeFile = getCodeBase() + treeFile;\r
+                    treeFile = getCodeBase() + treeFile;\r
 \r
                   try\r
                   {\r
-                    jalview.io.NewickFile fin = new jalview.io.NewickFile(applet.\r
-                        getCodeBase() + treeFile, "URL");\r
+                    jalview.io.NewickFile fin = new jalview.io.NewickFile(treeFile, "URL");\r
                     fin.parse();\r
 \r
                     if (fin.getTree() != null)\r
@@ -276,7 +285,7 @@ public class JalviewLite extends Applet
                       TreePanel tp = null;\r
                       tp = new TreePanel(currentAlignFrame.viewport,\r
                                          currentAlignFrame.viewport.getAlignment().getSequences(),\r
-                                         fin, "FromFile", applet.getCodeBase() + treeFile);\r
+                                         fin, "FromFile", treeFile);\r
                       addFrame(tp, treeFile, 600, 500);\r
                       currentAlignFrame.addTreeMenuItem(tp, treeFile);\r
                     }\r
index be2cf97..31a756b 100755 (executable)
@@ -134,7 +134,15 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
 \r
         if (FormatAdapter.formats.contains(format))\r
         {\r
+          try{\r
             sequences = new FormatAdapter().readFile(getText(), "Paste", format);\r
+          }catch(java.io.IOException ex)\r
+          {\r
+            JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+                                                  "Couldn't read the pasted text.\n" +ex.toString(),\r
+                                                  "Error parsing text",\r
+                                                  JOptionPane.WARNING_MESSAGE);\r
+          }\r
         }\r
 \r
         if (sequences != null)\r
@@ -161,14 +169,6 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
             {\r
             }\r
         }\r
-        else\r
-        {\r
-            JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
-                "Couldn't read the pasted text.\n" +\r
-                "Formats currently supported are\n" +\r
-                "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM",\r
-                "Error parsing text", JOptionPane.WARNING_MESSAGE);\r
-        }\r
     }\r
 \r
     /**\r
index ed03a80..2fe4e14 100755 (executable)
@@ -164,7 +164,9 @@ public class GFinder
         public void run()\r
         {\r
           String str = textfield.getText();\r
-          SequenceI[] sequences = new FormatAdapter().readFile(str, "Paste", "FASTA");\r
+          SequenceI[] sequences = null;\r
+          try{new FormatAdapter().readFile(str, "Paste", "FASTA");}\r
+          catch(Exception ex){}\r
           if(sequences!=null && sequences.length>0)\r
           {\r
             str = jalview.analysis.AlignSeq.extractGaps(\r