1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.page.user;
20
21 import org.vaadin.navigator7.Navigator.NavigationEvent;
22 import org.vaadin.navigator7.Page;
23 import org.vaadin.navigator7.ParamChangeListener;
24 import org.vaadin.navigator7.uri.Param;
25
26 import com.hack23.cia.model.internal.application.data.impl.AggregatedCountryData;
27 import com.hack23.cia.model.internal.application.data.impl.CountryMetaDataType;
28 import com.hack23.cia.service.api.DataContainer;
29 import com.vaadin.ui.Alignment;
30 import com.vaadin.ui.GridLayout;
31
32
33
34
35 @Page(uriName = "country", crawlable = true)
36 @SuppressWarnings("serial")
37 public final class CountryPage extends AbstractUserPage implements ParamChangeListener {
38
39
40 @Param(pos = 0, required = true)
41 String countryName;
42
43
44 @Param(pos = 1, required = true)
45 String countryIso;
46
47
48 private AggregatedCountryDataPanel targetSelectPanel = null;
49
50
51 private WorldBankIndicatorCountryPanel worldBankDataPanel=null;
52
53
54 private AggregatedBugsDataPanel targetPoliticiansPanel=null;
55
56
57
58
59 public CountryPage() {
60 super();
61 }
62
63
64
65
66 @Override
67 public String getPageTitle() {
68 return getUserState().translateFromEnglish("Country overview " + countryName);
69 }
70
71
72
73
74 @Override
75 public void paramChanged(final NavigationEvent navigationEvent) {
76 final DataContainer<AggregatedCountryData, String> dataContainer = getApplicationManager()
77 .getDataContainer(AggregatedCountryData.class);
78 final AggregatedCountryData country = dataContainer.load(countryName);
79 final GridLayout grid = new GridLayout(10, 8);
80
81 targetSelectPanel = new AggregatedCountryDataPanel();
82 grid.addComponent(targetSelectPanel, 0, 0, 1, 7);
83 grid.setComponentAlignment(targetSelectPanel, Alignment.MIDDLE_CENTER);
84 targetSelectPanel.update(country);
85 targetSelectPanel.setSizeFull();
86
87 if (country.getType().equals(CountryMetaDataType.ITSYOUR_PARLIAMENT)) {
88 worldBankDataPanel = new WorldBankIndicatorCountryPanel();
89 grid.addComponent(worldBankDataPanel, 2, 0, 7, 7);
90 grid.setComponentAlignment(worldBankDataPanel,
91 Alignment.MIDDLE_CENTER);
92 worldBankDataPanel.update(country);
93 worldBankDataPanel.setSizeFull();
94
95 targetPoliticiansPanel = new AggregatedBugsDataPanel(
96 translateFromEnglish("Politicians"));
97 grid.addComponent(targetPoliticiansPanel, 8, 0, 9, 7);
98 grid.setComponentAlignment(targetPoliticiansPanel,
99 Alignment.MIDDLE_CENTER);
100 targetPoliticiansPanel.update(country);
101 targetPoliticiansPanel.setSizeFull();
102 } else {
103 worldBankDataPanel = new WorldBankIndicatorCountryPanel();
104 grid.addComponent(worldBankDataPanel, 2, 0, 9, 7);
105 grid.setComponentAlignment(worldBankDataPanel,
106 Alignment.MIDDLE_CENTER);
107 worldBankDataPanel.update(country);
108 worldBankDataPanel.setSizeFull();
109 }
110
111 grid.setSizeFull();
112 grid.setMargin(false);
113 grid.setSpacing(true);
114 setCompositionRoot(grid);
115 setHeight(getScreenHeight());
116 }
117
118 }