*/\r
package jalview.gui;\r
\r
-import jalview.datamodel.*;\r
-\r
import jalview.io.*;\r
\r
import java.awt.*;\r
public static void addInternalFrame(final JInternalFrame frame,\r
String title, int w, int h, boolean resizable)\r
{\r
+\r
+ frame.setTitle(title);\r
+ frame.setSize(w, h);\r
+\r
+ // THIS IS A PUBLIC STATIC METHOD, SO IT MAY BE CALLED EVEN IN\r
+ // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN\r
+ // IF JALVIEW IS RUNNING HEADLESS\r
+ /////////////////////////////////////////////////\r
+ if (System.getProperty("java.awt.headless") != null\r
+ && System.getProperty("java.awt.headless").equals("true"))\r
+ {\r
+ return;\r
+ }\r
+\r
+\r
desktop.add(frame);\r
openFrameCount++;\r
\r
{\r
}\r
\r
- frame.setTitle(title);\r
- frame.setSize(w, h);\r
frame.setClosable(true);\r
frame.setResizable(resizable);\r
frame.setMaximizable(resizable);\r
*/\r
public void LoadFile(String file, String protocol, String format)\r
{\r
- LoadingThread loader = new LoadingThread(file, protocol, format);\r
- loader.start();\r
- }\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param file DOCUMENT ME!\r
- * @param protocol DOCUMENT ME!\r
- * @param format DOCUMENT ME!\r
- */\r
- public AlignFrame LoadFileWaitTillLoaded(String file, String protocol, String format)\r
- {\r
- LoadingThread loader = new LoadingThread(file, protocol, format);\r
- loader.start();\r
-\r
- while (loader.isAlive())\r
- {\r
- try\r
- {\r
- Thread.sleep(50);\r
- }\r
- catch (Exception ex)\r
- {}\r
- }\r
-\r
- return loader.af;\r
+ FileLoader fileLoader = new FileLoader();\r
+ fileLoader.LoadFile(file, protocol, format);\r
}\r
\r
/**\r
}\r
}\r
\r
- class LoadingThread extends Thread\r
- {\r
- String file;\r
- String protocol;\r
- String format;\r
- AlignFrame af;\r
-\r
- public LoadingThread(String file, String protocol, String format)\r
- {\r
- this.file = file;\r
- this.protocol = protocol;\r
- this.format = format;\r
- }\r
-\r
- public void run()\r
- {\r
- SequenceI[] sequences = null;\r
-\r
- if(format.equalsIgnoreCase("Jalview"))\r
- {\r
- Jalview2XML.LoadJalviewAlign(file);\r
- }\r
- else\r
- {\r
- if (FormatAdapter.formats.contains(format))\r
- {\r
- sequences = FormatAdapter.readFile(file, protocol, format);\r
- }\r
-\r
- if ( (sequences != null) && (sequences.length > 0))\r
- {\r
- af = new AlignFrame(new Alignment(sequences));\r
- addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH,\r
- AlignFrame.NEW_WINDOW_HEIGHT);\r
- af.currentFileFormat = format;\r
- af.statusBar.setText("Successfully loaded file " + file);\r
-\r
- try\r
- {\r
- af.setMaximum(Preferences.showFullscreen);\r
- }\r
- catch (Exception ex)\r
- {\r
- }\r
- }\r
- else\r
- {\r
- JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "Couldn't open file.\n" +\r
- "Formats currently supported are\n" +\r
- "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter!\r
- , "Error loading file", JOptionPane.WARNING_MESSAGE);\r
- }\r
- }\r
- }\r
- }\r
}\r