Loads PDB files from jar file, new views can open PDB file
[jalview.git] / src / jalview / gui / AlignFrame.java
index 3291dca..f483d6f 100755 (executable)
@@ -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);
@@ -974,10 +977,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     command.undoCommand();
 
     AlignViewport originalSource = getOriginatingSource(command);
-
-    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
     updateEditMenuBar();
-    originalSource.firePropertyChange("alignment", null,viewport.getAlignment().getSequences());
+
+    if(originalSource!=null)
+    {
+      originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
+      originalSource.firePropertyChange("alignment", null,null);
+    }
   }
 
   /**
@@ -987,29 +993,37 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
    */
   protected void redoMenuItem_actionPerformed(ActionEvent e)
   {
+    if(viewport.redoList.size()<1)
+      return;
+
     CommandI command = (CommandI) viewport.redoList.pop();
     viewport.historyList.push(command);
     command.doCommand();
 
     AlignViewport originalSource = getOriginatingSource(command);
-    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
-
     updateEditMenuBar();
-    originalSource.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());
+
+    if(originalSource!=null)
+    {
+      originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
+      originalSource.firePropertyChange("alignment", null,null);
+    }
   }
 
   AlignViewport getOriginatingSource(CommandI command)
   {
-    AlignViewport originalSource = viewport;
+    AlignViewport originalSource = null;
     //For sequence removal and addition, we need to fire
    //the property change event FROM the viewport where the
    //original alignment was altered
+    AlignmentI al=null;
     if (command instanceof EditCommand)
     {
       EditCommand editCommand = (EditCommand) command;
-      AlignmentI al = editCommand.getAlignment();
+      al = editCommand.getAlignment();
       Vector comps = (Vector) PaintRefresher.components
           .get(viewport.getSequenceSetId());
+
       for (int i = 0; i < comps.size(); i++)
       {
         if (comps.elementAt(i) instanceof AlignmentPanel)
@@ -1022,6 +1036,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
         }
       }
     }
+
+    if (originalSource == null)
+    {
+      //The original view is closed, we must validate
+      //the current view against the closed view first
+      if (al != null)
+        PaintRefresher.validateSequences(al, viewport.alignment);
+
+      originalSource = viewport;
+    }
+
     return originalSource;
   }
 
@@ -1455,7 +1480,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
   protected void deleteGroups_actionPerformed(ActionEvent e)
   {
     viewport.alignment.deleteAllGroups();
-    viewport.sequenceColours.clear();
+    viewport.sequenceColours = null;
     viewport.setSelectionGroup(null);
     PaintRefresher.Refresh(this, viewport.getSequenceSetId());
     alignPanel.repaint();