001    package org.hackystat.projectbrowser.page.dailyprojectdata.detailspanel;
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    
009    /**
010     * A panel that contains a link representing some DPD information. When clicked, the link generates
011     * a popup window with further details about the DPD information.
012     * 
013     * @author Philip Johnson
014     * @author Shaoxuan Zhang
015     */
016    public class DailyProjectDetailsPanel extends Panel {
017      /** Support serialization. */
018      private static final long serialVersionUID = 1L;
019      /** The modal window inside this panel. */
020      private final ModalWindow modalWindow;
021    
022      /**
023       * Provides a panel that displays details about a portion of the DailyProjectData. The panel
024       * consists of a link which, when clicked, will display a modal window with details about the data
025       * represented by the link. After creating this panel, you can call getModalWindow() to obtain the
026       * model window instance and set its content.
027       * 
028       * @param id The wicket component id.
029       * @param title The title of the window.
030       * @param linkLabel The label to be associated with the link.
031       */
032      public DailyProjectDetailsPanel(String id, String title, String linkLabel) {
033        super(id);
034        // Create, configure, and add the modal window to this panel.
035        this.modalWindow = new ModalWindow("modalWindow");
036        add(modalWindow);
037    
038        this.modalWindow.setCookieName("modalWindow");
039        this.modalWindow.setTitle(title);
040    
041        this.modalWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
042          /** Support serialization. */
043          private static final long serialVersionUID = 1L;
044    
045          public boolean onCloseButtonClicked(AjaxRequestTarget target) {
046            return true;
047          }
048        });
049        // Create, configure, and add the link that displays the modal window to this panel.
050        AjaxLink link = new AjaxLink("showModalWindow") {
051          /** Support serialization. */
052          private static final long serialVersionUID = 1L;
053    
054          @Override
055          public void onClick(AjaxRequestTarget target) {
056            modalWindow.show(target);
057          }
058        };
059        link.add(new Label("detailsLink", linkLabel));
060        add(link);
061      }
062    
063      /**
064       * @return the modalWindow
065       */
066      public ModalWindow getModalWindow() {
067        return modalWindow;
068      }
069    
070    }