annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java @ 1862:4cc21f0a470e

Handle Annotation Facets in DischargeLongitudinalSection diagrams. flys-artifacts/trunk@3211 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 10 Nov 2011 10:20:40 +0000
parents f7d890f4855f
children 5642a83420f2
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.FacetTypes;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
19 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
20
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
21 import de.intevation.flys.utils.StringUtil;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
22
1737
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
23 /**
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
24 * 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
25 */
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 public class WaterlevelPairSelectState
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 extends DefaultState
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 implements FacetTypes
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 /** 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
31 private static Logger logger = Logger.getLogger(
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
32 WaterlevelPairSelectState.class);
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
34
1737
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
35 /** Trivial constructor. */
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 public WaterlevelPairSelectState() {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 }
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 /** 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
41 @Override
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 protected String getUIProvider() {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 return "datacage_twin_panel";
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 }
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46
1737
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
47 /**
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
48 * 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
49 */
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 @Override
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 public Object computeAdvance(
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 FLYSArtifact artifact,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 String hash,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 CallContext context,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 List<Facet> facets,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 Object old
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 ) {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 //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
59 return "";
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
60 }
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
61
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
62
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 * 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
65 * @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
66 * @param name DataName, expceted to be "diffids".
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
67 */
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
68 @Override
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
69 protected Element[] createItems(
1694
2b9f0ca1449b Fix import from last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1693
diff changeset
70 ElementCreator cr,
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
71 Artifact artifact,
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
72 String name,
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
73 CallContext context)
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
74 {
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
75 logger.debug("createItems: " + name);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
76 if (name.equals("diffids")) {
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
77 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
78 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
79 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
80 FLYSArtifact flys = (FLYSArtifact) artifact;
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
81 String s = flys.getDataAsString("diffids");
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
82 value.setTextContent(s);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
83 item.appendChild(label);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
84 item.appendChild(value);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
85 return new Element[] { item };
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
86 }
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
87 return new Element[] {};
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 }
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
89
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
90
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
91 /**
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
92 * 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
93 */
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
94 @Override
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
95 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
96 FLYSArtifact flys,
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
97 ElementCreator creator,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
98 CallContext cc,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
99 String name,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
100 String value,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
101 String type
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
102 ) {
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
103 Element dataElement = creator.create("data");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
104 creator.addAttr(dataElement, "name", name, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
105 creator.addAttr(dataElement, "type", type, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
106
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
107 Element itemElement = creator.create("item");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
108 creator.addAttr(itemElement, "value", value, 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 String[] labels = getLabels(cc, value);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
111 Object[] obj = new Object[] { labels[0] };
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 // TODO own i18n
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
114 String attrValue = Resources.getMsg(
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
115 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
116 //I18N_STATIC_KEY, I18N_STATIC_KEY, obj);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
117
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
118 creator.addAttr(itemElement, "label", attrValue, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
119 dataElement.appendChild(itemElement);
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 return dataElement;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
122 }
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
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 * 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
127 * from the CalculationResult.
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 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
130 String[] recommendations = value.split("#");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
131 String displayString = "";
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
132
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
133 // 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
134 // like "W (Q=1) - W (Q=2)".
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
135 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
136 String[] minuendParts = StringUtil
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
137 .unbracket(recommendations[i+0])
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
138 .split(";");
1737
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
139 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
140 displayString += "(" + minuendParts[3];
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
141 }
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
142 else {
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
143 displayString += "([error]";
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
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
146 displayString += " - ";
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
147
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
148 String[] subtrahendParts = StringUtil
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
149 .unbracket(recommendations[i+1])
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
150 .split(";");
1737
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
151 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
152 displayString += subtrahendParts[3] + ") ";
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
153 }
1737
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
154 else {
d26911cac2e4 Create label from data String to revive names in client.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1694
diff changeset
155 displayString += "[error])";
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
156 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
157 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
158
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
159 return new String[] { displayString };
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
160 }
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
161 }
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org