# HG changeset patch # User Ingo Weinzierl # Date 1300438242 0 # Node ID 2e510c998adb00e0396ae84a1e4f2718f37be40e # Parent 2d6e02787d0054cb8d25ca978cc15f4f46fc1b9e New state for the location/distance input and some litte modifications of the DefaultState. flys-artifacts/trunk@1512 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 2d6e02787d00 -r 2e510c998adb flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Mar 17 16:37:39 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Mar 18 08:50:42 2011 +0000 @@ -1,3 +1,12 @@ +2011-03-18 Ingo Weinzierl + + * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: + Append an attribute 'uiprovider' to the dynamic UI node. + + * src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java: + New. A state for the location/distance selection of the WINFO + parameterization. + 2011-03-17 Ingo Weinzierl * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: diff -r 2d6e02787d00 -r 2e510c998adb flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Thu Mar 17 16:37:39 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Fri Mar 18 08:50:42 2011 +0000 @@ -41,10 +41,11 @@ ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); - Element ui = ProtocolUtils.createArtNode( + String label = Resources.getMsg(context.getMeta(), getID(), getID()); + Element ui = ProtocolUtils.createArtNode( creator, "state", - new String[] { "name" }, - new String[] { getID() }); + new String[] { "name", "uiprovider", "label" }, + new String[] { getID(), getUIProvider(), label }); Map theData = getData(); if (theData == null) { diff -r 2d6e02787d00 -r 2e510c998adb flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java Fri Mar 18 08:50:42 2011 +0000 @@ -0,0 +1,105 @@ +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.common.utils.XMLUtils; + +import de.intevation.artifactdatabase.ProtocolUtils; +import de.intevation.artifactdatabase.data.StateData; + +import de.intevation.flys.artifacts.resources.Resources; + +/** + * @author Ingo Weinzierl + */ +public class LocationDistanceSelect extends DefaultState { + + /** The logger used in this class.*/ + private static Logger logger = Logger.getLogger(LocationDistanceSelect.class); + + + /** The default step width.*/ + public static final String DEFAULT_STEP = "100"; + + /** + * The default constructor that initializes an empty State object. + */ + public LocationDistanceSelect() { + } + + protected Element createData( + XMLUtils.ElementCreator cr, + StateData data, + CallContext context) + { + Element select = ProtocolUtils.createArtNode( + cr, "select", null, null); + + cr.addAttr(select, "name", data.getName(), true); + + Element label = ProtocolUtils.createArtNode( + cr, "label", null, null); + + Element choices = ProtocolUtils.createArtNode( + cr, "choices", null, null); + + label.setTextContent(Resources.getMsg( + context.getMeta(), + data.getName(), + data.getName())); + + select.appendChild(label); + + return select; + } + + + protected Element[] createItems( + XMLUtils.ElementCreator cr, + String name, + CallContext context) + { + // TODO Insert correct min/max values! + + if (name.equals("ld_from")) { + Element min = createItem(cr, new String[] {"min", "1"}); + return new Element[] { min }; + } + else if (name.equals("ld_to")) { + Element max = createItem(cr, new String[] {"max", "10"}); + return new Element[] { max }; + } + else { + Element step = createItem(cr, new String[] {"step", DEFAULT_STEP}); + return new Element[] { step }; + } + + } + + + 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; + } + + + protected String getUIProvider() { + return "location_distance_panel"; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :