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 org.directdemocracyportal.democracy.web.views;
6   
7   import java.util.List;
8   
9   import org.directdemocracyportal.democracy.model.application.User;
10  import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
11  import org.directdemocracyportal.democracy.web.BeanLocator;
12  import org.directdemocracyportal.democracy.web.ImageConstants;
13  import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
14  import org.directdemocracyportal.democracy.web.action.ShowUserAction;
15  
16  import thinwire.ui.GridBox;
17  import thinwire.ui.Image;
18  import thinwire.ui.Panel;
19  import thinwire.ui.layout.TableLayout;
20  
21  /***
22   * The Class MembersPanel.
23   */
24  public class MembersPanel extends Panel
25  {
26  
27      /***
28       * Instantiates a new members panel.
29       *
30       * @param users the users
31       */
32      public MembersPanel(List<User> users) {
33          setLayout(new TableLayout(new double[][] { { 0 }, // Column Widths
34                  { 32, 0 } }, // Row Heights
35                  1, // Margin around edge of container
36                  5)); // Spacing between cells
37  
38          Image img = new Image(ImageConstants.GROUP_HOME_BUTTON);
39          img.setSize(ImageConstants.BUTTON_SIZE, ImageConstants.BUTTON_SIZE);
40          img.setLimit("0,0,l,c");
41          getChildren().add(img);
42  
43          GridBox gridBox = new GridBox();
44          gridBox.setVisibleHeader(true);
45          gridBox.setLimit("0,1,1,1");
46          gridBox.addActionListener(ACTION_CLICK, BeanLocator
47                  .getApplicationActionListener());
48  
49          GridBox.Column usernameHeader = new GridBox.Column();
50          usernameHeader.setName(ApplicationMessageHolder
51                  .getMessage(MessageConstans.HEADER_USERNAME));
52          gridBox.getColumns().add(usernameHeader);
53  
54          for (User user : users) {
55              GridBox.Row row = new GridBox.Row(user.getUsername());
56              row.setUserObject(new ShowUserAction(user.getId()));
57              gridBox.getRows().add(
58                      row);
59          }
60  
61          getChildren().add(gridBox);
62      }
63  }