Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java @ 1745:4ae7df2a74ed
Fix NPE in WDiff-diagram because no ranges present in masterartifact.
flys-artifacts/trunk@3039 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 19 Oct 2011 16:06:01 +0000 |
parents | 8a2cbf947395 |
children | f7d890f4855f |
rev | line source |
---|---|
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
7 import org.w3c.dom.Element; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
8 |
1693
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
9 import de.intevation.artifacts.Artifact; |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.CallContext; |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 |
1693
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
12 import de.intevation.artifactdatabase.ProtocolUtils; |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifactdatabase.state.Facet; |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
15 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
16 |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.artifacts.FLYSArtifact; |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
18 import de.intevation.flys.artifacts.model.CalculationResult; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
19 import de.intevation.flys.artifacts.model.FacetTypes; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
20 import de.intevation.flys.artifacts.model.WQKms; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
21 import de.intevation.flys.artifacts.resources.Resources; |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
23 import de.intevation.flys.utils.FLYSUtils; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
24 import de.intevation.flys.utils.StringUtil; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
25 |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
26 /** |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
27 * State in which the user selects 1 to n pairs of Waterlevels and alikes. |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
28 */ |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 public class WaterlevelPairSelectState |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 extends DefaultState |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 implements FacetTypes |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 { |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 /** The logger that is used in this state. */ |
1693
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
34 private static Logger logger = Logger.getLogger( |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
35 WaterlevelPairSelectState.class); |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
37 |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
38 /** Trivial constructor. */ |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 public WaterlevelPairSelectState() { |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 } |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 /** Specify to display a datacage_twin_panel. */ |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 @Override |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 protected String getUIProvider() { |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 return "datacage_twin_panel"; |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 } |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
50 /** |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
51 * Overridden to do nothing. |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
52 */ |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 @Override |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 public Object computeAdvance( |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 FLYSArtifact artifact, |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 String hash, |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 CallContext context, |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 List<Facet> facets, |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 Object old |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 ) { |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 //Get data and do stuff, do not calculate |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
62 return ""; |
1693
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
63 } |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
64 |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
65 |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
66 /** |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
67 * Create elements for document (prepopulated with data, if any). |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
68 * @param artifact FLYSArtifact to get data from. |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
69 * @param name DataName, expceted to be "diffids". |
1693
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
70 */ |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
71 @Override |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
72 protected Element[] createItems( |
1694
2b9f0ca1449b
Fix import from last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1693
diff
changeset
|
73 ElementCreator cr, |
1693
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
74 Artifact artifact, |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
75 String name, |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
76 CallContext context) |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
77 { |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
78 logger.debug("createItems: " + name); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
79 if (name.equals("diffids")) { |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
80 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
81 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
82 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
83 FLYSArtifact flys = (FLYSArtifact) artifact; |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
84 String s = flys.getDataAsString("diffids"); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
85 value.setTextContent(s); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
86 item.appendChild(label); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
87 item.appendChild(value); |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
88 return new Element[] { item }; |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
89 } |
5f1156d61e9e
Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1670
diff
changeset
|
90 return new Element[] {}; |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 } |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
92 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
93 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
94 /** |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
95 * Creats the data element used for the static part of DESCRIBE document. |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
96 */ |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
97 @Override |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
98 protected Element createStaticData( |
1743
8a2cbf947395
Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1737
diff
changeset
|
99 FLYSArtifact flys, |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
100 ElementCreator creator, |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
101 CallContext cc, |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
102 String name, |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
103 String value, |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
104 String type |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
105 ) { |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
106 Element dataElement = creator.create("data"); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
107 creator.addAttr(dataElement, "name", name, true); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
108 creator.addAttr(dataElement, "type", type, true); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
109 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
110 Element itemElement = creator.create("item"); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
111 creator.addAttr(itemElement, "value", value, true); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
112 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
113 String[] labels = getLabels(cc, value); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
114 Object[] obj = new Object[] { labels[0] }; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
115 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
116 // TODO own i18n |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
117 String attrValue = Resources.getMsg( |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
118 cc.getMeta(), "wsp.selected.string", "wsp.selected.string", obj); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
119 //I18N_STATIC_KEY, I18N_STATIC_KEY, obj); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
120 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
121 creator.addAttr(itemElement, "label", attrValue, true); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
122 dataElement.appendChild(itemElement); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
123 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
124 return dataElement; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
125 } |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
126 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
127 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
128 /** |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
129 * Get name to display for selected watelerlevels (for example "Q=123") |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
130 * from the CalculationResult. |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
131 */ |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
132 public static String[] getLabels(CallContext cc, String value) { |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
133 String[] recommendations = value.split("#"); |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
134 String displayString = ""; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
135 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
136 // Walk over all selected recommendations and create label |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
137 // like "W (Q=1) - W (Q=2)". |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
138 for (int i = 0; i < recommendations.length; i+=2) { |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
139 String[] minuendParts = StringUtil |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
140 .unbracket(recommendations[i+0]) |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
141 .split(";"); |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
142 if(minuendParts.length >= 4) { |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
143 displayString += "(" + minuendParts[3]; |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
144 } |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
145 else { |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
146 displayString += "([error]"; |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
147 } |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
148 |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
149 displayString += " - "; |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
150 |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
151 String[] subtrahendParts = StringUtil |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
152 .unbracket(recommendations[i+1]) |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
153 .split(";"); |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
154 if(subtrahendParts.length >= 4) { |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
155 displayString += subtrahendParts[3] + ") "; |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
156 } |
1737
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
157 else { |
d26911cac2e4
Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1694
diff
changeset
|
158 displayString += "[error])"; |
1663
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
159 } |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
160 } |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
161 |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
162 return new String[] { displayString }; |
4fbd43061315
Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1624
diff
changeset
|
163 } |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
164 } |
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |