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;
import java.util.StringTokenizer;
import java.util.Vector;
-import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
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
* @param format
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(AlignmentFileI source,
+ public AlignFrame LoadFileWaitTillLoaded(AlignmentFileReaderI source,
FileFormatI format)
{
this.source = source;
if (protocol == DataSourceType.FILE)
{
- Cache.setProperty("DEFAULT_FILE_FORMAT", format.toString());
+ Cache.setProperty("DEFAULT_FILE_FORMAT", format.getName());
}
}
// 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
{
+ "\" 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;
}
loadtime = -System.currentTimeMillis();
AlignmentI al = null;
- if (format == FileFormat.Jalview)
+ if (FileFormat.Jalview.equals(format))
{
if (source != null)
{
}
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())
{
@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);
}
});
}
@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);
}
});
}
@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);
}
});
}