1 package com.explosion.expfmodules.wizard.standard;
2
3 import java.util.HashMap;
4 import java.util.List;
5 import java.util.Map;
6
7 import com.explosion.utilities.preferences.Preference;
8 import com.explosion.utilities.preferences.impl.inmemory.InMemoryPreferencePersister;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 /***
31 * @author Stephen Cowx
32 * Created on 22-Dec-2004
33 */
34 public class PreferenceDataItem
35 {
36 private int sortOrderNumber;
37 private Preference preference;
38 private boolean isMandatory = false;
39 private Map attributes = new HashMap();
40
41 /***
42 * Constructs a dataItem as a single value
43 * @param name
44 * @param type
45 * @param defaultValue
46 * @param store
47 * @throws Exception
48 */
49 public PreferenceDataItem(String name, int type, String defaultValue, List values, Map store) throws Exception
50 {
51 preference = new Preference(name,type,InMemoryPreferencePersister.convertToInstanceOfType(type,defaultValue), store);
52 if (values != null && type == Preference.PROPERTY_TYPE_STRING_CHOICE);
53 preference.setChoiceValues(values);
54 }
55
56 /***
57 * Constructs a dataItem as a single value
58 * @param name
59 * @param type
60 * @param defaultValue
61 * @param store
62 * @throws Exception
63 */
64 public PreferenceDataItem(String name, int type, int collectionType, String defaultValue, List values, Map store) throws Exception
65 {
66 preference = new Preference(name,type,collectionType, InMemoryPreferencePersister.convertToInstanceOfType(collectionType,defaultValue), store);
67 }
68
69 /***
70 * Returns the Label
71 * @return
72 */
73 public String getLabel()
74 {
75 return preference.getLongName();
76 }
77
78 /***
79 * Sets the Label
80 * @param label
81 */
82 public void setLabel(String label)
83 {
84 preference.setLongName(label);
85 }
86
87 /***
88 * Returns the name
89 * @return
90 */
91 public String getName()
92 {
93 return preference.getUniqueIdentifier();
94 }
95
96 /***
97 * Sets the Name
98 * @param name
99 */
100 public void setName(String name)
101 {
102 preference.setUniqueIdentifier(name);
103 }
104
105 /***
106 * Returns the underlying Preference object
107 * @return
108 */
109 public Preference getPreference()
110 {
111 return preference;
112 }
113
114 /***
115 * Sets the Underlying Preference Object
116 * @param preference
117 */
118 public void setPreference(Preference preference)
119 {
120 this.preference = preference;
121 }
122
123 /***
124 * Returns the sortOrder number
125 * This is used for laying out dataitems in a view
126 * @return
127 */
128 public int getSortOrderNumber()
129 {
130 return sortOrderNumber;
131 }
132
133 /***
134 * Sets the sort order number of this data item
135 * @param sortOrderNumber
136 */
137 public void setSortOrderNumber(int sortOrderNumber)
138 {
139 this.sortOrderNumber = sortOrderNumber;
140 }
141
142 /***
143 * Returns the type of this item
144 * These types are exactly the same as the types available for the Preference
145 * object
146 * @return
147 */
148 public int getType()
149 {
150 return preference.getType();
151 }
152
153 /***
154 * Sets the type of this data item
155 * These types are exactly the same as the types available for the Preference
156 * @param type
157 */
158 public void setType(int type)
159 {
160 preference.setType(type);
161 }
162
163
164 /***
165 * returns whether this data item is mandatory or not
166 * @return
167 */
168 public boolean isMandatory()
169 {
170 return isMandatory;
171 }
172
173 /***
174 * @param isMandatory
175 */
176 public void setMandatory(boolean isMandatory)
177 {
178 this.isMandatory = isMandatory;
179 }
180
181 /***
182 * @return Returns the attribute.
183 */
184 public Map getAttributes() {
185 return attributes;
186 }
187
188 /***
189 * @param attribute The attribute to set.
190 */
191 public void setAttributes(Map attributes) {
192 this.attributes = attributes;
193 }
194 }