From c2cfc47868289f8d52e0e0b86162b4da1e03c19f Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 25 Apr 2005 08:52:13 +0000 Subject: [PATCH] Loading alignment threaded --- src/jalview/gui/Desktop.java | 47 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 4b0ffee..1226f67 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -190,27 +190,44 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); public void LoadFile(String file, String protocol, String format) { - SequenceI [] sequences = null; + LoadingThread loader = new LoadingThread(file, protocol, format); + loader.start(); + } - if (FormatProperties.contains(format)) - sequences = FormatAdapter.read(file, protocol, format); + class LoadingThread extends Thread + { + String file, protocol, format; - if (sequences != null && sequences.length>0) + public LoadingThread(String file, String protocol, String format) { - AlignFrame af = new AlignFrame(new Alignment(sequences)); - addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); - af.statusBar.setText("Successfully loaded file " + file); - + this.file = file; + this.protocol = protocol; + this.format = format; } - else - JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't open file.\n" - + "Formats currently supported are\n" - + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM" // JBPNote - message should be generated through FormatAdapter! - ,"Error loading file", - JOptionPane.WARNING_MESSAGE); + public void run() + { + SequenceI [] sequences = null; + + if (FormatProperties.contains(format)) + sequences = FormatAdapter.read(file, protocol, format); + if (sequences != null && sequences.length>0) + { + AlignFrame af = new AlignFrame(new Alignment(sequences)); + addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); + af.statusBar.setText("Successfully loaded file " + file); + } + else + JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't open file.\n" + + "Formats currently supported are\n" + + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM" // JBPNote - message should be generated through FormatAdapter! + ,"Error loading file", + JOptionPane.WARNING_MESSAGE); + + } } + public void inputURLMenuItem_actionPerformed(ActionEvent e) { String url = JOptionPane.showInternalInputDialog(Desktop.desktop,"Enter url of input file", @@ -314,3 +331,5 @@ this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); } } } + + -- 1.7.10.2