1
2
3
4
5
6 package com.hack23.cia.web.views.user;
7
8 import thinwire.ui.Label;
9 import thinwire.ui.Panel;
10 import thinwire.ui.layout.TableLayout;
11
12 import com.hack23.cia.model.application.dto.common.UserSessionDTO;
13 import com.hack23.cia.model.application.impl.common.Agency;
14 import com.hack23.cia.model.application.impl.user.AbstractTopListActionEvent;
15 import com.hack23.cia.web.action.user.TopListAction;
16 import com.hack23.cia.web.common.ImageConstants;
17 import com.hack23.cia.web.views.components.panels.CategoryDescriptionPanel;
18
19 /***
20 * The Class WelcomePanel.
21 */
22 public class WelcomePanel extends Panel {
23
24 /***
25 * Instantiates a new welcome panel.
26 *
27 * @param userSessionDTO the user session dto
28 */
29 public WelcomePanel(final UserSessionDTO userSessionDTO) {
30 super();
31 setLayout(new TableLayout(new double[][] { { 0, 0, 0 },
32 { 0, 0, 0 } },
33 10,
34 5));
35
36
37 final Label labelSiteDescription = new Label();
38 labelSiteDescription.setLimit("0,0,3,1");
39 labelSiteDescription.setWrapText(true);
40 labelSiteDescription.setText(userSessionDTO
41 .getLanguageResource(Agency.LanguageContentKey.SITE_DESCRIPTION));
42
43 final CategoryDescriptionPanel winnerPanel = new CategoryDescriptionPanel(
44 ImageConstants.WINNER_ICON,
45 userSessionDTO
46 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_WINNERS),
47 new TopListAction(
48 AbstractTopListActionEvent.Operation.TopWinners),
49 userSessionDTO
50 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_WINNERS_DESCRIPTION));
51 winnerPanel.setLimit("0, 1, 1, 1");
52
53 final CategoryDescriptionPanel loserPanel = new CategoryDescriptionPanel(
54 ImageConstants.LOSER_ICON,
55 userSessionDTO
56 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_LOSERS),
57 new TopListAction(
58 AbstractTopListActionEvent.Operation.TopLosers),
59 userSessionDTO
60 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_LOSERS_DESCRIPTION));
61 loserPanel.setLimit("0, 2, 1, 1");
62
63 final CategoryDescriptionPanel loyalPanel = new CategoryDescriptionPanel(
64 ImageConstants.LOYAL_ICON,
65 userSessionDTO
66 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_LOYAL),
67 new TopListAction(
68 AbstractTopListActionEvent.Operation.TopLoyals),
69 userSessionDTO
70 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_LOYAL_DESCRIPTION));
71 loyalPanel.setLimit("1, 1, 1, 1");
72
73 final CategoryDescriptionPanel rebelPanel = new CategoryDescriptionPanel(
74 ImageConstants.REBEL_ICON,
75 userSessionDTO
76 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_REBELS),
77 new TopListAction(
78 AbstractTopListActionEvent.Operation.TopRebels),
79 userSessionDTO
80 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_REBELS_DESCRIPTION));
81 rebelPanel.setLimit("1, 2, 1, 1");
82
83 final CategoryDescriptionPanel presencePanel = new CategoryDescriptionPanel(
84 ImageConstants.PRESENCE_ICON,
85 userSessionDTO
86 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_PRESENCE),
87 new TopListAction(
88 AbstractTopListActionEvent.Operation.TopPresent),
89 userSessionDTO
90 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_PRESENCE_DESCRIPTION));
91 presencePanel.setLimit("2, 1, 1, 1");
92
93 final CategoryDescriptionPanel absencePanel = new CategoryDescriptionPanel(
94 ImageConstants.ABSENCE_ICON,
95 userSessionDTO
96 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_ABSENCE),
97 new TopListAction(
98 AbstractTopListActionEvent.Operation.TopAbsent),
99 userSessionDTO
100 .getLanguageResource(Agency.LanguageContentKey.PARLIAMENT_MEMBERS_ABSENCE_DESCRIPTION));
101 absencePanel.setLimit("2, 2, 1, 1");
102
103 getChildren().add(labelSiteDescription);
104 getChildren().add(winnerPanel);
105 getChildren().add(loserPanel);
106 getChildren().add(loyalPanel);
107 getChildren().add(rebelPanel);
108 getChildren().add(presencePanel);
109 getChildren().add(absencePanel);
110 }
111 }