Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/Config.java @ 2896:d01517ecaf89
Removed duplicated i18n methods.
flys-client/trunk@4619 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 07 Jun 2012 08:29:40 +0000 |
parents | d81533df4138 |
children |
rev | line source |
---|---|
9
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
3 import com.google.gwt.i18n.client.LocaleInfo; |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
4 |
9
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.google.gwt.xml.client.Document; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.xml.client.Node; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 /** |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 * A class that is used to handle the global configuration of this client. You |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 * can retrieve an instance of this class using the <code>getInstance</code> |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 * methods. <b>NOTE:</b> the configuration is initialized using {@link |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 * getInstance(Document)} the first time. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 * |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 */ |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 public class Config { |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 /** The instance of the configuration. */ |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 protected static Config INSTANCE; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
1347
d81533df4138
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
585
diff
changeset
|
22 /** The xml document that contains the configuration options. */ |
9
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 protected Document config; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 /** |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * Get an instance by using {@link getInstance(Document)} or {@link |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 * getInstance()}. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 */ |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 private Config(Document config) { |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 this.config = config; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 } |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 /** |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 * Returns an instance of this class and initializes the configuration of |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 * this has not been done so far. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 * |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 * @param config The client configuration. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 * |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 * @return an instance of this Config class. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 */ |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public static Config getInstance(Document config) { |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 if (INSTANCE == null) { |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 INSTANCE = new Config(config); |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 return INSTANCE; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 /** |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 * Returns an instance of this class. If it has not been initialized with a |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 * valid configuration, null is returned. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 * |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 * @return an instance of this class or null, if the Config has not been |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 * initialized using {@link getInstance(Document)} so far. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 */ |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 public static Config getInstance() { |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 return INSTANCE; |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 /** |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 * Returns the URL of the artifact server. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 * |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * @return the artifact server url. |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 */ |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 public String getServerUrl() { |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 Node server = config.getElementsByTagName("server").item(0); |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 return server.getFirstChild().getNodeValue(); |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 } |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
73 |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
74 |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
75 /** |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
76 * Returns the name of the current locale. |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
77 * |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
78 * @return the name of the current locale. |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
79 */ |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
80 public String getLocale() { |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
81 return LocaleInfo.getCurrentLocale().getLocaleName(); |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
9
diff
changeset
|
82 } |
585
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
83 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
84 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
85 /** |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
86 * Returns the integer configured at |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
87 * <i>/config/projectlist/update-interval/text()</i> or -1 if an error |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
88 * occured or no such option is defined. |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
89 * |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
90 * @return the update interval of the project list. |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
91 */ |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
92 public int getProjectListUpdateInterval() { |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
93 Node projectlist = config.getElementsByTagName("projectlist").item(0); |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
94 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
95 if (projectlist == null) { |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
96 return -1; |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
97 } |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
98 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
99 Node interval = config.getElementsByTagName("update-interval").item(0); |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
100 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
101 if (interval == null) { |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
102 return -1; |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
103 } |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
104 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
105 String value = interval.getFirstChild().getNodeValue(); |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
106 |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
107 return value != null ? Integer.valueOf(value) : -1; |
ab7ec931bae2
#22 Introduced a polling mechanism to refresh the projects of a user in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
252
diff
changeset
|
108 } |
9
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
8facd8545a12
Added a global configuration for the client and classes providing methods to retrieve these information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |