X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileLoader.java;h=dc18cb799be5307f5194b3beb8005a20aa3109f1;hb=60b22c7b9ccf824a85fa2761e34dfdfba415a8a1;hp=67c72c224d1fa05213375865372f336c44042540;hpb=4a9e8dfb966b32dcfcb9830b2bd44def72b44adc;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 67c72c2..dc18cb7 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -125,7 +125,8 @@ public class FileLoader public void run() { - Desktop.instance.startLoading(file); + if (Desktop.instance != null) + Desktop.instance.startLoading(file); SequenceI[] sequences = null; @@ -135,9 +136,9 @@ public class FileLoader } else { - String errorMessage = AppletFormatAdapter.SUPPORTED_FORMATS; + String error = AppletFormatAdapter.SUPPORTED_FORMATS; - if (FormatAdapter.formats.contains(format)) + if (FormatAdapter.isValidFormat(format)) { try { @@ -145,7 +146,7 @@ public class FileLoader } catch (java.io.IOException ex) { - errorMessage = ex.getMessage(); + error = ex.getMessage(); } } @@ -175,18 +176,24 @@ public class FileLoader { } } - } else { - Desktop.instance.stopLoading(); - - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Couldn't load file " + file + - "\n" - + errorMessage, - "Error loading file", - JOptionPane.WARNING_MESSAGE); + if (Desktop.instance != null) + Desktop.instance.stopLoading(); + + final String errorMessage = "Couldn't load file "+file+"\n"+error; + + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + errorMessage, + "Error loading file", + JOptionPane.WARNING_MESSAGE); + } + }); } } @@ -195,7 +202,8 @@ public class FileLoader updateRecentlyOpened(); } - Desktop.instance.stopLoading(); + if (Desktop.instance != null) + Desktop.instance.stopLoading(); } }