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.ParliamentMember;
14  import com.hack23.cia.web.action.user.ParliamentMemberAction;
15  
16  /***
17   * The Class ParliamentMemberGridBox.
18   */
19  public class ParliamentMemberGridBox extends AbstractParliamentMemberGridBox {
20  
21      /***
22       * Instantiates a new parliament member grid box.
23       *
24       * @param userSessionDTO the user session dto
25       * @param currentList the current list
26       */
27      public ParliamentMemberGridBox(final UserSessionDTO userSessionDTO,final List<ParliamentMember> currentList) {
28          super(userSessionDTO,currentList);
29      }
30  
31      /*
32       * (non-Javadoc)
33       * 
34       * @see
35       * com.hack23.cia.web.views.AbstractTopListPanel#addGridBoxColumns(thinwire
36       * .ui.GridBox)
37       */
38      @Override
39      final void addGridBoxColumns() {
40          this.getColumns()
41                  .add(GridBoxColumnFactory.getWinningOccassionsHeader(getUserSessionDTO()));
42  
43          final GridBox.Column rebelOccassionsHeader = new GridBox.Column();
44          rebelOccassionsHeader.setName(getUserSessionDTO()
45                  .getLanguageResource(Agency.LanguageContentKey.REBEL_OCCASSIONS));
46          this.getColumns().add(rebelOccassionsHeader);
47  
48          final GridBox.Column absentOccassionsHeader = new GridBox.Column();
49          absentOccassionsHeader.setName(getUserSessionDTO()
50                  .getLanguageResource(Agency.LanguageContentKey.ABSENT_OCCASSIONS));
51          this.getColumns().add(absentOccassionsHeader);
52      }
53  
54      /*
55       * (non-Javadoc)
56       * 
57       * @see com.hack23.cia.web.views.AbstractTopListPanel#createRow(int,
58       * com.hack23.cia.model.sweden.ParliamentMember)
59       */
60      @Override
61      final Row createRow(final int rank, final ParliamentMember parliamentMember) {
62          final GridBox.Row row = new GridBox.Row(parliamentMember.getParliamentMemberBallotRecord().getWinning(),
63                  parliamentMember.getParliamentMemberBallotRecord().getRebel(), parliamentMember.getParliamentMemberBallotRecord().getAbsentVotes(),
64                  parliamentMember.getParliamentMemberBallotRecord().getTotalVotes(), parliamentMember.getName(),
65                  parliamentMember.getParty(), parliamentMember
66                          .getElectoralRegion(), parliamentMember.getParliamentMemberBallotRecord()
67                          .getFirstVoteDate(), parliamentMember.getParliamentMemberBallotRecord().getLastVoteDate());
68          row.setUserObject(new ParliamentMemberAction(parliamentMember.getId()));
69          return row;
70      }
71  }