Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / UserDetailsPanel.java @ a60ea262

History | View | Annotate | Download (2.3 kB)

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