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 thinwire.ui.GridBox;
8   
9   import com.hack23.cia.model.application.dto.common.UserSessionDTO;
10  import com.hack23.cia.model.application.impl.admin.LanguageAgencyActionEvent;
11  import com.hack23.cia.model.application.impl.common.Agency;
12  import com.hack23.cia.model.application.impl.common.Language;
13  import com.hack23.cia.web.action.admin.LanguageAgencyAction;
14  import com.hack23.cia.web.common.BeanLocator;
15  
16  /***
17   * The Class LanguagesGridBox.
18   */
19  public class LanguagesGridBox extends GridBox {
20  
21      /***
22       * Instantiates a new languages grid box.
23       *
24       * @param userSessionDTO the user session dto
25       * @param agency the agency
26       */
27      public LanguagesGridBox(final UserSessionDTO userSessionDTO,final Agency agency) {
28          super();
29          this.setVisibleHeader(true);
30          this.addActionListener(ACTION_CLICK, BeanLocator
31                  .getApplicationActionListener());
32  
33          this.getColumns().add(GridBoxColumnFactory.getNameHeader(userSessionDTO));
34  
35          for (final Language lang : agency.getLanguages()) {
36              final GridBox.Row row = new GridBox.Row(lang.getName());
37              row.setUserObject(new LanguageAgencyAction(
38                      LanguageAgencyActionEvent.Operation.Update, agency, lang));
39              this.getRows().add(row);
40          }
41      }
42  
43  }