aboutsummaryrefslogtreecommitdiffstats
path: root/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallParameter.java
blob: 517a0fedcfca4564152ee12af19e1c7cac29d586 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
 * 
 */
package org.openembedded.bc.ui.wizards.install;

class InstallParameter {
	public static final int DT_TEXT = 1;
	public static final int DT_COMBO = 2;
	public static final int DT_LIST = 3;
	public static final int DT_NUMBER = 4;
	public static final int DT_DIRECTORY = 5;
	public static final int DT_FILE = 6;
	public static final int DT_CHECKBOX = 7;
	
	private boolean valid = false;
	private int type;
	private String label;
	private boolean required;
	private String data;
	private String helpURL;
	private String helpText;

	public int getType() {
		return type;
	}

	public String getLabel() {
		return label;
	}

	public boolean isRequired() {
		return required;
	}

	public String getData() {
		return data;
	}

	public String getHelpURL() {
		return helpURL;
	}
	
	public String getHelpText() {
		return helpText;
	}

	public InstallParameter(String var) {
		// {|Datatype|Label|UnRequired|Data|Help|}
		// {|T|Distribution|R|angstrom-2008.1|http://wiki.openembedded.net/index.php/Getting_started#Create_local_configuration|}

		String[] elems = var.split("\\|");

		if (elems.length == 5 || elems.length == 6) {
			if (elems[0].equals("T")) {
				type = DT_TEXT;
			} else if (elems[0].equals("D")) {
				type = DT_DIRECTORY;
			} else if (elems[0].equals("F")) {
				type = DT_FILE;
			} else if (elems[0].equals("C")) {
				type = DT_COMBO;
			} else if (elems[0].equals("B")) {
				type = DT_CHECKBOX;
			} else {
				throw new RuntimeException("Invalid field format: " + var);
			}

			label = elems[1];

			if (elems[2].equals("R")) {
				required = true;
			} else if (elems[2].equals("U")) {
				required = false;
			} else {
				throw new RuntimeException("Invalid field format: " + var);
			}

			data = elems[3].trim();
			
			if (elems[4].trim().length() > 0) {
				helpURL = elems[4].trim();
			}
			
			if (elems.length == 6) {
				helpText = elems[5];
			}

			valid = true;
		} else {
			throw new RuntimeException("Invalid field format: " + var);
		}
	}

	public boolean isValid() {

		return valid;
	}

}