Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java @ 1660:804c58c56422
Extracted/use StringUtil.wWrap .
flys-artifacts/trunk@2859 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 28 Sep 2011 15:37:59 +0000 |
parents | 6d0299d63819 |
children | 8a2cbf947395 |
rev | line source |
---|---|
927
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
1622
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
3 import java.io.File; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
4 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
5 import org.w3c.dom.Element; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
6 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
7 import org.apache.log4j.Logger; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
8 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
9 import de.intevation.artifacts.CallContext; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
10 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
12 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
13 import de.intevation.flys.model.DGM; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
14 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
15 |
927
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 /** |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 */ |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 public class DGMSelect extends DefaultState { |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
1622
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
21 private static final Logger logger = Logger.getLogger(DGMSelect.class); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
22 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
23 |
927
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 @Override |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 protected String getUIProvider() { |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1051
diff
changeset
|
26 return "dgm_datacage_panel"; |
927
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 } |
1622
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
28 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
29 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
30 @Override |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
31 protected Element createStaticData( |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
32 ElementCreator creator, |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
33 CallContext cc, |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
34 String name, |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
35 String value, |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
36 String type |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
37 ) { |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
38 Element dataElement = creator.create("data"); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
39 creator.addAttr(dataElement, "name", name, true); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
40 creator.addAttr(dataElement, "type", type, true); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
41 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
42 Element itemElement = creator.create("item"); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
43 creator.addAttr(itemElement, "value", value, true); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
44 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
45 creator.addAttr(itemElement, "label", getLabel(cc, value), true); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
46 dataElement.appendChild(itemElement); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
47 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
48 return dataElement; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
49 } |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
50 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
51 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
52 public static String getLabel(CallContext cc, String value) { |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
53 logger.debug("Create label for value: " + value); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
54 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
55 try { |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
56 DGM dgm = DGM.getDGM(Integer.parseInt(value)); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
57 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
58 File file = new File(dgm.getPath()); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
59 return file.getName(); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
60 } |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
61 catch (NumberFormatException nfe) { |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
62 logger.warn("Cannot parse int value: '" + value + "'"); |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
63 } |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
64 |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
65 return ""; |
6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
66 } |
927
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 } |
53a2be494765
Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |