Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/StyleHelper.java @ 2986:176d915573e9
Added 18n for datacage officiallines.
flys-client/trunk@5004 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 13 Jul 2012 19:32:34 +0000 |
parents | 6d4a80b668a4 |
children | a6b7f0585761 |
rev | line source |
---|---|
2909
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Element; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import org.w3c.dom.NodeList; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.client.shared.model.Style; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.client.shared.model.StyleSetting; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 public class StyleHelper { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 private static final Logger logger = Logger.getLogger(StyleHelper.class); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 public static Style getStyle (Element element) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 if (!element.getTagName().equals("theme")) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 return null; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 NodeList list = element.getElementsByTagName("field"); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 Style style = new Style(); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 style.setName (element.getAttribute("name")); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 style.setFacet (element.getAttribute("facet")); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 try { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 int ndx = Integer.parseInt(element.getAttribute("index")); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 style.setIndex (ndx); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 catch(NumberFormatException nfe) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 return null; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 for(int i = 0; i < list.getLength(); i++) { |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 Element e = (Element) list.item(i); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 String hidden = e.getAttribute("hidden"); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 StyleSetting set = new StyleSetting ( |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 e.getAttribute("name"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 e.getAttribute("default"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 e.getAttribute("display"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 e.getAttribute("hints"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 e.getAttribute("type"), |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 (hidden != null ? Boolean.valueOf(hidden) : false) |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 ); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 style.appendStyleSetting(set); |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 return style; |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 } |
6d4a80b668a4
Added missing StyleHelper class from last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |