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.Person;
10 import org.directdemocracyportal.democracy.model.world.Vote;
11 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
12 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
13
14 import thinwire.ui.GridBox;
15 import thinwire.ui.Label;
16 import thinwire.ui.Panel;
17 import thinwire.ui.layout.TableLayout;
18
19 /***
20 * The Class PersonProfilePanel.
21 */
22 public class PersonProfilePanel extends Panel
23 {
24
25 /***
26 * Instantiates a new person profile panel.
27 *
28 * @param person the person
29 * @param votes the votes
30 */
31 public PersonProfilePanel(Person person, List<Vote> votes) {
32
33 setLayout(new TableLayout(new double[][] { { 0 },
34
35 { 20,0} },
36 1,
37 5));
38
39
40 Label informationLabel = new Label(ApplicationMessageHolder
41 .getMessage(MessageConstans.INFORMATION) + " " + person.getName());
42 informationLabel.setLimit("0,0");
43 getChildren().add(informationLabel);
44
45 GridBox informationBox = getVotesGridBox(votes);
46 informationBox.setLimit("0,1");
47 getChildren().add(informationBox);
48 }
49
50 /***
51 * Gets the votes grid box.
52 *
53 * @param votes the votes
54 * @return the votes grid box
55 */
56 private GridBox getVotesGridBox(List<Vote> votes) {
57 GridBox gridBox = new GridBox();
58 gridBox.setVisibleHeader(true);
59
60 GridBox.Column dateHeader = new GridBox.Column();
61 dateHeader.setName(ApplicationMessageHolder
62 .getMessage(MessageConstans.DATE));
63 gridBox.getColumns().add(dateHeader);
64
65 GridBox.Column positionHeader = new GridBox.Column();
66 positionHeader.setName(ApplicationMessageHolder
67 .getMessage(MessageConstans.VOTE));
68 gridBox.getColumns().add(positionHeader);
69
70 for (Vote vote: votes) {
71 gridBox.getRows().add(new GridBox.Row(vote.getVoteDate(),vote.getPosition()));
72 }
73
74 return gridBox;
75 }
76 }