From 85882b9349f5d4707a43e9bdd4007101d3aa42ec Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 2 May 2007 12:25:44 +0000 Subject: [PATCH] undo stackempty error fix, refactored do and undo() method to take array of alignments for operations that result in hide/show of alignment annotation, convenience method for getting alignment object array for all views --- src/jalview/gui/AlignFrame.java | 60 ++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 58650cb..3c74f43 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1049,8 +1049,28 @@ public class AlignFrame } } - - + /** + * + * @return alignment objects for all views + */ + AlignmentI[] getViewAlignments() + { + if (alignPanels!=null) + { + Enumeration e = alignPanels.elements(); + AlignmentI[] als = new AlignmentI[alignPanels.size()]; + for (int i=0; e.hasMoreElements(); i++) + { + als[i] = ((AlignmentPanel) e.nextElement()).av.getAlignment(); + } + return als; + } + if (viewport!=null) + { + return new AlignmentI[] { viewport.alignment }; + } + return null; + } /** * DOCUMENT ME! * @@ -1058,9 +1078,11 @@ public class AlignFrame */ protected void undoMenuItem_actionPerformed(ActionEvent e) { + if (viewport.historyList.empty()) + return; CommandI command = (CommandI)viewport.historyList.pop(); viewport.redoList.push(command); - command.undoCommand(); + command.undoCommand(getViewAlignments()); AlignViewport originalSource = getOriginatingSource(command); updateEditMenuBar(); @@ -1088,7 +1110,7 @@ public class AlignFrame CommandI command = (CommandI) viewport.redoList.pop(); viewport.historyList.push(command); - command.doCommand(); + command.doCommand(getViewAlignments()); AlignViewport originalSource = getOriginatingSource(command); updateEditMenuBar(); @@ -1582,19 +1604,43 @@ public class AlignFrame alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation was duplicated earlier alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a); } - - } } if (!newAlignment) { + // propagate alignment changed. viewport.setEndSeq(alignment.getHeight()); if (annotationAdded) { - alignPanel.annotationPanel.adjustPanelHeight(); + // Duplicate sequence annotation in all views. + AlignmentI[] alview = this.getViewAlignments(); + for (int avnum=0;avnum