From 10969ddae3e6311c50cddb58fb13f22f04661d80 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 19 Jun 2009 09:57:42 +0000 Subject: [PATCH] progress bars (still need to be threaded properly) and URI drag'n'dropping --- src/jalview/gui/Desktop.java | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 484bcde..0f6dbf4 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -387,6 +387,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements { Transferable t = evt.getTransferable(); java.util.List files = null; + java.util.List protocols = null; try { @@ -405,6 +406,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); String data = (String) t.getTransferData(uriListFlavor); files = new java.util.ArrayList(1); + protocols = new java.util.ArrayList(1); for (java.util.StringTokenizer st = new java.util.StringTokenizer( data, "\r\n"); st.hasMoreTokens();) { @@ -414,10 +416,19 @@ public class Desktop extends jalview.jbgui.GDesktop implements // the line is a comment (as per the RFC 2483) continue; } - java.net.URI uri = new java.net.URI(s); - java.io.File file = new java.io.File(uri); - files.add(file); + if (uri.getScheme().toLowerCase().startsWith("http")) + { + protocols.add(FormatAdapter.URL); + files.add(uri.toString()); + } + else + { + // otherwise preserve old behaviour: catch all for file objects + java.io.File file = new java.io.File(uri); + protocols.add(FormatAdapter.FILE); + files.add(file.toString()); + } } } } catch (Exception e) @@ -431,7 +442,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements for (int i = 0; i < files.size(); i++) { String file = files.get(i).toString(); - String protocol = FormatAdapter.FILE; + String protocol = (protocols==null) ? FormatAdapter.FILE : (String) protocols.get(i); String format = null; if (file.endsWith(".jar")) @@ -834,8 +845,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { java.io.File choice = chooser.getSelectedFile(); + JProgressBar progpanel = addProgressPanel("Saving jalview project "+choice.getName()); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); + // TODO catch and handle errors for savestate new Jalview2XML().SaveState(choice); + removeProgressPanel(progpanel); + } } @@ -859,9 +874,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { String choice = chooser.getSelectedFile().getAbsolutePath(); + setProgressBar("loading jalview project "+chooser.getSelectedFile().getName(),choice.hashCode()); jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser .getSelectedFile().getParent()); new Jalview2XML().LoadJalviewAlign(choice); + setProgressBar(null,choice.hashCode()); } } @@ -1177,7 +1194,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public boolean vamsasImport(File file) { - // TODO: create progress bar if (v_client != null) { @@ -1186,17 +1202,20 @@ public class Desktop extends jalview.jbgui.GDesktop implements return false; } + setProgressBar("Importing VAMSAS session from "+file.getName(),file.hashCode()); try { v_client = new jalview.gui.VamsasApplication(this, file,null); } catch (Exception ex) { + setProgressBar("Importing VAMSAS session from "+file.getName(),file.hashCode()); jalview.bin.Cache.log.error( "New vamsas session from existing session file failed:", ex); return false; } setupVamsasConnectedGui(); v_client.initial_update(); // TODO: thread ? + setProgressBar("Importing VAMSAS session from "+file.getName(),file.hashCode()); return v_client.inSession(); } public boolean joinVamsasSession(String mysesid) { @@ -1357,6 +1376,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements if (value == JalviewFileChooser.APPROVE_OPTION) { java.io.File choice = chooser.getSelectedFile(); + JProgressBar progpanel = addProgressPanel("Saving VAMSAS Document to "+choice.getName()); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); String warnmsg = null; String warnttl = null; @@ -1378,6 +1398,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements + choice, ex); } + removeProgressPanel(progpanel); if (warnmsg != null) { JOptionPane.showInternalMessageDialog(Desktop.desktop, -- 1.7.10.2