ingo@136: package de.intevation.flys.artifacts.states; ingo@136: ingo@136: import org.apache.log4j.Logger; ingo@136: ingo@136: import org.w3c.dom.Element; ingo@136: ingo@136: import de.intevation.artifacts.CallContext; ingo@136: ingo@136: import de.intevation.artifacts.common.utils.XMLUtils; ingo@136: ingo@136: import de.intevation.artifactdatabase.ProtocolUtils; ingo@136: import de.intevation.artifactdatabase.data.StateData; ingo@136: ingo@136: import de.intevation.flys.artifacts.resources.Resources; ingo@136: ingo@136: /** ingo@136: * @author Ingo Weinzierl ingo@136: */ ingo@136: public class LocationDistanceSelect extends DefaultState { ingo@136: ingo@136: /** The logger used in this class.*/ ingo@136: private static Logger logger = Logger.getLogger(LocationDistanceSelect.class); ingo@136: ingo@136: ingo@136: /** The default step width.*/ ingo@136: public static final String DEFAULT_STEP = "100"; ingo@136: ingo@136: /** ingo@136: * The default constructor that initializes an empty State object. ingo@136: */ ingo@136: public LocationDistanceSelect() { ingo@136: } ingo@136: ingo@136: protected Element createData( ingo@136: XMLUtils.ElementCreator cr, ingo@136: StateData data, ingo@136: CallContext context) ingo@136: { ingo@136: Element select = ProtocolUtils.createArtNode( ingo@136: cr, "select", null, null); ingo@136: ingo@136: cr.addAttr(select, "name", data.getName(), true); ingo@136: ingo@136: Element label = ProtocolUtils.createArtNode( ingo@136: cr, "label", null, null); ingo@136: ingo@136: Element choices = ProtocolUtils.createArtNode( ingo@136: cr, "choices", null, null); ingo@136: ingo@136: label.setTextContent(Resources.getMsg( ingo@136: context.getMeta(), ingo@136: data.getName(), ingo@136: data.getName())); ingo@136: ingo@136: select.appendChild(label); ingo@136: ingo@136: return select; ingo@136: } ingo@136: ingo@136: ingo@136: protected Element[] createItems( ingo@136: XMLUtils.ElementCreator cr, ingo@136: String name, ingo@136: CallContext context) ingo@136: { ingo@136: // TODO Insert correct min/max values! ingo@136: ingo@136: if (name.equals("ld_from")) { ingo@136: Element min = createItem(cr, new String[] {"min", "1"}); ingo@136: return new Element[] { min }; ingo@136: } ingo@136: else if (name.equals("ld_to")) { ingo@136: Element max = createItem(cr, new String[] {"max", "10"}); ingo@136: return new Element[] { max }; ingo@136: } ingo@136: else { ingo@136: Element step = createItem(cr, new String[] {"step", DEFAULT_STEP}); ingo@136: return new Element[] { step }; ingo@136: } ingo@136: ingo@136: } ingo@136: ingo@136: ingo@136: protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { ingo@136: Element item = ProtocolUtils.createArtNode(cr, "item", null, null); ingo@136: Element label = ProtocolUtils.createArtNode(cr, "label", null, null); ingo@136: Element value = ProtocolUtils.createArtNode(cr, "value", null, null); ingo@136: ingo@136: String[] arr = (String[]) obj; ingo@136: ingo@136: label.setTextContent(arr[0]); ingo@136: value.setTextContent(arr[1]); ingo@136: ingo@136: item.appendChild(label); ingo@136: item.appendChild(value); ingo@136: ingo@136: return item; ingo@136: } ingo@136: ingo@136: ingo@136: protected String getUIProvider() { ingo@136: return "location_distance_panel"; ingo@136: } ingo@136: } ingo@136: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :