1
2
3
4
5 package org.directdemocracyportal.democracy.web.views.header;
6
7 import org.directdemocracyportal.democracy.model.application.User;
8 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
9 import org.directdemocracyportal.democracy.web.BeanLocator;
10 import org.directdemocracyportal.democracy.web.ImageConstants;
11 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
12 import org.directdemocracyportal.democracy.web.action.LogoutAction;
13 import org.directdemocracyportal.democracy.web.action.ShowMyProfileAction;
14
15 import thinwire.ui.Button;
16 import thinwire.ui.Label;
17 import thinwire.ui.Panel;
18 import thinwire.ui.layout.TableLayout;
19 import thinwire.ui.style.Color;
20
21 /***
22 * The Class UserPanel.
23 */
24 public class UserPanel extends Panel
25 {
26
27 /***
28 * Instantiates a new user panel.
29 *
30 * @param user the user
31 */
32 public UserPanel(User user) {
33 super();
34 getStyle().getBackground().setColor(Color.valueOf("rgb(0,51,153)"));
35 setLayout(new TableLayout(new double[][] { { 0, 0, 0 },
36 { 0 } },
37 1,
38 5));
39
40 Label label = new Label(ApplicationMessageHolder
41 .getMessage(MessageConstans.WELCOME) + user.getUsername());
42 label.setLimit("0,0");
43 getChildren().add(label);
44
45 Button profileButton = new Button();
46 profileButton.setImage(ImageConstants.USER_HOME_ICON);
47 profileButton.setText(ApplicationMessageHolder
48 .getMessage(MessageConstans.BUTTON_MY_PROFILE));
49 profileButton.setSize(90, 30);
50 profileButton.setLimit("1,0,c,c");
51 profileButton.setUserObject(new ShowMyProfileAction());
52 profileButton.addActionListener(ACTION_CLICK, BeanLocator
53 .getApplicationActionListener());
54 getChildren().add(profileButton);
55
56 Button logoutButton = new Button();
57 logoutButton.setText(ApplicationMessageHolder
58 .getMessage(MessageConstans.BUTTON_LOGOUT));
59 logoutButton.setUserObject(new LogoutAction());
60 logoutButton.addActionListener(ACTION_CLICK, BeanLocator
61 .getApplicationActionListener());
62 logoutButton.setSize(90, 30);
63 logoutButton.setLimit("2,0,c,c");
64 getChildren().add(logoutButton);
65 }
66 }