File: FilterDefinition.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 (59 lines) | stat: -rw-r--r-- 1,441 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
48
49
50
51
52
53
54
55
56
57
58
59
package tim.prune.load.babel;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JPanel;
import javax.swing.SwingUtilities;

/**
 * Superclass of all the filter definition panels, to be added in the cardset
 * of the AddFilterDialog
 */
public abstract class FilterDefinition extends JPanel
{
	/** Parent dialog to inform of parameter changes */
	private AddFilterDialog _parentDialog = null;
	/** Listener for key presses on the parameter entry fields */
	protected KeyListener _paramChangeListener = null;

	/**
	 * Constructor
	 */
	public FilterDefinition(AddFilterDialog inFilterDialog)
	{
		_parentDialog = inFilterDialog;
		_paramChangeListener = new KeyAdapter() {
			public void keyTyped(KeyEvent arg0) {
				SwingUtilities.invokeLater(new Runnable() {
					public void run() {
						_parentDialog.filterParamsChanged();
					}
				});
			}
		};
	}

	/**
	 * @return true if the filter definition is valid
	 */
	public abstract boolean isFilterValid();

	/**
	 * @return filter definition to pass to gpsbabel
	 */
	public String getString()
	{
		return "-x " + getFilterName() + getParameters();
	}

	/** @return filter name */
	protected abstract String getFilterName();

	/** Construct the GUI elements and add them to the panel */
	protected abstract void makePanelContents();

	/** @return filter parameters */
	protected abstract String getParameters();
}