annotate gwt-client/src/main/java/org/dive4elements/river/client/client/Config.java @ 5861:172338b1407f

GWT client: Added copyright header.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:30:15 +0200
parents 5aa05a7a34b7
children ea9eef426962
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client;
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
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
11 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
12
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
13 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
14 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
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
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 * 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
19 * 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
20 * 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
21 * 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
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 * @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
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 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
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 /** 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
28 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
29
1347
d81533df4138 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 585
diff changeset
30 /** 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
31 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
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 * 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
36 * 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
37 */
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 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
39 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
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
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 /**
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 * 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
45 * 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
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 * @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
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 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
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 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
52 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
53 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
54 }
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 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
57 }
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
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 /**
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 * 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
62 * 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
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 * @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
65 * 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
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 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
68 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
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
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
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 /**
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 * 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
74 *
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
75 * @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
76 */
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
77 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
78 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
79 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
80 }
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
81
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
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 /**
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
84 * 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
85 *
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
86 * @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
87 */
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
88 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
89 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
90 }
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
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
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 /**
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 * 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
95 * <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
96 * 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
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 * @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
99 */
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 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
101 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
102
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 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
104 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
105 }
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 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
108
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
109 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
110 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
111 }
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
112
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
113 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
114
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
115 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
116 }
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
117 }
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
118 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org