Neeed to know protocol for annotation loading
[jalview.git] / src / jalview / gui / AlignFrame.java
index 3688462..bb722a5 100755 (executable)
@@ -592,7 +592,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
           dset.deleteSequence(0);
         }
 
-        firePropertyChange("Alignment", null, null);
+        firePropertyChange("Alignment", null, viewport.alignment.getSequences());
 
         updateEditMenuBar();
       }
@@ -618,7 +618,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
 
   public void save_actionPerformed(ActionEvent e)
   {
-    if(fileName==null || currentFileFormat==null)
+    if(fileName==null
+       || currentFileFormat==null
+       || fileName.startsWith("http")
+        )
       saveAs_actionPerformed(null);
     else
       saveAlignment(fileName, currentFileFormat);
@@ -673,6 +676,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
 
   public boolean saveAlignment(String file, String format)
   {
+    boolean success = true;
+
     if (format.equalsIgnoreCase("Jalview"))
     {
       String shortName = title;
@@ -683,15 +688,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
             java.io.File.separatorChar) + 1);
       }
 
-      new Jalview2XML().SaveAlignment(this, file, shortName);
+      success = new Jalview2XML().SaveAlignment(this, file, shortName);
 
       statusBar.setText("Successfully saved to file: "
                           +fileName+" in "
                           +format +" format.");
 
-
-      // USE Jalview2XML to save this file
-      return true;
     }
     else
     {
@@ -717,28 +719,37 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
 
       if (output == null)
       {
-        return false;
-      }
-
-      try
-      {
-        java.io.PrintWriter out = new java.io.PrintWriter(
-            new java.io.FileWriter(file));
-
-        out.print(output);
-        out.close();
-        this.setTitle(file);
-        statusBar.setText("Successfully saved to file: "
-                          +fileName+" in "
-                          +format +" format.");
-        return true;
+        success = false;
       }
-      catch (Exception ex)
+      else
       {
-        ex.printStackTrace();
+        try
+        {
+          java.io.PrintWriter out = new java.io.PrintWriter(
+              new java.io.FileWriter(file));
+
+          out.print(output);
+          out.close();
+          this.setTitle(file);
+          statusBar.setText("Successfully saved to file: "
+                            + fileName + " in "
+                            + format + " format.");
+        }
+        catch (Exception ex)
+        {
+          success = false;
+          ex.printStackTrace();
+        }
       }
     }
-    return false;
+
+    if (!success)
+      JOptionPane.showInternalMessageDialog(
+          this, "Couldn't save file: " + fileName,
+          "Error Saving File",
+          JOptionPane.WARNING_MESSAGE);
+
+    return success;
   }
 
   /**
@@ -979,7 +990,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     if(originalSource!=null)
     {
       originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
-      originalSource.firePropertyChange("alignment", null,null);
+      originalSource.firePropertyChange("alignment",
+                                        null,
+                                        originalSource.alignment.getSequences());
     }
   }
 
@@ -1003,7 +1016,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     if(originalSource!=null)
     {
       originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
-      originalSource.firePropertyChange("alignment", null,null);
+      originalSource.firePropertyChange("alignment",
+                                        null,
+                                        originalSource.alignment.getSequences());
     }
   }
 
@@ -1268,7 +1283,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
      }
      else
      {
-       sequences = new FormatAdapter().readFile(str, "Paste", format);
+       sequences = new FormatAdapter().readFile(str, "Paste", format).getSequencesArray();
      }
 
      AlignmentI alignment = null;
@@ -1547,6 +1562,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
       sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false);
     }
 
+    alignPanel.repaint();
+
     PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
   }
 
@@ -2657,9 +2674,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
       tp = new TreePanel(alignPanel, type, pwType);
     }
 
-    title = title + " from " + this.title;
+    title += " from ";
+
     if(viewport.viewName!=null)
-      title+= " ("+viewport.viewName+")";
+      title+= viewport.viewName+" of ";
+
+    title += this.title;
 
     Desktop.addInternalFrame(tp, title, 600, 500);
   }
@@ -3267,7 +3287,7 @@ public void drop(DropTargetDropEvent evt)
       }
 
       boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport.
-          alignment, file);
+          alignment, file, protocol);
 
       if (!isAnnotation)
       {