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.sweden.impl.ParliamentMember;
13  import com.hack23.cia.web.common.BeanLocator;
14  
15  /***
16   * The Class AbstractParliamentMemberGridBox.
17   */
18  public abstract class AbstractParliamentMemberGridBox extends GridBox {
19  
20      /*** The user session dto. */
21      private final UserSessionDTO userSessionDTO;
22  
23      /***
24       * Instantiates a new abstract parliament member grid box.
25       *
26       * @param userSessionDTO the user session dto
27       * @param currentList the current list
28       */
29      public AbstractParliamentMemberGridBox(final UserSessionDTO userSessionDTO,
30              final List<ParliamentMember> currentList) {
31          super();
32          this.userSessionDTO = userSessionDTO;
33          this.setVisibleHeader(true);
34          this.addActionListener(ACTION_CLICK, BeanLocator
35                  .getApplicationActionListener());
36  
37          addGridBoxColumns();
38  
39          this.getColumns().add(GridBoxColumnFactory.getRegisteredVotesHeader(userSessionDTO));
40          this.getColumns().add(GridBoxColumnFactory.getNameHeader(userSessionDTO));
41          this.getColumns().add(GridBoxColumnFactory.getPartyHeader(userSessionDTO));
42          this.getColumns().add(GridBoxColumnFactory.getElectoralAreaHeader(userSessionDTO));
43          this.getColumns().add(GridBoxColumnFactory.getFirstVoteHeader(userSessionDTO));
44          this.getColumns().add(GridBoxColumnFactory.getLastVoteHeader(userSessionDTO));
45  
46          int rank = 1;
47          for (final ParliamentMember parliamentMember : currentList) {
48              this.getRows().add(createRow(rank++, parliamentMember));
49          }
50      }
51  
52      /***
53       * Adds the grid box columns.
54       */
55      abstract void addGridBoxColumns();
56  
57      /***
58       * Creates the row.
59       *
60       * @param row the row
61       * @param parliamentMember the parliament member
62       * @return the grid box. row
63       */
64      abstract GridBox.Row createRow(int row, ParliamentMember parliamentMember);
65  
66      /***
67       * Gets the user session dto.
68       *
69       * @return the user session dto
70       */
71      public final UserSessionDTO getUserSessionDTO() {
72          return userSessionDTO;
73      }
74  
75  }