changeset 6479:ac6c41fcae55

Use help-url provided by ServerInfoService (fix for #1197). Required some changes in FLYS.onModuleLoad(), should be reviewed by someone.
author Christian Lins <christian.lins@intevation.de>
date Thu, 27 Jun 2013 17:36:51 +0200
parents 6e54f72b4caf
children d19a0ffb9ccf
files gwt-client/src/main/java/org/dive4elements/river/client/client/Config.java gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java
diffstat 2 files changed, 36 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/Config.java	Thu Jun 27 17:25:12 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/Config.java	Thu Jun 27 17:36:51 2013 +0200
@@ -29,6 +29,7 @@
     /** The xml document that contains the configuration options. */
     protected Document config;
 
+    protected String helpUrl;
 
     /**
      * Get an instance by using {@link getInstance(Document)} or {@link
@@ -85,8 +86,11 @@
      * @return wiki base URL
      */
     public String getWikiUrl() {
-        Node server = config.getElementsByTagName("wiki").item(0);
-        return server.getFirstChild().getNodeValue();
+        return this.helpUrl;
+    }
+
+    public void setWikiUrl(String url) {
+        this.helpUrl = url;
     }
 
 
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java	Thu Jun 27 17:25:12 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java	Thu Jun 27 17:36:51 2013 +0200
@@ -154,7 +154,7 @@
         vertical.draw();
 
         Config config = Config.getInstance();
-        String locale = config.getLocale();
+        final String locale = config.getLocale();
 
         serverInfoService.getConfig(locale, new AsyncCallback<Map<String,String>>() {
 
@@ -162,36 +162,39 @@
             public void onSuccess(Map<String, String> result) {
                 GWT.log("serverInfoService.callBack.onSuccess");
                 GWT.log("help-url=" + result.get("help-url"));
+                Config.getInstance().setWikiUrl(result.get("help-url"));
+
+                // Start user service; somewhat nested here...
+                userService.getCurrentUser(locale, new AsyncCallback<User>() {
+                    @Override
+                    public void onFailure(Throwable caught) {
+                        GWT.log("Could not find a logged in user.");
+                        String msg = getExceptionString(MSG, caught);
+                        SC.warn(msg);
+                    }
+
+                    @Override
+                    public void onSuccess(User user) {
+                        GWT.log("Found a user. Set '"+ user.getName() + "'");
+                        setCurrentUser(user);
+
+                        header.setCurrentUser(user);
+
+                        projectList = new ProjectList(FLYS.this, user);
+                        workspace   = new FLYSWorkspace(FLYS.this);
+                        view.setProjectList(projectList);
+                        view.setFLYSWorkspace(workspace);
+
+                        readRivers();
+                    }
+                });
             }
 
             @Override
             public void onFailure(Throwable caught) {
-               GWT.log("serverInfoService.callBack.onFailure");
-
-            }
-        });
-
-        userService.getCurrentUser(locale, new AsyncCallback<User>() {
-            @Override
-            public void onFailure(Throwable caught) {
-                GWT.log("Could not find a logged in user.");
-                String msg = getExceptionString(MSG, caught);
-                SC.warn(msg);
-            }
-
-            @Override
-            public void onSuccess(User user) {
-                GWT.log("Found a user. Set '"+ user.getName() + "'");
-                setCurrentUser(user);
-
-                header.setCurrentUser(user);
-
-                projectList = new ProjectList(FLYS.this, user);
-                workspace   = new FLYSWorkspace(FLYS.this);
-                view.setProjectList(projectList);
-                view.setFLYSWorkspace(workspace);
-
-                readRivers();
+               GWT.log("Could not read server information.");
+               String msg = getExceptionString(MSG, caught);
+               SC.warn(msg);
             }
         });
     }

http://dive4elements.wald.intevation.org