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
10 public class FileLoader
\r
12 public void LoadFile(String file, String protocol, String format)
\r
14 LoadingThread loader = new LoadingThread(file, protocol, format);
\r
18 public AlignFrame LoadFileWaitTillLoaded(String file, String protocol,
\r
21 LoadingThread loader = new LoadingThread(file, protocol, format);
\r
23 while (loader.isAlive())
\r
29 catch (Exception ex)
\r
45 public LoadingThread(String file, String protocol, String format)
\r
48 this.protocol = protocol;
\r
49 this.format = format;
\r
54 SequenceI[] sequences = null;
\r
56 if (format.equalsIgnoreCase("Jalview"))
\r
58 af = Jalview2XML.LoadJalviewAlign(file);
\r
62 if (FormatAdapter.formats.contains(format))
\r
64 sequences = FormatAdapter.readFile(file, protocol, format);
\r
67 if ( (sequences != null) && (sequences.length > 0))
\r
69 af = new AlignFrame(new Alignment(sequences));
\r
70 af.currentFileFormat = format;
\r
71 af.statusBar.setText("Successfully loaded file " + file);
\r
73 Desktop.addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH,
\r
74 AlignFrame.NEW_WINDOW_HEIGHT);
\r
79 af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
\r
81 catch (Exception ex)
\r
87 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
88 "Couldn't open file.\n" +
\r
89 "Formats currently supported are\n" +
\r
90 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter!
\r
91 , "Error loading file",
\r
92 JOptionPane.WARNING_MESSAGE);
\r