# HG changeset patch # User Raimund Renkert # Date 1347019428 0 # Node ID c91e7db0fd4bcf85e9c39823191cb2261708c79e # Parent 1cfe788325d58db1cdf69b45a3375d1895eba433 Set data for characteristic diameter for use in parameter matrix UI. flys-artifacts/trunk@5382 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Sep 07 12:03:48 2012 +0000 @@ -1,3 +1,21 @@ +2012-09-07 Raimund Renkert + + * doc/conf/artifacts/minfo.xml: + Add data fields for characteristic bed and bedload diameter. + + * src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java: + Use parametermatrix as UI provider and set the correct data. + + * src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java, + src/main/java/de/intevation/flys/artifacts/states/MultiStringArrayState.java: + Updated method parameter. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: + Added i18n strings. + 2012-09-07 Raimund Renkert Issue 791. diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/doc/conf/artifacts/minfo.xml --- a/flys-artifacts/doc/conf/artifacts/minfo.xml Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/minfo.xml Fri Sep 07 12:03:48 2012 +0000 @@ -197,7 +197,8 @@ - + + diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MultiStringArrayState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MultiStringArrayState.java Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MultiStringArrayState.java Fri Sep 07 12:03:48 2012 +0000 @@ -35,7 +35,7 @@ try { creator.addAttr(select, "type", "options", true); - for (KVP kvp: getOptions(artifact, name)) { + for (KVP kvp: getOptions(artifact, name, context)) { Element item = creator.create("item"); creator.addAttr(item, "label", kvp.getValue().toString(), true); creator.addAttr(item, "value", kvp.getKey().toString(), true); @@ -80,7 +80,8 @@ protected abstract KVP[] getOptions( Artifact artifact, - String parameterName + String parameterName, + CallContext context ) throws IllegalArgumentException; diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java Fri Sep 07 12:03:48 2012 +0000 @@ -39,7 +39,8 @@ @Override protected KVP[] getOptions( Artifact artifact, - String parameterName + String parameterName, + CallContext context ) throws IllegalArgumentException { diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/CharDiameter.java Fri Sep 07 12:03:48 2012 +0000 @@ -1,17 +1,26 @@ package de.intevation.flys.artifacts.states.minfo; +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.apache.poi.hssf.record.formula.functions.Rows; import org.w3c.dom.Element; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.common.model.KVP; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.artifacts.states.DefaultState; +import de.intevation.flys.artifacts.states.MultiStringArrayState; -public class CharDiameter extends DefaultState { +public class CharDiameter extends MultiStringArrayState { - public static final String UI_PROVIDER = "minfo.bed.char_diameter"; + private static final Logger logger = Logger.getLogger(CharDiameter.class); + + public static final String UI_PROVIDER = "parameter-matrix"; private static final String CHAR_DIAMETER_MIN = "calc.bed.dmin"; private static final String CHAR_DIAMETER_MAX = "calc.bed.dmax"; @@ -55,25 +64,31 @@ } @Override - protected Element[] createItems( - XMLUtils.ElementCreator cr, - Artifact artifact, - String name, - CallContext context) + protected KVP[] getOptions( + Artifact artifact, + String parameterName, + CallContext context + ) + throws IllegalArgumentException { CallMeta meta = context.getMeta(); - Element[] calcs = new Element[CHAR_DIAMETER.length]; + List> rows = new ArrayList>(); + String key = parameterName; for (int i = 0; i < CHAR_DIAMETER.length; ++i) { String calc = CHAR_DIAMETER[i]; - calcs[i] = createItem( - cr, new String[] { - Resources.getMsg(meta, calc, calc), - calc - }); + rows.add(new KVP (calc, + Resources.getMsg(meta, calc, calc))); } - return calcs; + return rows.toArray(new KVP[rows.size()]); + } + + @Override + protected String getLabelFor(CallContext cc, String parameterName, + String value) throws IllegalArgumentException { + + return Resources.getMsg(cc.getMeta(), value, value); } } diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Sep 07 12:03:48 2012 +0000 @@ -442,3 +442,6 @@ module.fixanalysis = Fix Analysis module.new_map = New Map module.new_chart = New Chart + +load_diameter = Bedload Diameter +bed_diameter = Bed Diameter diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Sep 07 12:03:48 2012 +0000 @@ -445,3 +445,6 @@ module.fixanalysis = Fixierungsanalyse module.new_map = Neue Karte module.new_chart = Neues Diagramm + +load_diameter = Geschiebedurchmesser +bed_diameter = Sohldurchmesser diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Sep 07 12:03:48 2012 +0000 @@ -444,3 +444,7 @@ module.fixanalysis = Fixierungsanalyse module.new_map = Neue Karte module.new_chart = Neues Diagramm + +load_diameter = Geschiebedurchmesser +bed_diameter = Sohldurchmesser + diff -r 1cfe788325d5 -r c91e7db0fd4b flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Fri Sep 07 11:58:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Sep 07 12:03:48 2012 +0000 @@ -443,3 +443,6 @@ module.fixanalysis = Fix Analysis module.new_map = New Map module.new_chart = New Chart + +load_diameter = Bedload Diameter +bed_diameter = Bed Diameter