# HG changeset patch # User Ingo Weinzierl # Date 1316599727 0 # Node ID 6d0299d6381901df1bffe76d61e086e17b9d92f9 # Parent 6d3c1f4d0e8c544f405f86c872f4a80362e632f8 #325 Create human readable label for the selected DEM (used in the static UI part). flys-artifacts/trunk@2795 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6d3c1f4d0e8c -r 6d0299d63819 flys-artifacts/ChangeLog --- 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 + + 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 * doc/mapserver/fontset.txt: diff -r 6d3c1f4d0e8c -r 6d0299d63819 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java --- 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 Ingo Weinzierl */ 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 :