X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fundo%2FUndoCreatePoint.java;fp=src%2Ftim%2Fprune%2Fundo%2FUndoCreatePoint.java;h=7d297fe460f13fc9bb76ff145c1f6537cd50dba6;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/undo/UndoCreatePoint.java b/src/tim/prune/undo/UndoCreatePoint.java new file mode 100644 index 0000000..7d297fe --- /dev/null +++ b/src/tim/prune/undo/UndoCreatePoint.java @@ -0,0 +1,37 @@ +package tim.prune.undo; + +import tim.prune.I18nManager; +import tim.prune.data.TrackInfo; + +/** + * Undo creation of new point + */ +public class UndoCreatePoint implements UndoOperation +{ + /** + * @return description of operation + */ + public String getDescription() + { + return I18nManager.getText("undo.createpoint"); + } + + + /** + * 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 + { + if (inTrackInfo.getTrack().getNumPoints() < 1) + { + throw new UndoException(getDescription()); + } + // Reset selection if last point selected + if (inTrackInfo.getSelection().getCurrentPointIndex() == (inTrackInfo.getTrack().getNumPoints()-1)) { + inTrackInfo.getSelection().clearAll(); // Note: Informers told twice now! + } + // Remove last point + inTrackInfo.getTrack().cropTo(inTrackInfo.getTrack().getNumPoints() - 1); + } +}