diff flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 2:bc5d4d2297b9

Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar. flys-client/trunk@1309 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Feb 2011 08:57:34 +0000
parents 0e22a19852e7
children 89976499e013
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Wed Feb 09 09:59:27 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Thu Feb 10 08:57:34 2011 +0000
@@ -1,10 +1,16 @@
 package de.intevation.flys.client.client;
 
 import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.RootPanel;
 
 import com.smartgwt.client.widgets.layout.VLayout;
 
+import de.intevation.artifacts.common.model.User;
+
+import de.intevation.flys.client.client.services.UserService;
+import de.intevation.flys.client.client.services.UserServiceAsync;
 import de.intevation.flys.client.client.ui.FLYSView;
 import de.intevation.flys.client.client.ui.MainMenu;
 
@@ -16,24 +22,43 @@
  */
 public class FLYS implements EntryPoint {
 
+    /** The UserService used to retrieve information about the current user. */
+    protected UserServiceAsync userService = GWT.create(UserService.class);
+
+    protected MainMenu menu;
+    protected FLYSView view;
+
+
     /**
      * This is the entry point method.
      */
     public void onModuleLoad() {
 
         VLayout vertical = new VLayout();
-        vertical.setMembersMargin(5);
+        vertical.setMembersMargin(2);
         vertical.setLayoutMargin(1);
         vertical.setWidth100();
         vertical.setHeight100();
 
-        MainMenu menu = new MainMenu();
-        FLYSView view = new FLYSView();
+        menu = new MainMenu();
+        view = new FLYSView();
 
         vertical.addMember(menu);
         vertical.addMember(view);
 
         RootPanel.get("app").add(vertical);
+
+        userService.getCurrentUser(new AsyncCallback<User>() {
+            public void onFailure(Throwable caught) {
+                GWT.log("Could not find a logged in user.");
+                // TODO do something
+            }
+
+            public void onSuccess(User user) {
+                GWT.log("Found a user. Set '"+ user.getLastName()+"'");
+                menu.setCurrentUser(user);
+            }
+        });
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org