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