2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
22 import jalview.gui.AlignFrame;
\r
23 import jalview.gui.Jalview2XML;
\r
24 import javax.swing.JOptionPane;
\r
25 import jalview.datamodel.Alignment;
\r
26 import jalview.gui.Desktop;
\r
27 import jalview.datamodel.SequenceI;
\r
29 public class FileLoader
\r
31 public void LoadFile(String file, String protocol, String format)
\r
33 LoadingThread loader = new LoadingThread(file, protocol, format);
\r
37 public AlignFrame LoadFileWaitTillLoaded(String file, String protocol,
\r
40 LoadingThread loader = new LoadingThread(file, protocol, format);
\r
42 while (loader.isAlive())
\r
48 catch (Exception ex)
\r
64 public LoadingThread(String file, String protocol, String format)
\r
67 this.protocol = protocol;
\r
68 this.format = format;
\r
73 SequenceI[] sequences = null;
\r
75 if (format.equalsIgnoreCase("Jalview"))
\r
77 af = Jalview2XML.LoadJalviewAlign(file);
\r
81 if (FormatAdapter.formats.contains(format))
\r
83 sequences = new FormatAdapter().readFile(file, protocol, format);
\r
86 if ( (sequences != null) && (sequences.length > 0))
\r
88 af = new AlignFrame(new Alignment(sequences));
\r
89 af.currentFileFormat = format;
\r
90 af.statusBar.setText("Successfully loaded file " + file);
\r
92 Desktop.addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH,
\r
93 AlignFrame.NEW_WINDOW_HEIGHT);
\r
98 af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
\r
100 catch (Exception ex)
\r
106 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
107 "Couldn't open file.\n" +
\r
108 "Formats currently supported are\n" +
\r
109 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter!
\r
110 , "Error loading file",
\r
111 JOptionPane.WARNING_MESSAGE);
\r