]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/undo/UndoCreatePoint.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / src / tim / prune / undo / UndoCreatePoint.java
diff --git a/src/tim/prune/undo/UndoCreatePoint.java b/src/tim/prune/undo/UndoCreatePoint.java
new file mode 100644 (file)
index 0000000..7d297fe
--- /dev/null
@@ -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);
+       }
+}