Mercurial > dive4elements > river
changeset 1622:6d0299d63819
#325 Create human readable label for the selected DEM (used in the static UI part).
flys-artifacts/trunk@2795 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 21 Sep 2011 10:08:47 +0000 |
parents | 6d3c1f4d0e8c |
children | 0221451a24fe |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java |
diffstat | 2 files changed, 63 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Sep 19 18:46:44 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Sep 21 10:08:47 2011 +0000 @@ -1,3 +1,11 @@ +2011-09-21 Ingo Weinzierl <ingo@intevation.de> + + flys/issue325 (FLYS Client: Auswahl des DGM zeigt numerischen Wert an) + + * src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java: Write + a better label for the selected DEM into the static DESCRIBE. Use the + name of the DEM file as label instead of the database id. + 2011-09-16 Bjoern Schilberg <bjoern.schilberg@intevation.de> * doc/mapserver/fontset.txt:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java Mon Sep 19 18:46:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java Wed Sep 21 10:08:47 2011 +0000 @@ -1,13 +1,68 @@ package de.intevation.flys.artifacts.states; +import java.io.File; + +import org.w3c.dom.Element; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.CallContext; + +import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; + +import de.intevation.flys.model.DGM; + + /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class DGMSelect extends DefaultState { + private static final Logger logger = Logger.getLogger(DGMSelect.class); + + @Override protected String getUIProvider() { return "dgm_datacage_panel"; } + + + @Override + protected Element createStaticData( + ElementCreator creator, + CallContext cc, + String name, + String value, + String type + ) { + Element dataElement = creator.create("data"); + creator.addAttr(dataElement, "name", name, true); + creator.addAttr(dataElement, "type", type, true); + + Element itemElement = creator.create("item"); + creator.addAttr(itemElement, "value", value, true); + + creator.addAttr(itemElement, "label", getLabel(cc, value), true); + dataElement.appendChild(itemElement); + + return dataElement; + } + + + public static String getLabel(CallContext cc, String value) { + logger.debug("Create label for value: " + value); + + try { + DGM dgm = DGM.getDGM(Integer.parseInt(value)); + + File file = new File(dgm.getPath()); + return file.getName(); + } + catch (NumberFormatException nfe) { + logger.warn("Cannot parse int value: '" + value + "'"); + } + + return ""; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :