Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CoreConfiguration |
|
| 1.0434782608695652;1.043 |
1 | package org.jtheque.core.managers.core; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import org.jtheque.core.managers.state.AbstractState; | |
20 | import org.jtheque.utils.bean.IntDate; | |
21 | ||
22 | /** | |
23 | * The configuration of the core. | |
24 | * | |
25 | * @author Baptiste Wicht | |
26 | */ | |
27 | 0 | public final class CoreConfiguration extends AbstractState { |
28 | private static final String TRUE = "true"; | |
29 | private static final String FALSE = "false"; | |
30 | ||
31 | /** | |
32 | * The preferred look and feel of the user. | |
33 | * | |
34 | * @return The preferred look and feel. | |
35 | */ | |
36 | public String getPreferredLookAndFeel() { | |
37 | 0 | return getProperty("lookAndFeel"); |
38 | } | |
39 | ||
40 | /** | |
41 | * Set the preferred look and feel. | |
42 | * | |
43 | * @param lookAndFeel The preferred look and feel. | |
44 | */ | |
45 | public void setPreferredLookAndFeel(String lookAndFeel) { | |
46 | 0 | setProperty("lookAndFeel", lookAndFeel); |
47 | 0 | } |
48 | ||
49 | /** | |
50 | * Indicate if we verify the updates at the application startup. | |
51 | * | |
52 | * @return <code>true</code> if verify updates on startup else <code>false</code> | |
53 | */ | |
54 | public boolean verifyUpdateOnStartup() { | |
55 | 0 | return Boolean.parseBoolean(getProperty("verifyOnStartup", FALSE)); |
56 | } | |
57 | ||
58 | /** | |
59 | * Set if we must verify the updates on startup. | |
60 | * | |
61 | * @param value A boolean tag indicating if we must verify updates on startup. | |
62 | */ | |
63 | public void setVerifyUpdateOnStartup(boolean value) { | |
64 | 0 | setProperty("verifyOnStartup", String.valueOf(value)); |
65 | 0 | } |
66 | ||
67 | /** | |
68 | * Indicate if we must retain the size of the windows. | |
69 | * | |
70 | * @return <code>true</code> if we must retain the size of the windows else <code>false</code> | |
71 | */ | |
72 | public boolean retainSizeAndPositionOfWindow() { | |
73 | 0 | return Boolean.parseBoolean(getProperty("retainSizeAndPositionOfWindow", FALSE)); |
74 | } | |
75 | ||
76 | /** | |
77 | * Set if we must retain the size of the window. | |
78 | * | |
79 | * @param value A boolean tag indicating if we must retain the size of the window. | |
80 | */ | |
81 | public void setRetainSizeAndPositionOfWindow(boolean value) { | |
82 | 0 | setProperty("retainSizeAndPositionOfWindow", Boolean.toString(value)); |
83 | 0 | } |
84 | ||
85 | /** | |
86 | * Indicate if we must use always use the same look and feel. | |
87 | * | |
88 | * @return <code>true</code> if we use always the same look and feel else <code>false</code> | |
89 | */ | |
90 | public boolean alwaysLookAndFeel() { | |
91 | 0 | return Boolean.parseBoolean(getProperty("alwaysLookAndFeel", TRUE)); |
92 | } | |
93 | ||
94 | /** | |
95 | * Set if we must always use the same look and feel or not. | |
96 | * | |
97 | * @param value A boolean tag indicating if we must always use the same look and feel. | |
98 | */ | |
99 | public void setAlwaysLookAndFeel(boolean value) { | |
100 | 0 | setProperty("alwaysLookAndFeel", Boolean.toString(value)); |
101 | 0 | } |
102 | ||
103 | /** | |
104 | * Indicate if there is a proxy or not. | |
105 | * | |
106 | * @return <code>true</code> if there is a proxy else <code>false</code> | |
107 | */ | |
108 | public boolean hasAProxy() { | |
109 | 0 | return Boolean.parseBoolean(getProperty("proxy", FALSE)); |
110 | } | |
111 | ||
112 | /** | |
113 | * Set if there is a proxy or not. | |
114 | * | |
115 | * @param value A boolean tag indicating if there is a proxy or not. | |
116 | */ | |
117 | public void setHasAProxy(boolean value) { | |
118 | 0 | setProperty("proxy", Boolean.toString(value)); |
119 | 0 | } |
120 | ||
121 | /** | |
122 | * Return the port number of the proxy. | |
123 | * | |
124 | * @param value The port number of the proxy. | |
125 | */ | |
126 | public void setProxyPort(String value) { | |
127 | 0 | setProperty("proxyPort", value); |
128 | 0 | } |
129 | ||
130 | /** | |
131 | * Return the port number of the proxy. | |
132 | * | |
133 | * @return The port number of the proxy. | |
134 | */ | |
135 | public String getProxyPort() { | |
136 | 0 | return getProperty("proxyPort"); |
137 | } | |
138 | ||
139 | /** | |
140 | * Set the address of the proxy. | |
141 | * | |
142 | * @param value The address of the proxy. | |
143 | */ | |
144 | public void setProxyAddress(String value) { | |
145 | 0 | setProperty("proxyAddress", value); |
146 | 0 | } |
147 | ||
148 | /** | |
149 | * Return the address of the proxy. | |
150 | * | |
151 | * @return The address of the proxy. | |
152 | */ | |
153 | public String getProxyAddress() { | |
154 | 0 | return getProperty("proxyAddress"); |
155 | } | |
156 | ||
157 | /** | |
158 | * Set if we must delete the logs or not. | |
159 | * | |
160 | * @param value A boolean tag indicating if we must delete the logs or not. | |
161 | */ | |
162 | public void setMustDeleteLogs(boolean value) { | |
163 | 0 | setProperty("deleteLog", Boolean.toString(value)); |
164 | 0 | } |
165 | ||
166 | /** | |
167 | * Indicate if we must delete the logs or not. | |
168 | * | |
169 | * @return <code>true</code> if we must delete the logs else <code>false</code> | |
170 | */ | |
171 | public boolean mustDeleteLogs() { | |
172 | 0 | return Boolean.valueOf(getProperty("deleteLog", FALSE)); |
173 | } | |
174 | ||
175 | /** | |
176 | * Set the email of the user. | |
177 | * | |
178 | * @param value The new email to set | |
179 | */ | |
180 | public void setUserEmail(String value) { | |
181 | 0 | setProperty("userEmail", value); |
182 | 0 | } |
183 | ||
184 | /** | |
185 | * Return the email of the user. | |
186 | * | |
187 | * @return The email | |
188 | */ | |
189 | public String getUserEmail() { | |
190 | 0 | return getProperty("userEmail"); |
191 | } | |
192 | ||
193 | /** | |
194 | * Set the SMTP host. | |
195 | * | |
196 | * @param value The new SMTP host. | |
197 | */ | |
198 | public void setSmtpHost(String value) { | |
199 | 0 | setProperty("smtpHost", value); |
200 | 0 | } |
201 | ||
202 | /** | |
203 | * Return the SMTP host. | |
204 | * | |
205 | * @return The SMTP host. | |
206 | */ | |
207 | public String getSmtpHost() { | |
208 | 0 | return getProperty("smtpHost"); |
209 | } | |
210 | ||
211 | /** | |
212 | * Set the date of the last reading of the messages. | |
213 | * | |
214 | * @param value The date of the last reading of the messages. | |
215 | */ | |
216 | void setMessagesLastRead(String value) { | |
217 | 0 | setProperty("messagesLastRead", value); |
218 | 0 | } |
219 | ||
220 | /** | |
221 | * Return the date of the last reading of the messages. | |
222 | * | |
223 | * @return The date of the last reading of the messages. | |
224 | */ | |
225 | public IntDate getMessagesLastRead() { | |
226 | 0 | if (getProperty("messagesLastRead") == null) { |
227 | 0 | setMessagesLastRead("20000101"); |
228 | } | |
229 | ||
230 | 0 | return new IntDate(Integer.parseInt(getProperty("messagesLastRead"))); |
231 | } | |
232 | ||
233 | /** | |
234 | * Set the configuration to the default values. | |
235 | */ | |
236 | public void setDefaults() { | |
237 | 0 | setAlwaysLookAndFeel(true); |
238 | 0 | setHasAProxy(false); |
239 | 0 | setMustDeleteLogs(false); |
240 | 0 | setPreferredLookAndFeel("Metal"); |
241 | 0 | setProxyAddress(""); |
242 | 0 | setProxyPort(""); |
243 | 0 | setRetainSizeAndPositionOfWindow(true); |
244 | 0 | setSmtpHost(""); |
245 | 0 | setUserEmail(""); |
246 | 0 | setMessagesLastRead("20000101"); |
247 | 0 | setVerifyUpdateOnStartup(false); |
248 | 0 | } |
249 | } |