1
2
3
4
5 package com.hack23.cia.web.views.user;
6
7 import thinwire.ui.TabFolder;
8 import thinwire.ui.TabSheet;
9 import thinwire.ui.WebBrowser;
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.common.ParliamentChart;
15 import com.hack23.cia.model.sweden.impl.CommitteeReport;
16 import com.hack23.cia.web.common.ImageConstants;
17 import com.hack23.cia.web.views.components.panels.ImagePanel;
18
19 /***
20 * The Class CommitteeReportSummaryPanel.
21 */
22 public class CommitteeReportSummaryPanel extends AbstractParliamentOperationPanel {
23
24 /*** The user session dto. */
25 private final UserSessionDTO userSessionDTO;
26
27 /***
28 * Instantiates a new committee report summary panel.
29 *
30 * @param userSessionDTO the user session dto
31 * @param commiteeReport the commitee report
32 */
33 public CommitteeReportSummaryPanel(final UserSessionDTO userSessionDTO, final CommitteeReport commiteeReport) {
34 super(userSessionDTO);
35 this.userSessionDTO = userSessionDTO;
36 setLayout(new TableLayout(new double[][] { { 0 },
37 { 0 } },
38 1,
39 5));
40
41 final TabFolder tabFolder = createTabFolder(commiteeReport);
42
43 tabFolder.getChildren().add(
44 createTabFolderCharts(commiteeReport));
45 tabFolder.getChildren().add(
46 createTabFolderCitizenOperation());
47
48 tabFolder.setLimit("0,0,1,1");
49 getChildren().add(tabFolder);
50 }
51
52 /***
53 * Creates the tab folder.
54 *
55 * @param commiteeReport the commitee report
56 * @return the tab folder
57 */
58 private TabFolder createTabFolder(final CommitteeReport commiteeReport) {
59 final TabFolder tabFolder = new TabFolder();
60
61 if (commiteeReport.getHref() != null) {
62 final TabSheet homePageTab = createTabHomePage(commiteeReport);
63 tabFolder.getChildren().add(homePageTab);
64 }
65 return tabFolder;
66 }
67
68 /***
69 * Creates the tab folder chart outcome.
70 *
71 * @param commiteeReport the commitee report
72 * @return the tab sheet
73 */
74 private TabSheet createTabFolderChartOutcome(
75 final CommitteeReport commiteeReport) {
76 final TabSheet tabSheet = new TabSheet();
77
78 tabSheet.setText(userSessionDTO
79 .getLanguageResource(Agency.LanguageContentKey.OUTCOME));
80 tabSheet.setLayout(new TableLayout(new double[][] { { 0 },
81
82 { 0 } },
83 1,
84 5));
85 final ImagePanel imagePanel = new ImagePanel(ParliamentChart.getFileName(ParliamentChart.Outcome, commiteeReport, userSessionDTO.getUserSession().getLanguage()));
86 imagePanel.setLimit("0,0");
87 tabSheet.getChildren().add(imagePanel);
88
89 return tabSheet;
90 }
91
92 /***
93 * Creates the tab folder chart political party behavior.
94 *
95 * @param commiteeReport the commitee report
96 * @return the tab sheet
97 */
98 private TabSheet createTabFolderChartPoliticalPartyBehavior(
99 final CommitteeReport commiteeReport) {
100 final TabSheet tabSheet = new TabSheet();
101
102 tabSheet.setText(userSessionDTO
103 .getLanguageResource(Agency.LanguageContentKey.POLITICAL_PARTY_BEHAVIOR));
104 tabSheet.setLayout(new TableLayout(new double[][] { { 0 },
105
106 { 0 } },
107 1,
108 5));
109 final ImagePanel imagePanel = new ImagePanel(ParliamentChart.getFileName(ParliamentChart.PoliticalPartyBehavior, commiteeReport, userSessionDTO.getUserSession().getLanguage()));
110 imagePanel.setLimit("0,0");
111 tabSheet.getChildren().add(imagePanel);
112
113 return tabSheet;
114 }
115
116 /***
117 * Creates the tab folder chart proffessional behavior.
118 *
119 * @param commiteeReport the commitee report
120 * @return the tab sheet
121 */
122 private TabSheet createTabFolderChartProffessionalBehavior(final CommitteeReport commiteeReport) {
123 final TabSheet tabSheet = new TabSheet();
124
125 tabSheet.setText(userSessionDTO
126 .getLanguageResource(Agency.LanguageContentKey.PROFFESSIONAL_BEHAVIOR));
127 tabSheet.setLayout(new TableLayout(new double[][] { { 0 },
128
129 { 0 } },
130 1,
131 5));
132 final ImagePanel imagePanel = new ImagePanel(ParliamentChart.getFileName(ParliamentChart.ProffessionalBehavior, commiteeReport, userSessionDTO.getUserSession().getLanguage()));
133 imagePanel.setLimit("0,0");
134 tabSheet.getChildren().add(imagePanel);
135
136 return tabSheet;
137 }
138
139 /***
140 * Creates the tab folder charts.
141 *
142 * @param commiteeReport the commitee report
143 * @return the tab sheet
144 */
145 private TabSheet createTabFolderCharts(final CommitteeReport commiteeReport) {
146 final TabSheet tabSheet = new TabSheet();
147
148 tabSheet.setText(userSessionDTO
149 .getLanguageResource(Agency.LanguageContentKey.CHARTS));
150 tabSheet.setImage(ImageConstants.CHART_IMAGE_SMALL);
151 tabSheet.setLayout(new TableLayout(new double[][] { { 0 },
152
153 { 0 } },
154 1,
155 5));
156
157 final TabFolder tabFolder = new TabFolder();
158 tabFolder.setLimit("0,0");
159
160 tabFolder.getChildren().add(
161 createTabFolderChartSummary(commiteeReport));
162 tabFolder.getChildren().add(
163 createTabFolderChartOutcome(commiteeReport));
164 tabFolder.getChildren().add(
165 createTabFolderChartPoliticalPartyBehavior(commiteeReport));
166 tabFolder.getChildren().add(
167 createTabFolderChartProffessionalBehavior(commiteeReport));
168
169
170 tabFolder.setCurrentIndex(0);
171 tabSheet.getChildren().add(tabFolder);
172 return tabSheet;
173 }
174
175
176 /***
177 * Creates the tab folder chart summary.
178 *
179 * @param commiteeReport the commitee report
180 * @return the tab sheet
181 */
182 private TabSheet createTabFolderChartSummary(
183 final CommitteeReport commiteeReport) {
184 final TabSheet tabSheet = new TabSheet();
185
186 tabSheet.setText(userSessionDTO
187 .getLanguageResource(Agency.LanguageContentKey.SUMMARY));
188 tabSheet.setLayout(new TableLayout(new double[][] { { 0 },
189
190 { 0 } },
191 1,
192 5));
193 final ImagePanel imagePanel = new ImagePanel(ParliamentChart.getFileName(ParliamentChart.Summary, commiteeReport, userSessionDTO.getUserSession().getLanguage()));
194 imagePanel.setLimit("0,0");
195 tabSheet.getChildren().add(imagePanel);
196
197 return tabSheet;
198 }
199
200 /***
201 * Creates the tab home page.
202 *
203 * @param commiteeReport the commitee report
204 * @return the tab sheet
205 */
206 private TabSheet createTabHomePage(final CommitteeReport commiteeReport) {
207 final TabSheet homePage = new TabSheet();
208
209 homePage.setText(commiteeReport.getName());
210
211 homePage.setLayout(new TableLayout(new double[][] { { 0 },
212
213 { 0 } },
214 1,
215 5));
216
217 final WebBrowser comp = new WebBrowser();
218 comp.setLimit("0,0");
219 comp.setLocation(commiteeReport.getHref());
220 homePage.getChildren().add(comp);
221 return homePage;
222 }
223
224 }