]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoCreatePoint.java
Version 6, October 2008
[GpsPrune.git] / tim / prune / undo / UndoCreatePoint.java
1 package tim.prune.undo;
2
3 import tim.prune.I18nManager;
4 import tim.prune.data.TrackInfo;
5
6 /**
7  * Undo creation of new point
8  */
9 public class UndoCreatePoint implements UndoOperation
10 {
11         /**
12          * @return description of operation
13          */
14         public String getDescription()
15         {
16                 return I18nManager.getText("undo.createpoint");
17         }
18
19
20         /**
21          * Perform the undo operation on the given Track
22          * @param inTrackInfo TrackInfo object on which to perform the operation
23          */
24         public void performUndo(TrackInfo inTrackInfo) throws UndoException
25         {
26                 if (inTrackInfo.getTrack().getNumPoints() < 1)
27                 {
28                         throw new UndoException(getDescription());
29                 }
30                 // Reset selection if last point selected
31                 if (inTrackInfo.getSelection().getCurrentPointIndex() == (inTrackInfo.getTrack().getNumPoints()-1)) {
32                         inTrackInfo.getSelection().clearAll(); // Note: Informers told twice now!
33                 }
34                 // Remove last point
35                 inTrackInfo.getTrack().cropTo(inTrackInfo.getTrack().getNumPoints() - 1);
36         }
37 }