9063
|
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.inundationduration; |
|
10 |
9078
|
11 import java.util.HashMap; |
|
12 import java.util.Map; |
|
13 |
9063
|
14 import org.apache.log4j.Logger; |
9481
|
15 import org.dive4elements.artifactdatabase.data.StateData; |
9063
|
16 import org.dive4elements.artifacts.Artifact; |
9078
|
17 import org.dive4elements.artifacts.CallContext; |
9481
|
18 import org.dive4elements.artifacts.common.utils.XMLUtils; |
9078
|
19 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
|
20 import org.dive4elements.river.artifacts.states.AddTableDataHelper; |
9063
|
21 import org.dive4elements.river.artifacts.states.DefaultState; |
9481
|
22 import org.dive4elements.river.artifacts.uinfo.salix.ScenarioTypeState; |
9078
|
23 import org.w3c.dom.Element; |
9063
|
24 |
|
25 /** State in which to fetch years for sedminent load calculation. */ |
|
26 public class LoadScenarioSelect extends DefaultState { |
|
27 private static final long serialVersionUID = 1L; |
|
28 /** The log used in this class. */ |
|
29 private static Logger log = Logger.getLogger(LoadScenarioSelect.class); |
|
30 |
|
31 /** |
|
32 * The default constructor that initializes an empty State object. |
|
33 */ |
|
34 public LoadScenarioSelect() { |
|
35 } |
|
36 |
|
37 /** Year Select Widget. */ |
|
38 @Override |
|
39 protected String getUIProvider() { |
9078
|
40 return "uinfo.sedimentheight_select"; |
|
41 } |
|
42 |
|
43 @Override |
|
44 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { |
|
45 final String datakey = "sedimentheight"; |
|
46 try { |
|
47 if (datakey.equals(name)) { |
|
48 |
|
49 final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "cm", context.getMeta()); |
|
50 |
9273
|
51 helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from"); |
9078
|
52 helper.addColumn(1, "cm", "60", "Delta [cm]", "INTEGER", "RIGHT", null); |
|
53 |
|
54 for (int i = -200; i < 210; i = i + 10) { |
|
55 final Map<String, String> row = new HashMap<>(); |
|
56 row.put("cm", Integer.toString(i)); |
|
57 helper.addRow(row); |
|
58 |
|
59 } |
|
60 helper.submitMapToXml(); |
|
61 } |
|
62 } |
|
63 catch (final IllegalArgumentException iae) { |
|
64 iae.printStackTrace(); |
|
65 } |
9063
|
66 } |
|
67 |
|
68 @Override |
|
69 public boolean validate(final Artifact artifact) throws IllegalArgumentException { |
|
70 return true; |
9481
|
71 } |
9222
|
72 |
9481
|
73 @Override |
|
74 protected Element createData(final XMLUtils.ElementCreator cr, final Artifact artifact, final StateData data, final CallContext context) { |
|
75 return ScenarioTypeState.changeHeaderForCurrentState("state.uinfo.inundation.scenario", data.getName(), cr, context); |
9063
|
76 } |
|
77 } |
|
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |