001    package org.hackystat.projectbrowser.page.sensordata;
002    
003    import java.util.List;
004    
005    import javax.xml.datatype.XMLGregorianCalendar;
006    
007    import org.apache.wicket.markup.html.list.ListItem;
008    import org.apache.wicket.markup.html.list.ListView;
009    import org.apache.wicket.markup.html.panel.Panel;
010    import org.hackystat.sensorbase.resource.projects.jaxb.SensorDataSummary;
011    
012    /**
013     * A panel for holding the SDT summary information. 
014     * @author Philip Johnson
015     */
016    public class SdtSummaryPanel extends Panel {
017    
018      /** For serialization. */
019      private static final long serialVersionUID = 1L;
020      /** Must be serializable, thus a long rather than an XMLGregorianCalendar. */
021      private long start; 
022      
023      /**
024       * Creates a panel to display summary information. 
025       * @param id The wicket ID. 
026       * @param summaryList The list of SensorDataSummary instances to be displayed in this panel.
027       * @param startTime The time this summary information started.
028       */
029      public SdtSummaryPanel(String id, List<SensorDataSummary> summaryList, 
030          XMLGregorianCalendar startTime) {
031        super(id);
032        this.start = startTime.toGregorianCalendar().getTimeInMillis();
033        // Set up the table
034        add(new ListView("ToolInfoList", summaryList) {
035          /** For serialization */
036          private static final long serialVersionUID = 1L;
037    
038          /** 
039           * How to populate the table.
040           * @param item The ProjectSummary item.  
041           */
042          @Override
043          protected void populateItem(ListItem item) {
044            SensorDataSummary summary = (SensorDataSummary)item.getModelObject();
045            String tool = summary.getTool();
046            String sdt = summary.getSensorDataType();
047            String info = String.format("%d:%s ", summary.getNumInstances().intValue(), tool); 
048            SensorDataPopupPanel sdtPopup = new SensorDataPopupPanel("SdtPopup", "SDT Info", info, sdt, 
049                tool, start);
050            item.add(sdtPopup);
051          }
052        });
053      }
054    }