001    package org.hackystat.projectbrowser.page.trajectory.dtwpanel.datapanel;
002    
003    import java.util.logging.Level;
004    import java.util.logging.Logger;
005    
006    import org.apache.wicket.Application;
007    import org.apache.wicket.AttributeModifier;
008    import org.apache.wicket.markup.html.WebComponent;
009    import org.apache.wicket.markup.html.basic.Label;
010    import org.apache.wicket.markup.html.panel.Panel;
011    import org.apache.wicket.model.IModel;
012    import org.apache.wicket.model.PropertyModel;
013    import org.hackystat.projectbrowser.ProjectBrowserApplication;
014    import org.hackystat.projectbrowser.ProjectBrowserSession;
015    import org.hackystat.projectbrowser.page.ProjectBrowserBasePage;
016    import org.hackystat.projectbrowser.page.popupwindow.PopupWindowPanel;
017    import org.hackystat.projectbrowser.page.trajectory.TrajectorySession;
018    
019    /**
020     * The DTW analysis panel displaying charts.
021     * 
022     * @author Pavel Senin
023     *
024     */
025    public class TrajectoryDTWDataPanel extends Panel {
026    
027      /** Support serialization. */
028      private static final long serialVersionUID = 1L;
029      /** TelemetrySession that hold the page state. */
030      TrajectorySession session = ProjectBrowserSession.get().getTrajectorySession();
031    
032      /**
033       * Constructor.
034       * 
035       * @param id the wicket component id.
036       * @param page the parent page.
037       */
038      public TrajectoryDTWDataPanel(String id, ProjectBrowserBasePage page) {
039        super(id);
040        getLogger().log(Level.FINER, "[DEBUG] TrajectoryDTWDataPanel constructed.");
041        IModel dataModel = new PropertyModel(session, "dataModel");
042    
043        // add the selected chart.
044        //
045        WebComponent selectedchartUrl = new WebComponent("selectedChart") {
046          /** Support serialization. */
047          public static final long serialVersionUID = 1L;
048    
049          @Override
050          public boolean isVisible() {
051            getLogger().log(Level.FINER,
052                "[DEBUG] Selected chart URL:" + session.getDataModel().isChartEmpty());
053            return !session.getDataModel().isChartEmpty();
054          }
055        };
056        selectedchartUrl.add(new AttributeModifier("src", true, new PropertyModel(dataModel,
057            "selectedChart")));
058        add(selectedchartUrl);
059    
060        // adding the help popup
061        //
062        PopupWindowPanel selectedchartUrlWindow = new PopupWindowPanel("selectedChartUrlWindow",
063            "Google Chart URL") {
064          /** Support serialization. */
065          public static final long serialVersionUID = 1L;
066    
067          @Override
068          public boolean isVisible() {
069            return !session.getDataModel().isChartEmpty();
070          }
071        };
072        selectedchartUrlWindow.getModalWindow().setContent(
073            new Label(selectedchartUrlWindow.getModalWindow().getContentId(), new PropertyModel(
074                dataModel, "selectedChart")));
075        add(selectedchartUrlWindow);
076    
077        // add the normalized chart.
078        //
079        WebComponent normalizedTSChartUrl = new WebComponent("normalizedTSChart") {
080          /** Support serialization. */
081          public static final long serialVersionUID = 2L;
082    
083          @Override
084          public boolean isVisible() {
085            getLogger().log(Level.FINER,
086                "[DEBUG] Normalized chart URL:" + session.getDataModel().isNormalizedTSChartEmpty());
087            return !session.getDataModel().isNormalizedTSChartEmpty();
088          }
089        };
090        normalizedTSChartUrl.add(new AttributeModifier("src", true, new PropertyModel(dataModel,
091            "normalizedTSChart")));
092        add(normalizedTSChartUrl);
093    
094        // add the DTW chart.
095        //
096        WebComponent dtwChartUrl = new WebComponent("DTWChart") {
097          /** Support serialization. */
098          public static final long serialVersionUID = 3L;
099    
100          @Override
101          public boolean isVisible() {
102            getLogger().log(Level.FINER,
103                "[DEBUG] DTW chart URL:" + session.getDataModel().isDTWChartEmpty());
104            return !session.getDataModel().isDTWChartEmpty();
105          }
106        };
107        dtwChartUrl.add(new AttributeModifier("src", true, new PropertyModel(dataModel, "DTWChart")));
108        add(dtwChartUrl);
109    
110      }
111    
112      /**
113       * @return the logger that associated to this web application.
114       */
115      private Logger getLogger() {
116        return ((ProjectBrowserApplication) Application.get()).getLogger();
117      }
118    
119    }