Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java @ 9184:dace17e26d33
code review uinfo.inundationduration
author | gernotbelger |
---|---|
date | Wed, 27 Jun 2018 14:07:02 +0200 |
parents | 2f5052835b76 |
children | c7e5285d434f |
comparison
equal
deleted
inserted
replaced
9183:65543c75bfbb | 9184:dace17e26d33 |
---|---|
24 * | 24 * |
25 */ | 25 */ |
26 public abstract class RadioSelect extends DefaultState { | 26 public abstract class RadioSelect extends DefaultState { |
27 | 27 |
28 private static final long serialVersionUID = 1L; | 28 private static final long serialVersionUID = 1L; |
29 private Artifact artifact; | |
29 | 30 |
30 public RadioSelect() { | 31 public RadioSelect() { |
31 | 32 |
32 } | 33 } |
33 | 34 |
34 protected abstract LinkedHashMap<String, String> makeEntries(CallMeta meta, Artifact artifact); // AUSNAHMSWEISE EXPLIZITER TYP, damit gewährleistet ist, | 35 protected abstract LinkedHashMap<String, String> makeEntries(CallMeta meta, Artifact artifact); // AUSNAHMSWEISE EXPLIZITER TYP, damit Reihenfolge nicht |
35 // dass die Reihenfolge | 36 // verrutscht |
36 // nicht verrutscht | |
37 | 37 |
38 @Override | 38 @Override |
39 protected final String getUIProvider() { | 39 protected final String getUIProvider() { |
40 return "radio_panel"; | 40 return "radio_panel"; |
41 } | 41 } |
42 | 42 |
43 @Override | 43 @Override |
44 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { | 44 protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { |
45 | |
46 // REMEBER: we need it for getLabelFor later | |
47 this.artifact = artifact; | |
48 | |
45 final CallMeta meta = context.getMeta(); | 49 final CallMeta meta = context.getMeta(); |
46 final Map<String, String> entries = makeEntries(meta, artifact); | 50 final Map<String, String> entries = makeEntries(meta, artifact); |
47 | 51 |
48 final Element[] elements = new Element[entries.size()]; | 52 final Element[] elements = new Element[entries.size()]; |
49 int i = 0; | 53 int i = 0; |
56 return elements; | 60 return elements; |
57 } | 61 } |
58 | 62 |
59 @Override | 63 @Override |
60 protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) { | 64 protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) { |
61 // könnte nicht davon ausgegangen werden, dass die entries immer zuerst in createItems erzeugt werden und da quasi | 65 // artifacts must be set in "createItems" -> createItems has to be called first |
62 // "lazy" initialisiert werden? | 66 final Map<String, String> entries = makeEntries(cc.getMeta(), this.artifact); |
63 final Map<String, String> entries = makeEntries(cc.getMeta(), null); | |
64 | 67 |
65 final String valueToSet = entries.get(value) != null ? entries.get(value) : value; | 68 final String valueToSet = entries.get(value) != null ? entries.get(value) : value; |
66 return super.getLabelFor(cc, name, valueToSet, type); | 69 return super.getLabelFor(cc, name, valueToSet, type); |
67 } | 70 } |
68 } | 71 } |