001/** 002 * 003 */ 004package icy.sequence.edit; 005 006import icy.sequence.Sequence; 007 008import java.awt.Image; 009 010import javax.swing.undo.CannotUndoException; 011 012/** 013 * Default lazy sequence data undoable edit (do a complete sequence data copy to restore previous 014 * state).<br> 015 * Do not handle redo operation to not consume too much memory. 016 * 017 * @author Stephane 018 */ 019public class DataSequenceEdit extends AbstractSequenceEdit 020{ 021 Sequence previous; 022 023 public DataSequenceEdit(Sequence previous, Sequence sequence, String name, Image icon) 024 { 025 super(sequence, name, icon); 026 027 this.previous = previous; 028 } 029 030 public DataSequenceEdit(Sequence previous, Sequence sequence, String name) 031 { 032 this(previous, sequence, name, null); 033 } 034 035 public DataSequenceEdit(Sequence previous, Sequence sequence, Image icon) 036 { 037 this(previous, sequence, "Sequence data changed", icon); 038 } 039 040 public DataSequenceEdit(Sequence previous, Sequence sequence) 041 { 042 this(previous, sequence, "Sequence data changed", null); 043 } 044 045 @Override 046 public void undo() throws CannotUndoException 047 { 048 super.undo(); 049 050 // undo 051 getSequence().copyDataFrom(previous); 052 } 053 054 @Override 055 public boolean canRedo() 056 { 057 return false; 058 } 059}