001package icy.sequence.edit; 002 003import icy.roi.ROI; 004import icy.sequence.Sequence; 005 006import java.util.Collection; 007 008import javax.swing.undo.CannotRedoException; 009import javax.swing.undo.CannotUndoException; 010 011/** 012 * ROI group remove Sequence edit event 013 * 014 * @author Stephane 015 */ 016public class ROIRemovesSequenceEdit extends AbstractROIsSequenceEdit 017{ 018 public ROIRemovesSequenceEdit(Sequence sequence, Collection<ROI> rois) 019 { 020 super(sequence, rois, (rois.size() > 1) ? "ROI group removed" : "ROI removed"); 021 } 022 023 @Override 024 public void undo() throws CannotUndoException 025 { 026 super.undo(); 027 028 final Sequence sequence = getSequence(); 029 030 sequence.beginUpdate(); 031 try 032 { 033 for (ROI roi : getROIs()) 034 sequence.addROI(roi, false); 035 } 036 finally 037 { 038 sequence.endUpdate(); 039 } 040 } 041 042 @Override 043 public void redo() throws CannotRedoException 044 { 045 super.redo(); 046 047 final Sequence sequence = getSequence(); 048 049 sequence.beginUpdate(); 050 try 051 { 052 for (ROI roi : getROIs()) 053 sequence.removeROI(roi, false); 054 } 055 finally 056 { 057 sequence.endUpdate(); 058 } 059 } 060 061}