Put the user's full name from the User object to the hashmap that keeps the correlati...
[pithos] / src / gr / ebs / gss / client / UserDetailsPanel.java
1 /*
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
3  *
4  * This file is part of GSS.
5  *
6  * GSS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 package gr.ebs.gss.client;
20
21 import gr.ebs.gss.client.rest.resource.UserResource;
22
23 import com.google.gwt.user.client.DeferredCommand;
24 import com.google.gwt.user.client.IncrementalCommand;
25 import com.google.gwt.user.client.ui.Composite;
26 import com.google.gwt.user.client.ui.HTML;
27 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
28 import com.google.gwt.user.client.ui.HorizontalPanel;
29
30 /**
31  * The panel that displays a status bar with quota information.
32  */
33 public class UserDetailsPanel extends Composite {
34         public static final boolean DONE = false;
35
36         /**
37          * The label that displays user information.
38          */
39         private HTML userInfoLabel;
40
41         /**
42          * The constructor of the user details panel.
43          */
44         public UserDetailsPanel() {
45                 final HorizontalPanel outer = new HorizontalPanel();
46                 outer.setSpacing(8);
47                 userInfoLabel = new HTML("&nbsp;");
48                 outer.add(userInfoLabel);
49                 outer.setCellHorizontalAlignment(userInfoLabel, HasHorizontalAlignment.ALIGN_RIGHT);
50                 outer.setStyleName("statusbar-inner");
51
52                 initWidget(outer);
53
54                 DeferredCommand.addCommand(new IncrementalCommand() {
55
56                         @Override
57                         public boolean execute() {
58                                 return displayUserInfo();
59                         }
60                 });
61         }
62
63         /**
64          * Display the user information on the panel.
65          *
66          * @return true if the work has been carried out successfully
67          */
68         protected boolean displayUserInfo() {
69                 UserResource user = GSS.get().getCurrentUserResource();
70                 if (user == null)
71                         return !DONE;
72                 userInfoLabel.setHTML("<b>" + user.getName() + " \u0387 " + user.getUsername() + "</b>");
73                 GSS.get().putUserToMap(user.getUsername(), user.getName());
74                 return DONE;
75         }
76
77 }