Add remove seq from multiple views, must fire alignmentChange from originating source
authoramwaterhouse <Andrew Waterhouse>
Wed, 15 Nov 2006 16:41:51 +0000 (16:41 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 15 Nov 2006 16:41:51 +0000 (16:41 +0000)
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/AlignFrame.java

index ff7646f..e99c27f 100755 (executable)
@@ -700,29 +700,68 @@ public void itemStateChanged(ItemEvent evt)
     }\r
   }\r
 \r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param e DOCUMENT ME!\r
+   */\r
   protected void undoMenuItem_actionPerformed()\r
   {\r
     CommandI command = (CommandI)viewport.historyList.pop();\r
     viewport.redoList.push(command);\r
     command.undoCommand();\r
 \r
-    viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+    AlignViewport originalSource = getOriginatingSource(command);\r
+\r
+    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
     updateEditMenuBar();\r
-    viewport.firePropertyChange("alignment", null,\r
-                                viewport.getAlignment().getSequences());\r
+    originalSource.firePropertyChange("alignment", null,null);\r
   }\r
 \r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param e DOCUMENT ME!\r
+   */\r
   protected void redoMenuItem_actionPerformed()\r
   {\r
     CommandI command = (CommandI) viewport.redoList.pop();\r
     viewport.historyList.push(command);\r
     command.doCommand();\r
-    viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;\r
+\r
+    AlignViewport originalSource = getOriginatingSource(command);\r
+    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;\r
 \r
     updateEditMenuBar();\r
-    viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());\r
+    originalSource.firePropertyChange("alignment", null, null);\r
   }\r
 \r
+  AlignViewport getOriginatingSource(CommandI command)\r
+  {\r
+    AlignViewport originalSource = viewport;\r
+    //For sequence removal and addition, we need to fire\r
+   //the property change event FROM the viewport where the\r
+   //original alignment was altered\r
+    if (command instanceof EditCommand)\r
+    {\r
+      EditCommand editCommand = (EditCommand) command;\r
+      AlignmentI al = editCommand.getAlignment();\r
+      Vector comps = (Vector) PaintRefresher.components\r
+          .get(viewport.getSequenceSetId());\r
+      for (int i = 0; i < comps.size(); i++)\r
+      {\r
+        if (comps.elementAt(i) instanceof AlignmentPanel)\r
+        {\r
+          if (al == ( (AlignmentPanel) comps.elementAt(i)).av.alignment)\r
+          {\r
+            originalSource = ( (AlignmentPanel) comps.elementAt(i)).av;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
+    return originalSource;\r
+  }\r
 \r
   public void moveSelectedSequences(boolean up)\r
   {\r
index 18ebf0e..42934b9 100755 (executable)
@@ -961,10 +961,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     viewport.redoList.push(command);
     command.undoCommand();
 
+    AlignViewport originalSource = getOriginatingSource(command);
 
-    viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
+    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;
     updateEditMenuBar();
-    viewport.firePropertyChange("alignment", null,null);
+    originalSource.firePropertyChange("alignment", null,null);
   }
 
   /**
@@ -977,12 +978,40 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener
     CommandI command = (CommandI) viewport.redoList.pop();
     viewport.historyList.push(command);
     command.doCommand();
-    viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
+
+    AlignViewport originalSource = getOriginatingSource(command);
+    originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns()!=null;
 
     updateEditMenuBar();
-    viewport.firePropertyChange("alignment", null, null);
+    originalSource.firePropertyChange("alignment", null, null);
   }
 
+  AlignViewport getOriginatingSource(CommandI command)
+  {
+    AlignViewport originalSource = viewport;
+    //For sequence removal and addition, we need to fire
+   //the property change event FROM the viewport where the
+   //original alignment was altered
+    if (command instanceof EditCommand)
+    {
+      EditCommand editCommand = (EditCommand) command;
+      AlignmentI 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)
+        {
+          if (al == ( (AlignmentPanel) comps.elementAt(i)).av.alignment)
+          {
+            originalSource = ( (AlignmentPanel) comps.elementAt(i)).av;
+            break;
+          }
+        }
+      }
+    }
+    return originalSource;
+  }
 
   /**
    * DOCUMENT ME!