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 TopLosersGridBox.
18   */
19  public class TopLosersGridBox extends AbstractParliamentMemberGridBox {
20  
21      /***
22       * Instantiates a new top losers grid box.
23       *
24       * @param userSessionDTO the user session dto
25       * @param currentList the current list
26       */
27      public TopLosersGridBox(final UserSessionDTO userSessionDTO,final List<ParliamentMember> currentList) {
28          super(userSessionDTO,currentList);
29          // TODO Auto-generated constructor stub
30      }
31  
32      /*
33       * (non-Javadoc)
34       * 
35       * @see
36       * com.hack23.cia.web.views.AbstractTopListPanel#addGridBoxColumns(thinwire
37       * .ui.GridBox)
38       */
39      @Override
40      final void addGridBoxColumns() {
41          this.getColumns().add(GridBoxColumnFactory.getRankHeader(getUserSessionDTO()));
42  
43          final GridBox.Column absentHeader = new GridBox.Column();
44          absentHeader.setName(getUserSessionDTO()
45                  .getLanguageResource(Agency.LanguageContentKey.LOSER_PERCENT));
46          this.getColumns().add(absentHeader);
47  
48          final GridBox.Column tillfallenFranvaroHeader = new GridBox.Column();
49          tillfallenFranvaroHeader.setName(getUserSessionDTO()
50                  .getLanguageResource(Agency.LanguageContentKey.VOTE_OCCASSIONS_LOST));
51          this.getColumns().add(tillfallenFranvaroHeader);
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(rank, Long.valueOf(parliamentMember.getParliamentMemberBallotRecord()
63                  .getPercentageLoosing()), parliamentMember.getParliamentMemberBallotRecord().getOpponent(),
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  
72  }