Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 3407:70e9d56e21fc
Set default value of MINFO SQ relation's outliers parameter to 3.
flys-artifacts/trunk@5059 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 11:45:15 +0000 |
parents | d9af29a4bb85 |
children | 1bb6fb621167 |
comparison
equal
deleted
inserted
replaced
3406:3732e1bab0aa | 3407:70e9d56e21fc |
---|---|
193 return Resources.getMsg(meta, value, value); | 193 return Resources.getMsg(meta, value, value); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 /** | |
199 * This method returns the default value and description for <i>data</i>. | |
200 * Note, that this method returns the defaults only if <i>USE_DEFAULTS</i> | |
201 * is set; otherwise, null is returned. | |
202 * @param context The CallContext used for i18n. | |
203 * @param data The data objects that the defaults are for. | |
204 * @return a String[] with [default value, default label]. | |
205 */ | |
206 protected String[] getDefaultsFor(CallContext context, StateData data) { | |
207 if (USE_DEFAULTS) { | |
208 String defValue = (String) data.getValue(); | |
209 String defDesc = null; | |
210 | |
211 if (defValue != null && defValue.length() > 0) { | |
212 defDesc = Resources.getMsg( | |
213 context.getMeta(), | |
214 defValue, | |
215 defValue); | |
216 } | |
217 | |
218 if (defValue != null && defDesc != null) { | |
219 return new String[] { defValue, defDesc }; | |
220 } | |
221 } | |
222 | |
223 return null; | |
224 } | |
225 | |
226 | |
198 public Element describe( | 227 public Element describe( |
199 Artifact artifact, | 228 Artifact artifact, |
200 Document document, | 229 Document document, |
201 Node root, | 230 Node root, |
202 CallContext context, | 231 CallContext context, |
239 | 268 |
240 data = data != null ? data : getData(name); | 269 data = data != null ? data : getData(name); |
241 | 270 |
242 Element select = createData(creator, artifact, data, context); | 271 Element select = createData(creator, artifact, data, context); |
243 | 272 |
244 if (USE_DEFAULTS) { | 273 String[] defaults = getDefaultsFor(context, data); |
245 String defValue = (String) data.getValue(); | 274 if (defaults != null && defaults.length > 1) { |
246 String defDesc = null; | 275 creator.addAttr(select, "defaultValue", defaults[0], true); |
247 | 276 creator.addAttr(select, "defaultLabel", defaults[1], true); |
248 if (defValue != null && defValue.length() > 0) { | |
249 defDesc = Resources.getMsg( | |
250 context.getMeta(), | |
251 defValue, | |
252 defValue); | |
253 } | |
254 | |
255 if (defValue != null && defDesc != null) { | |
256 creator.addAttr(select, "defaultValue", defValue, true); | |
257 creator.addAttr(select, "defaultLabel", defDesc, true); | |
258 } | |
259 } | 277 } |
260 | 278 |
261 appendItems(artifact, creator, name, context, select); | 279 appendItems(artifact, creator, name, context, select); |
262 ui.appendChild(select); | 280 ui.appendChild(select); |
263 } | 281 } |