X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FRedundancyPanel.java;h=ec896d596f591b07148f892554478e05e3750da8;hb=3e3378e2ccfea39a2b161600c5a2029716acd1b7;hp=50183eb9e2d79d751e8452343aea44ba5be26cfc;hpb=f3bc67915e61855d87866b4a614fe7a953813408;p=jalview.git diff --git a/src/jalview/gui/RedundancyPanel.java b/src/jalview/gui/RedundancyPanel.java index 50183eb..ec896d5 100755 --- a/src/jalview/gui/RedundancyPanel.java +++ b/src/jalview/gui/RedundancyPanel.java @@ -19,15 +19,16 @@ package jalview.gui; import jalview.datamodel.*; - import jalview.jbgui.*; +import jalview.util.Comparison; +import jalview.commands.*; import java.awt.event.*; import java.util.*; import javax.swing.event.*; -import jalview.util.Comparison; + import javax.swing.*; @@ -223,16 +224,6 @@ public class RedundancyPanel extends GSliderPanel implements Runnable */ public void applyButton_actionPerformed(ActionEvent e) { - historyList.push(new HistoryItem("Remove redundancy", - ap.av.alignment, HistoryItem.HIDE)); - - if ((historyList.size() == 1) || - !af.historyList.contains(historyList.firstElement())) - { - af.addHistoryItem((HistoryItem) historyList.firstElement()); - af.updateEditMenuBar(); - } - Vector del = new Vector(); undoButton.setEnabled(true); @@ -244,31 +235,48 @@ public class RedundancyPanel extends GSliderPanel implements Runnable { if (value <= redundancy[i]) { - SequenceI seq = originalSequences[i]; - ap.av.alignment.deleteSequence(seq); - PaintRefresher.Refresh(this,ap.av.getSequenceSetId(),seq,null); - del.add(seq); - if (sg != null) - { - sg.deleteSequence(seq, false); - } + del.addElement(originalSequences[i]); } } - // This has to be done before the restoreHistoryItem method of alignFrame will // actually restore these sequences. if (del.size() > 0) { - for (int i = 0, j = del.size(); i < j; i++) + SequenceI [] deleted = new SequenceI[del.size()]; + + int width = 0; + for (int i = 0; i < del.size(); i++) + { + deleted[i] = (SequenceI)del.elementAt(i); + if(deleted[i].getLength()>width) + width = deleted[i].getLength(); + } + + EditCommand cut = new EditCommand("Remove Redundancy", + EditCommand.CUT, deleted,0,width,ap.av.alignment); + + for (int i = 0; i < del.size(); i++) + { + ap.av.alignment.deleteSequence( deleted[i] ); + PaintRefresher.Refresh(this, + ap.av.getSequenceSetId(), + true, + true); + if (sg != null) { - SequenceI sq = (SequenceI) del.elementAt(i); - sq.deleteChars(0, sq.getLength()); + sg.deleteSequence(deleted[i], false); } + } + + historyList.push(cut); + + ap.alignFrame.addHistoryItem(cut); + + ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences()); } - ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences()); - af.updateEditMenuBar(); + } @@ -279,18 +287,20 @@ public class RedundancyPanel extends GSliderPanel implements Runnable */ public void undoButton_actionPerformed(ActionEvent e) { - HistoryItem hi = (HistoryItem) historyList.pop(); - af.restoreHistoryItem(hi); + CommandI command = (CommandI) historyList.pop(); + command.undoCommand(); + + if (ap.av.historyList.contains(command)) + { + ap.av.historyList.remove(command); + af.updateEditMenuBar(); + } + + ap.repaint(); if (historyList.size() == 0) { undoButton.setEnabled(false); - - if (af.historyList.contains(hi)) - { - af.historyList.remove(hi); - af.updateEditMenuBar(); - } } }