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