Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/themes/DefaultTheme.java @ 2279:6eb6162f2cd2
Fix i18n
flys-artifacts/trunk@3941 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 06 Feb 2012 16:12:48 +0000 |
parents | 6566c7868456 |
children | fe29b0226faf |
rev | line source |
---|---|
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.themes; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.HashMap; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.Iterator; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import java.util.Map; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Document; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Element; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Node; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.common.utils.XMLUtils; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 /** |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 */ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 public class DefaultTheme implements Theme { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 /** The name of the theme.*/ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 protected String name; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** The description of the theme.*/ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 protected String description; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
1668
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
26 protected String facet; |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
27 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
28 protected int index; |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
29 |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 /** The map storing the fields of this theme.*/ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 protected Map<String, ThemeField> fields; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 /** The map storing the attributes of this theme.*/ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 protected Map<String, String> attr; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 /** |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 * Initializes the components of this Theme. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 */ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 public DefaultTheme(String name, String description) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 this.name = name; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 this.description = description; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 this.fields = new HashMap<String, ThemeField>(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 this.attr = new HashMap<String, String>(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 public void init(Node config) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public String getName() { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 return name; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 public String getDescription() { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 return description; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
1668
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
63 public String getFacet() { |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
64 return facet; |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
65 } |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
66 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
67 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
68 public void setFacet(String facet) { |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
69 this.facet = facet; |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
70 } |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
71 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
72 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
73 public int getIndex() { |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
74 return index; |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
75 } |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
76 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
77 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
78 public void setIndex(int index) { |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
79 this.index = index; |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
80 } |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
81 |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
82 |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 public void addAttribute(String name, String value) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 if (name != null && value != null) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 attr.put(name, value); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 public String getAttribute(String name) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 return attr.get(name); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 public void addField(String name, ThemeField field) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 if (name != null && field != null) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 fields.put(name, field); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 public void setFieldValue(String name, Object value) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 if (name != null && value != null) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 ThemeField field = fields.get(name); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 if (field != null) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 field.setValue(value); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 public ThemeField getField(String name) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 return fields.get(name); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 public String getFieldType(String name) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 ThemeField field = fields.get(name); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 return field != null ? field.getType() : null; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 public Object getFieldValue(String name) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 ThemeField field = fields.get(name); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 return field != null ? field.getValue() : null; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 public Document toXML() { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 Document doc = XMLUtils.newDocument(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 ElementCreator cr = new ElementCreator(doc, null, null); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 Element theme = cr.create("theme"); |
1668
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
138 theme.setAttribute("facet", facet); |
6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
340
diff
changeset
|
139 theme.setAttribute("index", String.valueOf(index)); |
340
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 appendAttributes(cr, theme); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 appendFields(cr, theme); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 doc.appendChild(theme); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 return doc; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 /** |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 * Appends the attributes configured for this theme. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 * |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 * @param cr The ElementCreator. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 * @param theme The document root element. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 */ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 protected void appendAttributes(ElementCreator cr, Element theme) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 Iterator<String> iter = attr.keySet().iterator(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 while (iter.hasNext()) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 String key = iter.next(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 String val = getAttribute(key); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 if (key == null || val == null) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 continue; |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 cr.addAttr(theme, key, val); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 /** |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 * Appends the fields configured for this theme. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 * |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 * @param cr The ElementCreator. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 * @param theme The document root element. |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 */ |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 protected void appendFields(ElementCreator cr, Element theme) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 Iterator<String> iter = fields.keySet().iterator(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 while (iter.hasNext()) { |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 String name = iter.next(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 ThemeField field = getField(name); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 Document doc = field.toXML(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 Node root = doc.getFirstChild(); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 theme.appendChild(theme.getOwnerDocument().importNode(root, true)); |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 } |
b36fd8f21e6a
Implementation of interfaces and its default implementations and a factory to work with themes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |