Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 25:2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
flys-client/trunk@1411 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 07 Mar 2011 13:40:37 +0000 |
parents | fe2f4d1dd784 |
children | e4155a6833a9 |
comparison
equal
deleted
inserted
replaced
24:8825ce0a537e | 25:2da6be38d8b6 |
---|---|
6 import com.google.gwt.user.client.ui.RootPanel; | 6 import com.google.gwt.user.client.ui.RootPanel; |
7 import com.google.gwt.xml.client.XMLParser; | 7 import com.google.gwt.xml.client.XMLParser; |
8 | 8 |
9 import com.smartgwt.client.widgets.layout.VLayout; | 9 import com.smartgwt.client.widgets.layout.VLayout; |
10 | 10 |
11 import de.intevation.artifacts.common.model.User; | |
12 | |
13 import de.intevation.flys.client.shared.model.Artifact; | 11 import de.intevation.flys.client.shared.model.Artifact; |
14 import de.intevation.flys.client.shared.model.Collection; | 12 import de.intevation.flys.client.shared.model.Collection; |
15 import de.intevation.flys.client.shared.model.DefaultCollection; | 13 import de.intevation.flys.client.shared.model.DefaultCollection; |
14 import de.intevation.flys.client.shared.model.User; | |
16 | 15 |
17 import de.intevation.flys.client.client.services.ArtifactService; | 16 import de.intevation.flys.client.client.services.ArtifactService; |
18 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 17 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
19 import de.intevation.flys.client.client.services.UserService; | 18 import de.intevation.flys.client.client.services.UserService; |
20 import de.intevation.flys.client.client.services.UserServiceAsync; | 19 import de.intevation.flys.client.client.services.UserServiceAsync; |
49 protected ProjectList projectList; | 48 protected ProjectList projectList; |
50 | 49 |
51 /** The FLYSWorkspace.*/ | 50 /** The FLYSWorkspace.*/ |
52 protected FLYSWorkspace workspace; | 51 protected FLYSWorkspace workspace; |
53 | 52 |
53 /** The user who is currently logged in.*/ | |
54 protected User currentUser; | |
55 | |
54 | 56 |
55 /** | 57 /** |
56 * This is the entry point method. | 58 * This is the entry point method. |
57 */ | 59 */ |
58 public void onModuleLoad() { | 60 public void onModuleLoad() { |
70 vertical.addMember(view); | 72 vertical.addMember(view); |
71 | 73 |
72 RootPanel.get("app").add(vertical); | 74 RootPanel.get("app").add(vertical); |
73 | 75 |
74 initConfiguration(); | 76 initConfiguration(); |
77 String serverUrl = Config.getInstance().getServerUrl(); | |
75 | 78 |
76 userService.getCurrentUser(new AsyncCallback<User>() { | 79 userService.getCurrentUser(serverUrl, new AsyncCallback<User>() { |
77 public void onFailure(Throwable caught) { | 80 public void onFailure(Throwable caught) { |
78 GWT.log("Could not find a logged in user."); | 81 GWT.log("Could not find a logged in user."); |
79 // TODO do something | 82 // TODO do something |
80 } | 83 } |
81 | 84 |
82 public void onSuccess(User user) { | 85 public void onSuccess(User user) { |
83 GWT.log("Found a user. Set '"+ user.getLastName()+"'"); | 86 GWT.log("Found a user. Set '"+ user.getName() + "'"); |
87 setCurrentUser(user); | |
88 | |
84 menu.setCurrentUser(user); | 89 menu.setCurrentUser(user); |
85 | 90 |
86 projectList = new ProjectList(user); | 91 projectList = new ProjectList(user); |
87 workspace = new FLYSWorkspace(); | 92 workspace = new FLYSWorkspace(); |
88 view.setProjectList(projectList); | 93 view.setProjectList(projectList); |
97 * configuration. | 102 * configuration. |
98 */ | 103 */ |
99 protected void initConfiguration() { | 104 protected void initConfiguration() { |
100 String xml = FLYSResources.INSTANCE.initialConfiguration().getText(); | 105 String xml = FLYSResources.INSTANCE.initialConfiguration().getText(); |
101 Config.getInstance(XMLParser.parse(xml)); | 106 Config.getInstance(XMLParser.parse(xml)); |
107 } | |
108 | |
109 | |
110 /** | |
111 * Returns the user that is currently logged in. | |
112 * | |
113 * @return the current user. | |
114 */ | |
115 public User getCurrentUser() { | |
116 return currentUser; | |
117 } | |
118 | |
119 | |
120 /** | |
121 * Sets the current user. | |
122 */ | |
123 public void setCurrentUser(User user) { | |
124 currentUser = user; | |
102 } | 125 } |
103 | 126 |
104 | 127 |
105 /** | 128 /** |
106 * This method creates a new CollectionView and adds it to the workspace. | 129 * This method creates a new CollectionView and adds it to the workspace. |