From 98e5ebe726c30cca66c22541ddb98228d914805a Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 8 Feb 2006 15:25:50 +0000 Subject: [PATCH] FormatAdapter throws exception --- src/jalview/bin/JalviewLite.java | 25 +++++++++++++++++-------- src/jalview/gui/CutAndPasteTransfer.java | 16 ++++++++-------- src/jalview/jbgui/GFinder.java | 4 +++- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index a26b9d0..c4e17fb 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -127,8 +127,13 @@ public class JalviewLite extends Applet } String format = jalview.io.IdentifyFile.Identify(args[0],"File"); - SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format); - + SequenceI[] sequences = null; + try{ + sequences = new AppletFormatAdapter().readFile(args[0], "File", format); + }catch(java.io.IOException ex) + { + ex.printStackTrace(); + } if ( (sequences != null) && (sequences.length > 0)) { AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0]); @@ -247,8 +252,13 @@ public class JalviewLite extends Applet public void run() { SequenceI[] sequences = null; - sequences = new AppletFormatAdapter().readFile(file, protocol, format); - + try{ + sequences = new AppletFormatAdapter().readFile(file, protocol, + format); + }catch(java.io.IOException ex) + { + ex.printStackTrace(); + } if ((sequences != null) && (sequences.length > 0)) { currentAlignFrame = new AlignFrame(new Alignment(sequences), @@ -263,12 +273,11 @@ public class JalviewLite extends Applet if (treeFile != null) { if (treeFile.indexOf("://") == -1) - treeFile = getCodeBase() + treeFile; + treeFile = getCodeBase() + treeFile; try { - jalview.io.NewickFile fin = new jalview.io.NewickFile(applet. - getCodeBase() + treeFile, "URL"); + jalview.io.NewickFile fin = new jalview.io.NewickFile(treeFile, "URL"); fin.parse(); if (fin.getTree() != null) @@ -276,7 +285,7 @@ public class JalviewLite extends Applet TreePanel tp = null; tp = new TreePanel(currentAlignFrame.viewport, currentAlignFrame.viewport.getAlignment().getSequences(), - fin, "FromFile", applet.getCodeBase() + treeFile); + fin, "FromFile", treeFile); addFrame(tp, treeFile, 600, 500); currentAlignFrame.addTreeMenuItem(tp, treeFile); } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index be2cf97..31a756b 100755 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -134,7 +134,15 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer if (FormatAdapter.formats.contains(format)) { + try{ sequences = new FormatAdapter().readFile(getText(), "Paste", format); + }catch(java.io.IOException ex) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Couldn't read the pasted text.\n" +ex.toString(), + "Error parsing text", + JOptionPane.WARNING_MESSAGE); + } } if (sequences != null) @@ -161,14 +169,6 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer { } } - else - { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Couldn't read the pasted text.\n" + - "Formats currently supported are\n" + - "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM", - "Error parsing text", JOptionPane.WARNING_MESSAGE); - } } /** diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index ed03a80..2fe4e14 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -164,7 +164,9 @@ public class GFinder public void run() { String str = textfield.getText(); - SequenceI[] sequences = new FormatAdapter().readFile(str, "Paste", "FASTA"); + SequenceI[] sequences = null; + try{new FormatAdapter().readFile(str, "Paste", "FASTA");} + catch(Exception ex){} if(sequences!=null && sequences.length>0) { str = jalview.analysis.AlignSeq.extractGaps( -- 1.7.10.2