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