001 package org.hackystat.projectbrowser.page.dailyprojectdata.build; 002 003 import org.apache.wicket.markup.html.basic.Label; 004 import org.apache.wicket.markup.html.list.ListItem; 005 import org.apache.wicket.markup.html.list.ListView; 006 import org.apache.wicket.markup.html.panel.Panel; 007 import org.apache.wicket.model.PropertyModel; 008 import org.hackystat.projectbrowser.ProjectBrowserSession; 009 import org.hackystat.projectbrowser.page.dailyprojectdata.DailyProjectDataSession; 010 011 012 /** 013 * Data panel for build. 014 * 015 * @author Philip Johnson 016 * @author Shaoxuan Zhang 017 * 018 */ 019 public class BuildPanel extends Panel { 020 021 /** Support serialization. */ 022 private static final long serialVersionUID = 1L; 023 024 /** 025 * Create this panel, providing the appropriate wicket ID. 026 * 027 * @param id The wicket component id. 028 */ 029 public BuildPanel(String id) { 030 super(id); 031 DailyProjectDataSession session = ProjectBrowserSession.get().getDailyProjectDataSession(); 032 // prepare the data model. 033 BuildDataModel dataModel = session.getBuildDataModel(); 034 add(new Label("valuesType", session.getContextSensitiveMenu("Values").getSelectedValue())); 035 ListView buildListView = new ListView("buildDataList", new PropertyModel(dataModel, 036 "buildDataList")) { 037 /** Support serialization. */ 038 private static final long serialVersionUID = 1L; 039 040 @Override 041 protected void populateItem(ListItem item) { 042 BuildData buildData = (BuildData) item.getModelObject(); 043 item.add(new Label("project", buildData.getProject().getName())); 044 DailyProjectDataSession session = ProjectBrowserSession.get().getDailyProjectDataSession(); 045 String valueType = session.getContextSensitiveMenu("Values").getSelectedValue(); 046 item.add(buildData.getPanel("bucket0", 0, ("Count".equals(valueType)))); 047 item.add(buildData.getPanel("bucket1", 1, ("Count".equals(valueType)))); 048 item.add(new Label("total", buildData.getTotalString())); 049 } 050 }; 051 add(buildListView); 052 } 053 054 /** 055 * Returns true if this panel should be displayed. 056 * The panel should be displayed if its corresponding data model has information. 057 * @return True if this panel should be displayed. 058 */ 059 @Override 060 public boolean isVisible() { 061 DailyProjectDataSession session = ProjectBrowserSession.get().getDailyProjectDataSession(); 062 return !session.getBuildDataModel().isEmpty(); 063 } 064 }