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.Event;
10  import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
11  import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
12  
13  import thinwire.ui.GridBox;
14  import thinwire.ui.Panel;
15  import thinwire.ui.layout.TableLayout;
16  
17  /***
18   * The Class EventsPanel.
19   */
20  public class EventsPanel extends Panel
21  {
22  
23      /***
24       * Instantiates a new events panel.
25       *
26       * @param events the events
27       */
28      public EventsPanel(List<Event> events) {
29          super();
30          setLayout(new TableLayout(new double[][] { { 0 }, // Column Widths
31                  { 0 } }, // Row Heights
32                  1, // Margin around edge of container
33                  5)); // Spacing between cells
34  
35          GridBox gridBox = new GridBox();
36          gridBox.setVisibleHeader(true);
37          gridBox.setLimit("0,0,1,1");
38  
39          GridBox.Column timeHeader = new GridBox.Column();
40          timeHeader.setName(ApplicationMessageHolder
41                  .getMessage(MessageConstans.HEADER_TIME));
42          gridBox.getColumns().add(timeHeader);
43  
44          GridBox.Column actionHeader = new GridBox.Column();
45          actionHeader.setName(ApplicationMessageHolder
46                  .getMessage(MessageConstans.HEADER_ACTION));
47          gridBox.getColumns().add(actionHeader);
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 (Event event : events) {
55              gridBox.getRows().add(
56                      new GridBox.Row(event.getTime(), event.getAction(), event
57                              .getUser().getUsername()));
58          }
59          getChildren().add(gridBox);
60      }
61  }