/*
 *  Draco Econometrics
 *  Copyright (C) 2006-2009 Approximatrix, LLC
 *  http://www.approximatrix.com
 *  
 *  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/>.
 */

package com.approximatrix.draco.editor.wizard.ui;

import java.awt.BorderLayout;


import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import org.pietschy.wizard.InvalidStateException;
import org.pietschy.wizard.PanelWizardStep;

import com.approximatrix.draco.application.plugin.PluginType;
import com.approximatrix.draco.editor.wizard.PluginWizardData;

public class PluginTypeStep extends PanelWizardStep {

	public static final String REGRESSION_PLUGIN = "<html><body><b>Regression Plugin</b><br>"+
		"Regression plugins attempt to compute estimated parameters<br>" +
		"and normally return estimates along with associated errors.<br>" +
		"Regression plugins are integrated into the <i>Regress</i> menu.</body></html>";
	
	public static final String ANALYSIS_PLUGIN = "<html><body><b>Analysis Plugin</b><br>"+
		"Analysis plugins utilize model data to compute statistics, <br>forecasts," +
		"or relationships.  Analysis plugins are integrated into<br> the <i>Data</i> menu.</body></html>";

	private JRadioButton regressButton = null;
	private JRadioButton analysisButton = null;
	
	private PluginWizardData pwd = null;
	
	public PluginTypeStep(PluginWizardData pwd) {
		super("Plugin Type","Select the desired plugin type to create.");
		
		this.pwd = pwd;
		
		this.setLayout(new BorderLayout());
		
		regressButton = new JRadioButton(REGRESSION_PLUGIN);
		analysisButton = new JRadioButton(ANALYSIS_PLUGIN);
		
		ButtonGroup pluginButtons = new ButtonGroup();
		pluginButtons.add(regressButton);
		pluginButtons.add(analysisButton);
		
		regressButton.setSelected(true);
		
		JPanel selectPanel = new JPanel();
		
		selectPanel.setLayout(new BoxLayout(selectPanel,BoxLayout.Y_AXIS));
		selectPanel.add(regressButton);
		selectPanel.add(analysisButton);
		
		selectPanel.setSize(250, 150);
		
		add(selectPanel,BorderLayout.CENTER);
		
		this.setComplete(true);
	}
	
	@Override
	public void applyState() throws InvalidStateException {
		if(regressButton.isSelected())
			this.pwd.setPluginType(PluginType.regression);
		else
			this.pwd.setPluginType(PluginType.analysis);
	}
	
}
