Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java @ 302:f526f02e8ce2
Bugfix: States are filled with data before they describe themself.
flys-artifacts/trunk@1664 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 12 Apr 2011 07:49:36 +0000 |
parents | b5c99532f898 |
children | 89bd0417418f |
line wrap: on
line source
package de.intevation.flys.artifacts.states; import org.apache.log4j.Logger; import org.w3c.dom.Element; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.flys.artifacts.resources.Resources; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class CalculationSelect extends DefaultState { /** The logger that is used in this class.*/ private static Logger logger = Logger.getLogger(CalculationSelect.class); /** Constant value for the reference line calculation.*/ public static final String CALCULATION_SURFACE_CURVE = "calc.surface.curve"; /** Constant value for the differences calculation.*/ public static final String CALCULATION_DURATION_CURVE = "calc.duration.curve"; /** Constant value for the flood map calculation.*/ public static final String CALCULATION_FLOOD_MAP = "calc.flood.map"; /** Constant value for the profile calculation.*/ public static final String CALCULATION_DISCHARGE_LONGITUDINAL_CURVE = "calc.discharge.longitudinal.section"; /** Constant value for the state discharge curve calculation.*/ public static final String CALCULATION_DISCHARGE_CURVE = "calc.discharge.curve"; /** An array that holds all available calculation modes.*/ public static final String[] CALCULATIONS = { CALCULATION_SURFACE_CURVE, CALCULATION_FLOOD_MAP, CALCULATION_DISCHARGE_CURVE, CALCULATION_DURATION_CURVE, CALCULATION_DISCHARGE_LONGITUDINAL_CURVE }; protected Element[] createItems( XMLUtils.ElementCreator cr, String name, CallContext context) { CallMeta meta = context.getMeta(); Element[] calcs = new Element[CALCULATIONS.length]; int i = 0; for (String calc: CALCULATIONS) { calcs[i++] = createItem( cr, new String[] { Resources.getMsg(meta, calc, calc), calc }); } return calcs; } protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { Element item = ProtocolUtils.createArtNode(cr, "item", null, null); Element label = ProtocolUtils.createArtNode(cr, "label", null, null); Element value = ProtocolUtils.createArtNode(cr, "value", null, null); String[] arr = (String[]) obj; label.setTextContent(arr[0]); value.setTextContent(arr[1]); item.appendChild(label); item.appendChild(value); return item; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :