File: TimeSensitiveFunction.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 (43 lines) | stat: -rw-r--r-- 1,236 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
package tim.prune.function;

import tim.prune.App;
import tim.prune.GenericFunction;
import tim.prune.I18nManager;
import tim.prune.data.Field;

import javax.swing.JOptionPane;

public abstract class TimeSensitiveFunction extends GenericFunction
{
	private static boolean _mangleTimestampsConfirmed = false;

	public TimeSensitiveFunction(App inApp) {
		super(inApp);
	}

	/**
	 * If necessary, ask the user to confirm the operation
	 * @return true if it's ok to proceed
	 */
	protected boolean confirmTimestampMangling()
	{
		if (_mangleTimestampsConfirmed) {
			return true;
		}
		// check whether Timestamp field exists, and if so confirm reversal
		int selStart = _app.getTrackInfo().getSelection().getStart();
		int selEnd = _app.getTrackInfo().getSelection().getEnd();
		if (!_app.getTrackInfo().getTrack().hasData(Field.TIMESTAMP, selStart, selEnd)) {
			return true;
		}
		if (JOptionPane.showConfirmDialog(_app.getFrame(),
				I18nManager.getText("dialog.confirmmangletimes.text"),
				I18nManager.getText("dialog.confirmmangletimes.title"),
				JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
		{
			_mangleTimestampsConfirmed = true;
			return true;
		}
		return false;
	}
}