Mercurial > dive4elements > river
changeset 2909:6d4a80b668a4
Added missing StyleHelper class from last commit.
flys-client/trunk@4687 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 18 Jun 2012 11:29:33 +0000 |
parents | cd068ff7966d |
children | ab0014c58ecb |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/StyleHelper.java |
diffstat | 2 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Mon Jun 18 11:17:29 2012 +0000 +++ b/flys-client/ChangeLog Mon Jun 18 11:29:33 2012 +0000 @@ -1,3 +1,8 @@ +2012-06-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/server/StyleHelper.java: Added + missing class from last commit. + 2012-06-18 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/server/StyleHelper.java: New
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/StyleHelper.java Mon Jun 18 11:29:33 2012 +0000 @@ -0,0 +1,53 @@ +package de.intevation.flys.client.server; + +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import org.apache.log4j.Logger; + +import de.intevation.flys.client.shared.model.Style; +import de.intevation.flys.client.shared.model.StyleSetting; + + +public class StyleHelper { + + private static final Logger logger = Logger.getLogger(StyleHelper.class); + + + public static Style getStyle (Element element) { + if (!element.getTagName().equals("theme")) { + return null; + } + + NodeList list = element.getElementsByTagName("field"); + Style style = new Style(); + + style.setName (element.getAttribute("name")); + style.setFacet (element.getAttribute("facet")); + + try { + int ndx = Integer.parseInt(element.getAttribute("index")); + style.setIndex (ndx); + } + catch(NumberFormatException nfe) { + return null; + } + + for(int i = 0; i < list.getLength(); i++) { + Element e = (Element) list.item(i); + String hidden = e.getAttribute("hidden"); + + StyleSetting set = new StyleSetting ( + e.getAttribute("name"), + e.getAttribute("default"), + e.getAttribute("display"), + e.getAttribute("hints"), + e.getAttribute("type"), + (hidden != null ? Boolean.valueOf(hidden) : false) + ); + style.appendStyleSetting(set); + } + return style; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :