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.Set;
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.admin.PortalActionEvent;
13  import com.hack23.cia.model.application.impl.common.Portal;
14  import com.hack23.cia.web.action.admin.PortalAction;
15  import com.hack23.cia.web.common.BeanLocator;
16  
17  /***
18   * The Class PortalsGridBox.
19   */
20  public class PortalsGridBox extends GridBox {
21  
22      /***
23       * Instantiates a new portals grid box.
24       *
25       * @param userSessionDTO the user session dto
26       * @param portals the portals
27       */
28      public PortalsGridBox(final UserSessionDTO userSessionDTO,final Set<Portal> portals) {
29          super();
30  
31          this.setVisibleHeader(true);
32          this.addActionListener(ACTION_CLICK, BeanLocator
33                  .getApplicationActionListener());
34  
35          this.getColumns().add(GridBoxColumnFactory.getNameHeader(userSessionDTO));
36          this.getColumns().add(GridBoxColumnFactory.getPortalMatchesUrlHeader(userSessionDTO));
37  
38          for (final Portal portal : portals) {
39              final GridBox.Row row = new GridBox.Row(portal.getName(), portal
40                      .getMatchesUrl());
41              row.setUserObject(new PortalAction(
42                      PortalActionEvent.Operation.Update, portal));
43              this.getRows().add(row);
44          }
45      }
46  }