001 package org.hackystat.projectbrowser.page.sensordata; 002 003 import org.apache.wicket.ajax.AjaxRequestTarget; 004 import org.apache.wicket.ajax.markup.html.AjaxLink; 005 import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; 006 import org.apache.wicket.markup.html.basic.Label; 007 import org.apache.wicket.markup.html.panel.Panel; 008 import org.hackystat.projectbrowser.ProjectBrowserSession; 009 010 /** 011 * A panel that contains a popup window. 012 * This one differs from PopupWindowPanel because the link is a regular text label, not an img. 013 * Since the HTML markup page is slightly different, it's not clear to me how we could 014 * avoid these two classes that are almost identical except for the link label creation code. 015 * @author Shaoxuan Zhang 016 * @author Philip Johnson 017 */ 018 public class SensorDataPopupPanel extends Panel { 019 /** Support serialization. */ 020 private static final long serialVersionUID = 1L; 021 /** The modal window inside this panel. */ 022 private final ModalWindow modalWindow; 023 /** The link that bring up the popup window. */ 024 private long start; 025 private String sdt; 026 private String tool; 027 028 /** 029 * A panel containing sensor data information for the given tool and type. 030 * @param id the wicket component id. 031 * @param title the title of the popup window. 032 * @param linkLabel The label to go in the link that pops up this panel. 033 * @param sdtName The name of the SDT. 034 * @param toolName The name of the tool that generated this sensor data. 035 * @param startTime The start time for this data. 036 */ 037 public SensorDataPopupPanel(String id, String title, String linkLabel, String sdtName, 038 String toolName, long startTime) { 039 super(id); 040 this.sdt = sdtName; 041 this.tool = toolName; 042 this.start = startTime; 043 044 modalWindow = new ModalWindow("modalWindow"); 045 add(modalWindow); 046 047 modalWindow.setCookieName("modalWindow"); 048 modalWindow.setTitle(title); 049 050 modalWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { 051 /** Support serialization. */ 052 private static final long serialVersionUID = 1L; 053 public boolean onCloseButtonClicked(AjaxRequestTarget target) { 054 return true; 055 } 056 }); 057 AjaxLink link = new AjaxLink("showModalWindow") { 058 /** Support serialization. */ 059 private static final long serialVersionUID = 1L; 060 @Override 061 public void onClick(AjaxRequestTarget target) { 062 SensorDataSession session = ProjectBrowserSession.get().getSensorDataSession(); 063 session.getSensorDataDetailsProvider().setSensorDataDetailsProvider(sdt, tool, start); 064 session.setSdtName(sdt); 065 session.setTool(tool); 066 modalWindow.setContent(new SensorDataDetailsPanel(modalWindow.getContentId())); 067 modalWindow.show(target); 068 } 069 }; 070 link.add(new Label("LinkLabel", linkLabel)); 071 add(link); 072 } 073 074 /** 075 * @return the modalWindow 076 */ 077 public ModalWindow getModalWindow() { 078 return modalWindow; 079 } 080 081 }