Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/Config.java @ 238:234c78a91c15
Added new UI provider for single location selection.
flys-client/trunk@1806 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 03 May 2011 13:52:14 +0000 |
parents | 924da6695800 |
children | 385e9368ffcd |
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.core.client.GWT; |
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 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
|
5 |
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
|
6 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
|
7 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
|
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 /** |
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 * 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
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * |
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 * @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
|
17 */ |
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 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
|
19 |
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 /** 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
|
21 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
|
22 |
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 /** The xml document that contains the configuration options.*/ |
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 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
|
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 /** |
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 * 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
|
29 * 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
|
30 */ |
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 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
|
32 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
|
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 /** |
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 * 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
|
38 * 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
|
39 * |
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 * @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
|
41 * |
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 * @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
|
43 */ |
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 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
|
45 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
|
46 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
|
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 |
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 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
|
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 /** |
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 * 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
|
55 * 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
|
56 * |
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 * @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
|
58 * 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
|
59 */ |
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 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
|
61 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
|
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 /** |
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 * 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
|
67 * |
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 * @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
|
69 */ |
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 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
|
71 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
|
72 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
|
73 } |
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
|
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 /** |
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 * 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
|
78 * |
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 * @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
|
80 */ |
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 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
|
82 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
|
83 } |
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
|
84 } |
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
|
85 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |