Loading alignment threaded
authoramwaterhouse <Andrew Waterhouse>
Mon, 25 Apr 2005 08:52:13 +0000 (08:52 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 25 Apr 2005 08:52:13 +0000 (08:52 +0000)
src/jalview/gui/Desktop.java

index 4b0ffee..1226f67 100755 (executable)
@@ -190,27 +190,44 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
 \r
  public void LoadFile(String file, String protocol,  String format)\r
  {\r
-   SequenceI [] sequences = null;\r
+   LoadingThread loader = new LoadingThread(file, protocol, format);\r
+   loader.start();\r
+ }\r
 \r
-   if (FormatProperties.contains(format))\r
-       sequences = FormatAdapter.read(file, protocol, format);\r
+ class LoadingThread extends Thread\r
+ {\r
+   String file, protocol, format;\r
 \r
-   if (sequences != null && sequences.length>0)\r
+   public LoadingThread(String file, String protocol,  String format)\r
    {\r
-     AlignFrame af = new AlignFrame(new Alignment(sequences));\r
-     addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);\r
-     af.statusBar.setText("Successfully loaded file " + file);\r
-\r
+     this.file = file;\r
+     this.protocol = protocol;\r
+     this.format = format;\r
    }\r
-   else\r
-     JOptionPane.showInternalMessageDialog(Desktop.desktop,  "Couldn't open file.\n"\r
-                          + "Formats currently supported are\n"\r
-                          + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM" // JBPNote - message should be generated through FormatAdapter!\r
-                          ,"Error loading file",\r
-                                   JOptionPane.WARNING_MESSAGE);\r
+   public void run()\r
+   {\r
+     SequenceI [] sequences = null;\r
+\r
+     if (FormatProperties.contains(format))\r
+         sequences = FormatAdapter.read(file, protocol, format);\r
 \r
+     if (sequences != null && sequences.length>0)\r
+     {\r
+       AlignFrame af = new AlignFrame(new Alignment(sequences));\r
+       addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);\r
+       af.statusBar.setText("Successfully loaded file " + file);\r
+     }\r
+     else\r
+       JOptionPane.showInternalMessageDialog(Desktop.desktop,  "Couldn't open file.\n"\r
+                            + "Formats currently supported are\n"\r
+                            + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM" // JBPNote - message should be generated through FormatAdapter!\r
+                            ,"Error loading file",\r
+                                     JOptionPane.WARNING_MESSAGE);\r
+\r
+   }\r
  }\r
 \r
+\r
  public void inputURLMenuItem_actionPerformed(ActionEvent e)\r
  {\r
    String url = JOptionPane.showInternalInputDialog(Desktop.desktop,"Enter url of input file",\r
@@ -314,3 +331,5 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
    }\r
  }\r
 }\r
+\r
+\r