9222
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by Intevation GmbH |
|
3 * |
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
6 * documentation coming with Dive4Elements River for details. |
|
7 */ |
|
8 |
|
9 package org.dive4elements.river.artifacts.uinfo.salix; |
|
10 |
|
11 import java.util.HashMap; |
|
12 import java.util.Map; |
|
13 |
|
14 import org.apache.log4j.Logger; |
9273
|
15 import org.dive4elements.artifactdatabase.data.StateData; |
9222
|
16 import org.dive4elements.artifacts.Artifact; |
|
17 import org.dive4elements.artifacts.CallContext; |
9273
|
18 import org.dive4elements.artifacts.common.utils.XMLUtils; |
9222
|
19 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
|
20 import org.dive4elements.river.artifacts.states.AddTableDataHelper; |
|
21 import org.dive4elements.river.artifacts.states.DefaultState; |
|
22 import org.w3c.dom.Element; |
|
23 |
|
24 /** State in which to fetch years for sedminent load calculation. */ |
|
25 public class LoadScenarioSelectLimit5 extends DefaultState { |
|
26 private static final long serialVersionUID = 1L; |
|
27 /** The log used in this class. */ |
|
28 private static Logger log = Logger.getLogger(LoadScenarioSelectLimit5.class); |
|
29 |
|
30 /** |
|
31 * The default constructor that initializes an empty State object. |
|
32 */ |
|
33 public LoadScenarioSelectLimit5() { |
|
34 } |
|
35 |
|
36 /** Year Select Widget. */ |
|
37 @Override |
|
38 protected String getUIProvider() { |
|
39 return "uinfo.sedimentheight_select.limit5"; |
|
40 } |
|
41 |
|
42 @Override |
|
43 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { |
9273
|
44 |
|
45 // the client is expecting helper input. bad abstraction. the table does not appear, only because no columns are added. |
|
46 // TODO Implement abstraction without helper on client side and then delete this method |
9222
|
47 final String datakey = "sedimentheight"; |
|
48 try { |
|
49 if (datakey.equals(name)) { |
|
50 |
|
51 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "cm", context.getMeta()); |
9273
|
52 for (int i = -200; i < -100; i = i + 10) { |
9222
|
53 final Map<String, String> row = new HashMap<>(); |
|
54 row.put("cm", Integer.toString(i)); |
|
55 helper.addRow(row); |
|
56 } |
|
57 helper.submitMapToXml(); |
|
58 } |
|
59 } |
|
60 catch (final IllegalArgumentException iae) { |
|
61 iae.printStackTrace(); |
|
62 } |
|
63 } |
|
64 |
|
65 @Override |
9273
|
66 protected Element createData(final XMLUtils.ElementCreator cr, final Artifact artifact, final StateData data, final CallContext context) { |
|
67 return ScenarioTypeState.changeHeaderForCurrentState("state.uinfo.inundation.scenario.regional", data.getName(), cr, context); |
|
68 } |
9222
|
69 |
|
70 } |
|
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |