From: amwaterhouse Date: Wed, 15 Nov 2006 16:41:51 +0000 (+0000) Subject: Add remove seq from multiple views, must fire alignmentChange from originating source X-Git-Tag: Release_2_2~109 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6fcda37468514274f893bd4ccf39480ee36ee31d;hp=702d861516f9f04118c97f36ae4d4e08017dde68;p=jalview.git Add remove seq from multiple views, must fire alignmentChange from originating source --- diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index ff7646f..e99c27f 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -700,29 +700,68 @@ public void itemStateChanged(ItemEvent evt) } } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ protected void undoMenuItem_actionPerformed() { CommandI command = (CommandI)viewport.historyList.pop(); viewport.redoList.push(command); command.undoCommand(); - viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null; + AlignViewport originalSource = getOriginatingSource(command); + + originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null; updateEditMenuBar(); - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); + originalSource.firePropertyChange("alignment", null,null); } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ protected void redoMenuItem_actionPerformed() { 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, viewport.getAlignment().getSequences()); + 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; + } public void moveSelectedSequences(boolean up) { diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 18ebf0e..42934b9 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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!