File: ConnectToPointFunction.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (64 lines) | stat: -rw-r--r-- 1,675 bytes parent folder | download | duplicates (4)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package tim.prune.function.media;

import tim.prune.App;
import tim.prune.GenericFunction;
import tim.prune.I18nManager;
import tim.prune.cmd.ConnectMediaCmd;
import tim.prune.data.AudioClip;
import tim.prune.data.DataPoint;
import tim.prune.data.Photo;


/**
 * Function to connect either a photo or an audio clip (or both) to the current point
 */
public class ConnectToPointFunction extends GenericFunction
{
	/**
	 * Constructor
	 * @param inApp app object
	 */
	public ConnectToPointFunction(App inApp) {
		super(inApp);
	}

	/**
	 * @return name key
	 */
	public String getNameKey() {
		return "function.connecttopoint";
	}

	/**
	 * Perform function
	 */
	public void begin()
	{
		DataPoint point = _app.getTrackInfo().getCurrentPoint();
		Photo photo = _app.getTrackInfo().getCurrentPhoto();
		AudioClip audio = _app.getTrackInfo().getCurrentAudio();
		ConnectMediaCmd command = new ConnectMediaCmd(point, photo, audio);
		command.setDescription(getDescription(photo, audio));
		command.setConfirmText(I18nManager.getText("confirm.media.connect"));
		_app.execute(command);
	}

	/**
	 * @return description of operation including photo and/or audio filename(s)
	 */
	public String getDescription(Photo inPhoto, AudioClip inAudio)
	{
		final String photoName = (inPhoto == null ? null : inPhoto.getName());
		final String audioName = (inAudio == null ? null : inAudio.getName());
		return I18nManager.getText("undo.connect", denull(photoName)
			+ ((photoName != null && audioName != null) ? ", " : "")
			+ denull(audioName));
	}

	/**
	 * Convert null strings to empty strings
	 */
	private String denull(String inName) {
		return inName == null ? "" : inName;
	}
}