felix@2306: package de.intevation.flys.artifacts.states;
felix@2306: 
ingo@3649: import org.apache.log4j.Logger;
ingo@3649: import org.w3c.dom.Element;
ingo@3649: 
ingo@3649: import de.intevation.artifacts.Artifact;
felix@2312: import de.intevation.artifacts.CallContext;
felix@2312: import de.intevation.artifacts.common.utils.StringUtils;
ingo@3649: import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
ingo@3649: import de.intevation.flys.artifacts.WINFOArtifact;
felix@2312: 
felix@2312: 
felix@2306: /**
felix@2306:  * Get me doubles (km).
felix@2306:  */
felix@2306: public class EnterMultipleLocationsState extends EnterLocationState {
ingo@3649:     /** The logger for this class. */
ingo@3649:     private static Logger logger = Logger.getLogger(EnterMultipleLocationsState.class);
felix@2306: 
felix@2306:     @Override
felix@2306:     protected String getUIProvider() {
ingo@3649:         logger.debug("multi location panel");
felix@2306:         return "multi_location_panel";
felix@2306:     }
felix@2312: 
sascha@3076: 
felix@2312:     /** Deal with multiple double values. */
felix@2312:     @Override
felix@2312:     protected String getLabelFor(
felix@2312:         CallContext cc,
felix@2312:         String      name,
felix@2312:         String      value,
felix@2312:         String      type
felix@2312:     ) {
felix@2312:         String[] vals = value.split(" ");
felix@2312:         for (int i = 0; i < vals.length; i++) {
felix@2312:             vals[i] = super.getLabelFor(cc, name, vals[i], type);
felix@2312:         }
felix@2312: 
felix@2314:         return StringUtils.join(" ", vals);
felix@2312:     }
ingo@3649: 
ingo@3649:     /**
ingo@3649:      * This method creates a list of items. These items represent the amount of
ingo@3649:      * input data that is possible for this state.
ingo@3649:      *
ingo@3649:      * @param cr The ElementCreator.
ingo@3649:      * @param name The name of the amount of data.
ingo@3649:      *
ingo@3649:      * @return a list of items.
ingo@3649:      */
ingo@3649:     @Override
ingo@3649:     protected Element[] createItems(
ingo@3649:         ElementCreator cr,
ingo@3649:         Artifact    artifact,
ingo@3649:         String      name,
ingo@3649:         CallContext context
ingo@3649:     ) {
ingo@3649:         if (name.equals("reference_endpoint")) {
ingo@3649:             Element[] elements = new Element[1];
ingo@3649:             WINFOArtifact winfo = (WINFOArtifact) artifact;
ingo@3649:             Double km = winfo.getReferenceStartKm();
ingo@3649:             elements[0] = createItem(
ingo@3649:                 cr,
ingo@3649:                 new String[] {"start_km", km.toString()});
ingo@3649:             return elements;
ingo@3649:         }
ingo@3649:         return null;
ingo@3649:     }
ingo@3649: 
felix@2306: }
felix@2306: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :