File: UndoReorder.java

package info (click to toggle)
gpsprune 17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,984 kB
  • ctags: 5,218
  • sloc: java: 39,403; sh: 25; makefile: 17; python: 15
file content (47 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package tim.prune.undo;

import tim.prune.I18nManager;
import tim.prune.data.DataPoint;
import tim.prune.data.Track;
import tim.prune.data.TrackInfo;

/**
 * Abstract operation to undo a reordering by replacing track contents with a shallow copy
 */
public abstract class UndoReorder implements UndoOperation
{
	/** Shallow copy of whole track contents */
	private DataPoint[] _contents = null;
	/** Description */
	private String _description = null;

	/**
	 * Constructor
	 * @param inTrack track contents to copy
	 * @param inDescKey description key
	 */
	public UndoReorder(Track inTrack, String inDescKey)
	{
		_contents = inTrack.cloneContents();
		_description = I18nManager.getText(inDescKey);
	}

	/**
	 * @return description
	 */
	public String getDescription() {
		return _description;
	}


	/**
	 * 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
	{
		// restore track to previous values
		inTrackInfo.getTrack().replaceContents(_contents);
		inTrackInfo.getSelection().clearAll();
	}
}