Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:0e22a19852e7 | 2:bc5d4d2297b9 |
---|---|
1 package de.intevation.flys.client.client; | 1 package de.intevation.flys.client.client; |
2 | 2 |
3 import com.google.gwt.core.client.EntryPoint; | 3 import com.google.gwt.core.client.EntryPoint; |
4 import com.google.gwt.core.client.GWT; | |
5 import com.google.gwt.user.client.rpc.AsyncCallback; | |
4 import com.google.gwt.user.client.ui.RootPanel; | 6 import com.google.gwt.user.client.ui.RootPanel; |
5 | 7 |
6 import com.smartgwt.client.widgets.layout.VLayout; | 8 import com.smartgwt.client.widgets.layout.VLayout; |
7 | 9 |
10 import de.intevation.artifacts.common.model.User; | |
11 | |
12 import de.intevation.flys.client.client.services.UserService; | |
13 import de.intevation.flys.client.client.services.UserServiceAsync; | |
8 import de.intevation.flys.client.client.ui.FLYSView; | 14 import de.intevation.flys.client.client.ui.FLYSView; |
9 import de.intevation.flys.client.client.ui.MainMenu; | 15 import de.intevation.flys.client.client.ui.MainMenu; |
10 | 16 |
11 | 17 |
12 /** | 18 /** |
14 * | 20 * |
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
16 */ | 22 */ |
17 public class FLYS implements EntryPoint { | 23 public class FLYS implements EntryPoint { |
18 | 24 |
25 /** The UserService used to retrieve information about the current user. */ | |
26 protected UserServiceAsync userService = GWT.create(UserService.class); | |
27 | |
28 protected MainMenu menu; | |
29 protected FLYSView view; | |
30 | |
31 | |
19 /** | 32 /** |
20 * This is the entry point method. | 33 * This is the entry point method. |
21 */ | 34 */ |
22 public void onModuleLoad() { | 35 public void onModuleLoad() { |
23 | 36 |
24 VLayout vertical = new VLayout(); | 37 VLayout vertical = new VLayout(); |
25 vertical.setMembersMargin(5); | 38 vertical.setMembersMargin(2); |
26 vertical.setLayoutMargin(1); | 39 vertical.setLayoutMargin(1); |
27 vertical.setWidth100(); | 40 vertical.setWidth100(); |
28 vertical.setHeight100(); | 41 vertical.setHeight100(); |
29 | 42 |
30 MainMenu menu = new MainMenu(); | 43 menu = new MainMenu(); |
31 FLYSView view = new FLYSView(); | 44 view = new FLYSView(); |
32 | 45 |
33 vertical.addMember(menu); | 46 vertical.addMember(menu); |
34 vertical.addMember(view); | 47 vertical.addMember(view); |
35 | 48 |
36 RootPanel.get("app").add(vertical); | 49 RootPanel.get("app").add(vertical); |
50 | |
51 userService.getCurrentUser(new AsyncCallback<User>() { | |
52 public void onFailure(Throwable caught) { | |
53 GWT.log("Could not find a logged in user."); | |
54 // TODO do something | |
55 } | |
56 | |
57 public void onSuccess(User user) { | |
58 GWT.log("Found a user. Set '"+ user.getLastName()+"'"); | |
59 menu.setCurrentUser(user); | |
60 } | |
61 }); | |
37 } | 62 } |
38 } | 63 } |
39 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |