View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
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 }, // Column Widths
32                  { 0, 0, 0 } }, // Row Heights
33                  10, // Margin around edge of container
34                  5)); // Spacing between cells
35          // Image
36  
37          final Label labelSiteDescription = new Label();
38          labelSiteDescription.setLimit("0,0,3,1"); //$NON-NLS-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"); //$NON-NLS-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"); //$NON-NLS-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"); //$NON-NLS-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"); //$NON-NLS-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"); //$NON-NLS-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"); //$NON-NLS-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 }