/*
 * #%L
 * gitools-ui-app
 * %%
 * Copyright (C) 2013 Universitat Pompeu Fabra - Biomedical Genomics group
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
package org.gitools.ui.analysis.wizard;

import org.apache.velocity.VelocityContext;
import org.gitools.ui.platform.panel.TemplatePanel;
import org.gitools.ui.platform.wizard.AbstractWizardPage;

import java.awt.*;
import java.net.URL;

public class ExamplePage extends AbstractWizardPage {

    public ExamplePage(String title) {
        initComponents();

        URL url = getClass().getResource("/vm/new_analysis_intro.vm");
        try {
            VelocityContext context = new VelocityContext();
            context.put("analysis_title", title);
            TemplatePanel panel = new TemplatePanel();
            panel.setTemplateFromResource("/vm/new_analysis_intro.vm", url);
            panel.render(context);
            panel.setPreferredSize(new Dimension(494, 231));
            textPanel.setLayout(new BorderLayout());
            textPanel.add(panel, BorderLayout.CENTER);

        } catch (Exception ex) {
        }

        setComplete(true);
    }

    public boolean isExampleEnabled() {
        return exampleCheck.isSelected();
    }

    public boolean isShowAgain() {
        return !dontShowAgainCheck.isSelected();
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        textPanel = new javax.swing.JPanel();
        exampleCheck = new javax.swing.JCheckBox();
        dontShowAgainCheck = new javax.swing.JCheckBox();

        textPanel.setBackground(new java.awt.Color(254, 254, 254));
        textPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout textPanelLayout = new javax.swing.GroupLayout(textPanel);
        textPanel.setLayout(textPanelLayout);
        textPanelLayout.setHorizontalGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 494, Short.MAX_VALUE));
        textPanelLayout.setVerticalGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 231, Short.MAX_VALUE));

        exampleCheck.setText("Fill this wizard with an example");

        dontShowAgainCheck.setText("Don't show this page next time");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(textPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(dontShowAgainCheck).addComponent(exampleCheck)).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(textPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGap(18, 18, 18).addComponent(exampleCheck).addGap(18, 18, 18).addComponent(dontShowAgainCheck).addContainerGap()));
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox dontShowAgainCheck;
    private javax.swing.JCheckBox exampleCheck;
    private javax.swing.JPanel textPanel;
    // End of variables declaration//GEN-END:variables

}
