1
2
3
4
5 package org.directdemocracyportal.democracy.web.views;
6
7 import java.util.List;
8
9 import org.directdemocracyportal.democracy.model.application.OnlinePoliticalParty;
10 import org.directdemocracyportal.democracy.model.world.PoliticalParty;
11 import org.directdemocracyportal.democracy.web.BeanLocator;
12 import org.directdemocracyportal.democracy.web.ImageConstants;
13 import org.directdemocracyportal.democracy.web.action.ShowOnlinePoliticalPartyAction;
14
15 import thinwire.ui.GridBox;
16 import thinwire.ui.Image;
17 import thinwire.ui.Panel;
18 import thinwire.ui.layout.TableLayout;
19
20 /***
21 * The Class PoliticalPartiesPanel.
22 */
23 public class PoliticalPartiesPanel extends Panel
24 {
25
26 /***
27 * Instantiates a new political parties panel.
28 *
29 * @param parties the parties
30 */
31 public PoliticalPartiesPanel(List<OnlinePoliticalParty> parties) {
32 setLayout(new TableLayout(new double[][] { { 0 },
33 { 32, 0 } },
34 1,
35 5));
36
37 Image img = new Image(ImageConstants.POLITICAL_PARTY_BUTTON);
38 img.setSize(ImageConstants.BUTTON_SIZE, ImageConstants.BUTTON_SIZE);
39 img.setLimit("0,0,l,c");
40 getChildren().add(img);
41
42 GridBox gridBox = new GridBox();
43 gridBox.setVisibleHeader(true);
44 gridBox.setLimit("0,1,1,1");
45
46 GridBox.Column usernameHeader = new GridBox.Column();
47 usernameHeader.setName("Political Party");
48 gridBox.getColumns().add(usernameHeader);
49
50 for (PoliticalParty party : parties) {
51 GridBox.Row row = new GridBox.Row(party.getName());
52 row.setUserObject(new ShowOnlinePoliticalPartyAction(party.getId()));
53 gridBox.getRows().add(
54 row);
55 }
56 gridBox.addActionListener(ACTION_CLICK, BeanLocator
57 .getApplicationActionListener());
58
59 getChildren().add(gridBox);
60 }
61 }