3 import jalview.gui.AlignFrame;
\r
4 import jalview.gui.Jalview2XML;
\r
5 import javax.swing.JOptionPane;
\r
6 import jalview.datamodel.Alignment;
\r
7 import jalview.gui.Desktop;
\r
8 import jalview.datamodel.SequenceI;
\r
9 import jalview.gui.Preferences;
\r
11 public class FileLoader
\r
13 public void LoadFile(String file, String protocol, String format)
\r
15 LoadingThread loader = new LoadingThread(file, protocol, format);
\r
19 public AlignFrame LoadFileWaitTillLoaded(String file, String protocol,
\r
22 LoadingThread loader = new LoadingThread(file, protocol, format);
\r
24 while (loader.isAlive())
\r
30 catch (Exception ex)
\r
46 public LoadingThread(String file, String protocol, String format)
\r
49 this.protocol = protocol;
\r
50 this.format = format;
\r
55 SequenceI[] sequences = null;
\r
57 if (format.equalsIgnoreCase("Jalview"))
\r
59 af = Jalview2XML.LoadJalviewAlign(file);
\r
63 if (FormatAdapter.formats.contains(format))
\r
65 sequences = FormatAdapter.readFile(file, protocol, format);
\r
68 if ( (sequences != null) && (sequences.length > 0))
\r
70 af = new AlignFrame(new Alignment(sequences));
\r
71 af.currentFileFormat = format;
\r
72 af.statusBar.setText("Successfully loaded file " + file);
\r
74 Desktop.addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH,
\r
75 AlignFrame.NEW_WINDOW_HEIGHT);
\r
80 af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
\r
82 catch (Exception ex)
\r
88 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
89 "Couldn't open file.\n" +
\r
90 "Formats currently supported are\n" +
\r
91 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter!
\r
92 , "Error loading file",
\r
93 JOptionPane.WARNING_MESSAGE);
\r