comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/EnterMultipleLocationsState.java @ 3786:4adc35aa655c

merged flys-artifacts/2.9.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:47 +0200
parents 1cfe788325d5
children 8e66293c5369
comparison
equal deleted inserted replaced
3719:e82acd5c86f7 3786:4adc35aa655c
1 package de.intevation.flys.artifacts.states;
2
3 import org.apache.log4j.Logger;
4 import org.w3c.dom.Element;
5
6 import de.intevation.artifacts.Artifact;
7 import de.intevation.artifacts.CallContext;
8 import de.intevation.artifacts.common.utils.StringUtils;
9 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
10 import de.intevation.flys.artifacts.WINFOArtifact;
11
12
13 /**
14 * Get me doubles (km).
15 */
16 public class EnterMultipleLocationsState extends EnterLocationState {
17 /** The logger for this class. */
18 private static Logger logger = Logger.getLogger(EnterMultipleLocationsState.class);
19
20 @Override
21 protected String getUIProvider() {
22 logger.debug("multi location panel");
23 return "multi_location_panel";
24 }
25
26
27 /** Deal with multiple double values. */
28 @Override
29 protected String getLabelFor(
30 CallContext cc,
31 String name,
32 String value,
33 String type
34 ) {
35 String label = "";
36 String[] vals = value.split(" ");
37 for (int i = 0; i < vals.length; i++) {
38 vals[i] = super.getLabelFor(cc, name, vals[i], type);
39 }
40
41 return StringUtils.join(" ", vals);
42 }
43
44 /**
45 * This method creates a list of items. These items represent the amount of
46 * input data that is possible for this state.
47 *
48 * @param cr The ElementCreator.
49 * @param name The name of the amount of data.
50 *
51 * @return a list of items.
52 */
53 @Override
54 protected Element[] createItems(
55 ElementCreator cr,
56 Artifact artifact,
57 String name,
58 CallContext context
59 ) {
60 if (name.equals("reference_endpoint")) {
61 Element[] elements = new Element[1];
62 WINFOArtifact winfo = (WINFOArtifact) artifact;
63 Double km = winfo.getReferenceStartKm();
64 elements[0] = createItem(
65 cr,
66 new String[] {"start_km", km.toString()});
67 return elements;
68 }
69 return null;
70 }
71
72 }
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org