1
2
3
4
5 package org.directdemocracyportal.democracy.web.views;
6
7 import java.util.List;
8
9 import org.directdemocracyportal.democracy.model.world.Government;
10 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
11 import org.directdemocracyportal.democracy.web.BeanLocator;
12 import org.directdemocracyportal.democracy.web.ImageConstants;
13 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
14 import org.directdemocracyportal.democracy.web.action.ShowGovernmentAction;
15
16 import thinwire.ui.GridBox;
17 import thinwire.ui.Image;
18 import thinwire.ui.Panel;
19 import thinwire.ui.layout.TableLayout;
20
21 /***
22 * The Class GovernmentsPanel.
23 */
24 public class GovernmentsPanel extends Panel
25 {
26
27 /***
28 * Instantiates a new governments panel.
29 *
30 * @param governments the governments
31 */
32 public GovernmentsPanel(List<Government> governments) {
33 setLayout(new TableLayout(new double[][] { { 0 },
34 { ImageConstants.BUTTON_SIZE, 0 } },
35 1,
36 5));
37
38 Image img = new Image(ImageConstants.GOVERNMENT_BUTTON);
39 img.setSize(ImageConstants.BUTTON_SIZE, ImageConstants.BUTTON_SIZE);
40 img.setLimit("0,0,l,c");
41 getChildren().add(img);
42
43 GridBox gridBox = new GridBox();
44 gridBox.setVisibleHeader(true);
45 gridBox.setLimit("0,1,1,1");
46
47 GridBox.Column nameHeader = new GridBox.Column();
48 nameHeader.setName(ApplicationMessageHolder
49 .getMessage(MessageConstans.HEADER_NAME));
50 gridBox.getColumns().add(nameHeader);
51
52 GridBox.Column typeHeader = new GridBox.Column();
53 typeHeader.setName(ApplicationMessageHolder
54 .getMessage(MessageConstans.TYPE));
55 gridBox.getColumns().add(typeHeader);
56
57 GridBox.Column headofStateHeader = new GridBox.Column();
58 headofStateHeader.setName(ApplicationMessageHolder
59 .getMessage(MessageConstans.HEAD_OF_STATE));
60 gridBox.getColumns().add(headofStateHeader);
61
62 for (Government government : governments) {
63 GridBox.Row row = new GridBox.Row(government.getName(),
64 government.getGovernmentType(), government
65 .getHeadofState().getName());
66 row.setUserObject(new ShowGovernmentAction(government.getId()));
67 gridBox.getRows().add(row);
68 }
69 gridBox.addActionListener(ACTION_CLICK, BeanLocator
70 .getApplicationActionListener());
71
72 getChildren().add(gridBox);
73 }
74 }