ingo@927: package de.intevation.flys.artifacts.states; ingo@927: ingo@927: import org.w3c.dom.Element; ingo@927: ingo@2579: import org.apache.log4j.Logger; ingo@2579: ingo@927: import de.intevation.artifacts.Artifact; ingo@927: import de.intevation.artifacts.CallContext; ingo@927: import de.intevation.artifacts.CallMeta; ingo@927: ingo@927: import de.intevation.artifacts.common.utils.XMLUtils; ingo@927: ingo@927: import de.intevation.artifactdatabase.ProtocolUtils; ingo@927: ingo@927: import de.intevation.flys.artifacts.resources.Resources; ingo@927: ingo@927: ingo@927: /** ingo@927: * @author Ingo Weinzierl ingo@927: */ ingo@927: public class FloodplainChoice extends DefaultState { ingo@927: ingo@2579: public static final String OPTION = "floodplain.option"; ingo@2579: public static final String ACTIVE = "floodplain.active"; ingo@2579: public static final String INACTIVE = "floodplain.inactive"; ingo@2579: ingo@2579: private static final Logger logger = ingo@2579: Logger.getLogger(FloodplainChoice.class); ingo@927: ingo@927: ingo@927: @Override ingo@927: protected String getUIProvider() { ingo@927: return "boolean_panel"; ingo@927: } ingo@927: ingo@927: ingo@927: @Override ingo@927: protected Element[] createItems( ingo@927: XMLUtils.ElementCreator cr, ingo@927: Artifact artifact, ingo@927: String name, ingo@927: CallContext context) ingo@927: { ingo@927: CallMeta meta = context.getMeta(); ingo@927: ingo@927: Element option = createItem( ingo@927: cr, ingo@927: new String[] { Resources.getMsg(meta, OPTION, OPTION), "true" }); ingo@927: ingo@927: return new Element[] { option }; ingo@927: } ingo@927: ingo@927: ingo@2579: @Override ingo@2579: protected String getLabelFor( ingo@2579: CallContext cc, ingo@2579: String name, ingo@2579: String value, ingo@2579: String type ingo@2579: ) { ingo@2579: logger.debug("GET LABEL FOR '" + name + "' / '" + value + "'"); ingo@2579: if (value != null && value.equals("true")) { ingo@2579: return Resources.getMsg(cc.getMeta(), ACTIVE, ACTIVE); ingo@2579: } ingo@2579: else { ingo@2579: return Resources.getMsg(cc.getMeta(), INACTIVE, INACTIVE); ingo@2579: } ingo@2579: } ingo@2579: ingo@2579: ingo@927: protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { ingo@927: Element item = ProtocolUtils.createArtNode(cr, "item", null, null); ingo@927: Element label = ProtocolUtils.createArtNode(cr, "label", null, null); ingo@927: Element value = ProtocolUtils.createArtNode(cr, "value", null, null); ingo@927: ingo@927: String[] arr = (String[]) obj; ingo@927: ingo@927: label.setTextContent(arr[0]); ingo@927: value.setTextContent(arr[1]); ingo@927: ingo@927: item.appendChild(label); ingo@927: item.appendChild(value); ingo@927: ingo@927: return item; ingo@927: } ingo@927: } ingo@927: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :