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 = new Jalview2XML().LoadJalviewAlign(file);
\r
81 String errorMessage = AppletFormatAdapter.SUPPORTED_FORMATS;
\r
83 if (FormatAdapter.formats.contains(format))
\r
86 sequences = new FormatAdapter().readFile(file, protocol, format);
\r
87 }catch(java.io.IOException ex)
\r
89 errorMessage = ex.getMessage();
\r
93 if ( (sequences != null) && (sequences.length > 0))
\r
95 af = new AlignFrame(new Alignment(sequences));
\r
96 af.currentFileFormat = format;
\r
97 af.statusBar.setText("Successfully loaded file " + file);
\r
99 Desktop.addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH,
\r
100 AlignFrame.NEW_WINDOW_HEIGHT);
\r
105 af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
\r
107 catch (Exception ex)
\r
113 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
114 "Couldn't load file "+file+"\n"
\r
116 "Error loading file",
\r
117 JOptionPane.WARNING_MESSAGE);
\r