X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileLoader.java;h=4f83ab1235e14be8b9879f6797f55d70cd7dceff;hb=18fb9dd58b1f0c4277b269c5e8bc2d3ed98394a5;hp=bbc753b5487cb809ceacd71447cf68512ac2bd85;hpb=ee198b3ca3687f18a2ee186f4e7c7330f4ea30f0;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index bbc753b..4f83ab1 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -34,6 +34,7 @@ import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; import jalview.gui.Desktop; import jalview.gui.Jalview2XML; +import jalview.gui.JvOptionPane; import jalview.json.binding.biojson.v1.ColourSchemeMapper; import jalview.schemes.ColourSchemeI; import jalview.structure.StructureSelectionManager; @@ -42,7 +43,6 @@ import jalview.util.MessageManager; import java.util.StringTokenizer; import java.util.Vector; -import javax.swing.JOptionPane; import javax.swing.SwingUtilities; public class FileLoader implements Runnable @@ -53,7 +53,8 @@ public class FileLoader implements Runnable FileFormatI format; - AlignmentFileI source = null; // alternative specification of where data comes + AlignmentFileReaderI source = null; // alternative specification of where data + // comes // from @@ -160,7 +161,7 @@ public class FileLoader implements Runnable * @param format * @return alignFrame constructed from file contents */ - public AlignFrame LoadFileWaitTillLoaded(AlignmentFileI source, + public AlignFrame LoadFileWaitTillLoaded(AlignmentFileReaderI source, FileFormatI format) { this.source = source; @@ -237,7 +238,7 @@ public class FileLoader implements Runnable if (protocol == DataSourceType.FILE) { - Cache.setProperty("DEFAULT_FILE_FORMAT", format.toString()); + Cache.setProperty("DEFAULT_FILE_FORMAT", format.getName()); } } @@ -258,10 +259,8 @@ public class FileLoader implements Runnable // just in case the caller didn't identify the file for us if (source != null) { - format = new IdentifyFile().identify(source, false); // identify - // stream and - // rewind rather - // than close + format = new IdentifyFile().identify(source, false); + // identify stream and rewind rather than close } else { @@ -277,13 +276,13 @@ public class FileLoader implements Runnable + "\" has null or unidentifiable data content!"); if (!Jalview.isHeadlessMode()) { - javax.swing.JOptionPane.showInternalMessageDialog( + JvOptionPane.showInternalMessageDialog( Desktop.desktop, MessageManager.getString("label.couldnt_read_data") + " in " + file + "\n" - + AppletFormatAdapter.SUPPORTED_FORMATS, + + AppletFormatAdapter.getSupportedFormats(), MessageManager.getString("label.couldnt_read_data"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } return; } @@ -300,7 +299,7 @@ public class FileLoader implements Runnable loadtime = -System.currentTimeMillis(); AlignmentI al = null; - if (format == FileFormat.Jalview) + if (FileFormat.Jalview.equals(format)) { if (source != null) { @@ -313,27 +312,27 @@ public class FileLoader implements Runnable } else { - String error = AppletFormatAdapter.SUPPORTED_FORMATS; - try + String error = AppletFormatAdapter.getSupportedFormats(); + try + { + if (source != null) { - if (source != null) - { - // read from the provided source - al = new FormatAdapter().readFromFile(source, format); - } - else - { - - // open a new source and read from it - FormatAdapter fa = new FormatAdapter(); - al = fa.readFile(file, protocol, format); - source = fa.getAlignFile(); // keep reference for later if - // necessary. - } - } catch (java.io.IOException ex) + // read from the provided source + al = new FormatAdapter().readFromFile(source, format); + } + else { - error = ex.getMessage(); + + // open a new source and read from it + FormatAdapter fa = new FormatAdapter(); + al = fa.readFile(file, protocol, format); + source = fa.getAlignFile(); // keep reference for later if + // necessary. } + } catch (java.io.IOException ex) + { + error = ex.getMessage(); + } if ((al != null) && (al.getHeight() > 0) && al.hasValidSequence()) { @@ -457,10 +456,10 @@ public class FileLoader implements Runnable @Override public void run() { - JOptionPane.showInternalMessageDialog(Desktop.desktop, + JvOptionPane.showInternalMessageDialog(Desktop.desktop, errorMessage, MessageManager .getString("label.error_loading_file"), - JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } }); } @@ -484,12 +483,12 @@ public class FileLoader implements Runnable @Override public void run() { - javax.swing.JOptionPane.showInternalMessageDialog( + JvOptionPane.showInternalMessageDialog( Desktop.desktop, MessageManager.formatMessage( "label.problems_opening_file", new String[] { file }), MessageManager .getString("label.file_open_error"), - javax.swing.JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } }); } @@ -506,12 +505,12 @@ public class FileLoader implements Runnable @Override public void run() { - javax.swing.JOptionPane.showInternalMessageDialog( + JvOptionPane.showInternalMessageDialog( Desktop.desktop, MessageManager.formatMessage( "warn.out_of_memory_loading_file", new String[] { file }), MessageManager .getString("label.out_of_memory"), - javax.swing.JOptionPane.WARNING_MESSAGE); + JvOptionPane.WARNING_MESSAGE); } }); }