]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoReorder.java
38c460e7f65fa309d0eba8be982e4acbb0a99957
[GpsPrune.git] / tim / prune / undo / UndoReorder.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.DataPoint;\r
5 import tim.prune.data.Track;\r
6 import tim.prune.data.TrackInfo;\r
7 \r
8 /**\r
9  * Abstract operation to undo a reordering by replacing track contents with a shallow copy\r
10  */\r
11 public abstract class UndoReorder implements UndoOperation\r
12 {\r
13         /** Shallow copy of whole track contents */\r
14         private DataPoint[] _contents = null;\r
15         /** Description */\r
16         private String _description = null;\r
17 \r
18         /**\r
19          * Constructor\r
20          * @param inTrack track contents to copy\r
21          * @param inDescKey description key\r
22          */\r
23         public UndoReorder(Track inTrack, String inDescKey)\r
24         {\r
25                 _contents = inTrack.cloneContents();\r
26                 _description = I18nManager.getText(inDescKey);\r
27         }\r
28 \r
29         /**\r
30          * @return description\r
31          */\r
32         public String getDescription() {\r
33                 return _description;\r
34         }\r
35 \r
36 \r
37         /**\r
38          * Perform the undo operation on the given Track\r
39          * @param inTrackInfo TrackInfo object on which to perform the operation\r
40          */\r
41         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
42         {\r
43                 // restore track to previous values\r
44                 inTrackInfo.getTrack().replaceContents(_contents);\r
45                 inTrackInfo.getSelection().clearAll();\r
46         }\r
47 }\r