1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package com.ideo.sweetdevria.config;
35
36
37 import java.io.Serializable;
38 import java.util.ArrayList;
39 import java.util.HashMap;
40 import java.util.List;
41 import java.util.Map;
42
43 import com.ideo.sweetdevria.config.elements.BuilderConfig;
44 import com.ideo.sweetdevria.config.elements.DrawerConfig;
45 import com.ideo.sweetdevria.config.elements.MessageResourcesConfig;
46 import com.ideo.sweetdevria.config.elements.PlugInConfig;
47 import com.ideo.sweetdevria.config.elements.PropertyConfig;
48
49
50
51
52 public class RIAConfigImpl implements Serializable, IRIAConfig {
53
54
55
56
57 private static final long serialVersionUID = -6967421386711409234L;
58
59 protected HashMap messageResources;
60 protected List messageResourcesOrder;
61
62 protected boolean configured;
63
64 protected HashMap builderConfigs;
65
66 protected HashMap drawerConfigs;
67
68 protected ArrayList plugIns;
69
70 protected Map properties;
71
72 public RIAConfigImpl() {
73 builderConfigs = new HashMap();
74 drawerConfigs = new HashMap();
75 messageResources = new HashMap();
76 messageResourcesOrder = new ArrayList();
77 plugIns = new ArrayList();
78 properties = new HashMap();
79 }
80
81
82
83
84
85 public boolean getConfigured() {
86 return configured;
87 }
88
89
90
91
92
93
94 public void addMessageResourcesConfig(final MessageResourcesConfig config) {
95 if (configured) {
96 throw new IllegalStateException("Configuration is frozen");
97 } if(messageResources.containsKey(config.getKey())){
98 return;
99 }else {
100 messageResources.put(config.getKey(), config);
101 messageResourcesOrder.add(config);
102 return;
103 }
104 }
105
106 public void addPlugInConfig(PlugInConfig plugInConfig) {
107 if (configured) {
108 throw new IllegalStateException("Configuration is frozen");
109 } else {
110 plugIns.add(plugInConfig);
111 return;
112 }
113 }
114
115 public void addPropertyConfig(PropertyConfig propertyConfig) {
116 if (configured) {
117 throw new IllegalStateException("Configuration is frozen");
118 } else {
119 if(!properties.containsKey(propertyConfig.getKey()))
120 properties.put(propertyConfig.getKey(), propertyConfig.getValue());
121 return;
122 }
123 }
124
125 public Map getProperties() {
126 return properties;
127 }
128
129 public String getProperty(String key) {
130 return (String)properties.get(key);
131 }
132
133 public MessageResourcesConfig findMessageResourcesConfig(final String key) {
134 return (MessageResourcesConfig) messageResources.get(key);
135 }
136
137 public MessageResourcesConfig[] findMessageResourcesConfigs() {
138 MessageResourcesConfig results[] = new MessageResourcesConfig[messageResourcesOrder.size()];
139 return (MessageResourcesConfig[]) messageResourcesOrder.toArray(results);
140 }
141
142 public void freeze() {
143 configured = true;
144 }
145
146
147
148
149
150
151 public void addBuilderConfig(final BuilderConfig config) {
152 if (configured) {
153 throw new IllegalStateException("Configuration is frozen");
154 }if(builderConfigs.containsKey(config.getId())){
155 return;
156 } else {
157 config.setRiaConfig(this);
158 builderConfigs.put(config.getId(), config);
159 return;
160 }
161 }
162
163
164
165
166
167 public void setConfigured(final boolean configured) {
168 this.configured = configured;
169 }
170
171
172
173
174
175
176
177 public BuilderConfig findBuilderConfig(final String id) {
178 return (BuilderConfig) builderConfigs.get(id);
179 }
180
181
182
183
184
185
186
187
188
189
190 public void addDrawerConfig(final DrawerConfig config) {
191 if (configured) {
192 throw new IllegalStateException("Configuration is frozen");
193 }if(drawerConfigs.containsKey(config.getId())){
194 return;
195 } else {
196 drawerConfigs.put(config.getId(), config);
197 return;
198 }
199 }
200
201
202
203
204
205
206
207 public DrawerConfig findDrawerConfig(final String drawerId) {
208 return (DrawerConfig) drawerConfigs.get(drawerId);
209 }
210
211
212
213
214
215 public DrawerConfig[] findDrawerConfigs() {
216 DrawerConfig results[] = new DrawerConfig[drawerConfigs.size()];
217 return (DrawerConfig[]) drawerConfigs.values().toArray(results);
218 }
219
220 public PlugInConfig[] findPlugInConfigs() {
221 PlugInConfig results[] = new PlugInConfig[plugIns.size()];
222 return (PlugInConfig[]) plugIns.toArray(results);
223 }
224
225 }