added action for saving the current session as a vamsas archive.
authorjprocter <Jim Procter>
Fri, 7 Sep 2007 16:57:22 +0000 (16:57 +0000)
committerjprocter <Jim Procter>
Fri, 7 Sep 2007 16:57:22 +0000 (16:57 +0000)
src/jalview/gui/Desktop.java

index 76d02e7..7927df9 100755 (executable)
@@ -959,6 +959,55 @@ public class Desktop
     }
   }
 
+  public void vamsasSave_actionPerformed(ActionEvent e)
+  {
+    if (v_client != null)
+    {
+      JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
+            getProperty(
+                "LAST_DIRECTORY"), new String[]
+            {"vdj"}, // TODO: VAMSAS DOCUMENT EXTENSION is VDJ
+            new String[]
+            {"Vamsas Document"}, "Vamsas Document");
+
+        chooser.setFileView(new JalviewFileView());
+        chooser.setDialogTitle("Save Vamsas Document Archive");
+
+        int value = chooser.showSaveDialog(this);
+
+        if (value == JalviewFileChooser.APPROVE_OPTION)
+        {
+          java.io.File choice = chooser.getSelectedFile();
+          jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
+          String warnmsg=null;
+          String warnttl=null;
+          try {
+            v_client.vclient.storeDocument(choice);
+          }
+          catch (Error ex)
+          {
+            warnttl = "Serious Problem saving Vamsas Document";
+            warnmsg = ex.toString();
+            jalview.bin.Cache.log.error("Error Whilst saving document to "+choice,ex);
+            
+          }
+          catch (Exception ex)
+          {
+            warnttl = "Problem saving Vamsas Document.";
+            warnmsg = ex.toString();
+            jalview.bin.Cache.log.warn("Exception Whilst saving document to "+choice,ex);
+            
+          }
+          if (warnmsg!=null)
+          {
+            JOptionPane.showInternalMessageDialog(Desktop.desktop,
+
+                  warnmsg, warnttl,
+                  JOptionPane.ERROR_MESSAGE);
+          }
+        }
+    }
+  }
   /**
    * hide vamsas user gui bits when a vamsas document event is being handled.
    * @param b true to hide gui, false to reveal gui