]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/undo/UndoReorder.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / src / tim / prune / undo / UndoReorder.java
diff --git a/src/tim/prune/undo/UndoReorder.java b/src/tim/prune/undo/UndoReorder.java
new file mode 100644 (file)
index 0000000..38c460e
--- /dev/null
@@ -0,0 +1,47 @@
+package tim.prune.undo;\r
+\r
+import tim.prune.I18nManager;\r
+import tim.prune.data.DataPoint;\r
+import tim.prune.data.Track;\r
+import tim.prune.data.TrackInfo;\r
+\r
+/**\r
+ * Abstract operation to undo a reordering by replacing track contents with a shallow copy\r
+ */\r
+public abstract class UndoReorder implements UndoOperation\r
+{\r
+       /** Shallow copy of whole track contents */\r
+       private DataPoint[] _contents = null;\r
+       /** Description */\r
+       private String _description = null;\r
+\r
+       /**\r
+        * Constructor\r
+        * @param inTrack track contents to copy\r
+        * @param inDescKey description key\r
+        */\r
+       public UndoReorder(Track inTrack, String inDescKey)\r
+       {\r
+               _contents = inTrack.cloneContents();\r
+               _description = I18nManager.getText(inDescKey);\r
+       }\r
+\r
+       /**\r
+        * @return description\r
+        */\r
+       public String getDescription() {\r
+               return _description;\r
+       }\r
+\r
+\r
+       /**\r
+        * Perform the undo operation on the given Track\r
+        * @param inTrackInfo TrackInfo object on which to perform the operation\r
+        */\r
+       public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
+       {\r
+               // restore track to previous values\r
+               inTrackInfo.getTrack().replaceContents(_contents);\r
+               inTrackInfo.getSelection().clearAll();\r
+       }\r
+}\r