X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fundo%2FUndoReorder.java;fp=src%2Ftim%2Fprune%2Fundo%2FUndoReorder.java;h=38c460e7f65fa309d0eba8be982e4acbb0a99957;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/undo/UndoReorder.java b/src/tim/prune/undo/UndoReorder.java new file mode 100644 index 0000000..38c460e --- /dev/null +++ b/src/tim/prune/undo/UndoReorder.java @@ -0,0 +1,47 @@ +package tim.prune.undo; + +import tim.prune.I18nManager; +import tim.prune.data.DataPoint; +import tim.prune.data.Track; +import tim.prune.data.TrackInfo; + +/** + * Abstract operation to undo a reordering by replacing track contents with a shallow copy + */ +public abstract class UndoReorder implements UndoOperation +{ + /** Shallow copy of whole track contents */ + private DataPoint[] _contents = null; + /** Description */ + private String _description = null; + + /** + * Constructor + * @param inTrack track contents to copy + * @param inDescKey description key + */ + public UndoReorder(Track inTrack, String inDescKey) + { + _contents = inTrack.cloneContents(); + _description = I18nManager.getText(inDescKey); + } + + /** + * @return description + */ + public String getDescription() { + return _description; + } + + + /** + * Perform the undo operation on the given Track + * @param inTrackInfo TrackInfo object on which to perform the operation + */ + public void performUndo(TrackInfo inTrackInfo) throws UndoException + { + // restore track to previous values + inTrackInfo.getTrack().replaceContents(_contents); + inTrackInfo.getSelection().clearAll(); + } +}