View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package com.hack23.cia.web.views.components.gridboxes;
6   
7   import java.util.List;
8   
9   import thinwire.ui.GridBox;
10  
11  import com.hack23.cia.model.application.dto.common.UserSessionDTO;
12  import com.hack23.cia.model.application.impl.common.Agency;
13  import com.hack23.cia.model.sweden.impl.Vote;
14  import com.hack23.cia.web.action.user.BallotAction;
15  import com.hack23.cia.web.common.BeanLocator;
16  
17  /***
18   * The Class VoteGridBox.
19   */
20  public class VoteGridBox extends GridBox {
21  
22      /***
23       * Instantiates a new vote grid box.
24       *
25       * @param userSessionDTO the user session dto
26       * @param votes the votes
27       */
28      public VoteGridBox(final UserSessionDTO userSessionDTO,final List<Vote> votes) {
29          super();
30          this.setVisibleHeader(true);
31          this.addActionListener(ACTION_CLICK, BeanLocator
32                  .getApplicationActionListener());
33  
34          final GridBox.Column dateHeader = new GridBox.Column();
35          dateHeader.setName(userSessionDTO
36                  .getLanguageResource(Agency.LanguageContentKey.DECISION_DATE));
37          this.getColumns().add(dateHeader);
38  
39          final GridBox.Column votePositionHeader = new GridBox.Column();
40          votePositionHeader.setName(userSessionDTO
41                  .getLanguageResource(Agency.LanguageContentKey.VOTE_POSITION));
42          this.getColumns().add(votePositionHeader);
43  
44          final GridBox.Column winningSideHeader = new GridBox.Column();
45          winningSideHeader.setName(userSessionDTO
46                  .getLanguageResource(Agency.LanguageContentKey.WINNING_SIDE));
47          this.getColumns().add(winningSideHeader);
48  
49          final GridBox.Column winningSideInPartyHeader = new GridBox.Column();
50          winningSideInPartyHeader.setName(userSessionDTO
51                  .getLanguageResource(Agency.LanguageContentKey.WINNING_SIDE_IN_PARTY));
52          this.getColumns().add(winningSideInPartyHeader);
53  
54          final GridBox.Column commiteeReportHeader = new GridBox.Column();
55          commiteeReportHeader.setName(userSessionDTO
56                  .getLanguageResource(Agency.LanguageContentKey.COMMITEE_REPORT));
57          this.getColumns().add(commiteeReportHeader);
58  
59          final GridBox.Column ballotHeader = new GridBox.Column();
60          ballotHeader.setName(userSessionDTO
61                  .getLanguageResource(Agency.LanguageContentKey.BALLOT));
62          this.getColumns().add(ballotHeader);
63  
64          for (final Vote vote : votes) {
65              final GridBox.Row row = new GridBox.Row(vote.getDatum().toString(),
66                      userSessionDTO.getLanguageResource(vote.getPosition()), userSessionDTO
67                              .getLanguageResource(vote.getBallot().getBallotResult()
68                                      .getWinningPosition()),
69                      userSessionDTO.getLanguageResource(vote.getBallot().getPartyBallotResult(
70                                      vote.getParliamentMember().getParty())
71                              .getWinningPosition()), vote.getBallot()
72                              .getCommiteeReport().getName(), vote.getBallot()
73                              .getDescription());
74              row.setUserObject(new BallotAction(vote.getBallot().getId()));
75              this.getRows().add(row);
76          }
77      }
78  
79  }