/**
 * GetStatsDialog.java
 * @date Jan 2, 2010
 * @author ricky barrette
 * @author Twenty Codes, LLC
 */
package com.TwentyCodes.java.OrderProcessor.UI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EmptyBorder;

import com.TwentyCodes.java.OrderProcessor.Date;
import com.TwentyCodes.java.OrderProcessor.Months;

/**
 * this will be a dialog for getting information about the stats the user is looking for
 * @author ricky barrette
 */
public class GetStatsDialog extends JFrame implements ActionListener {


	private static final long serialVersionUID = -8681149469926405790L;
	private JPanel contentPane;
	private JRadioButton mJan;
	private JRadioButton mFeb;
	private JRadioButton mMar;
	private JRadioButton mApr;
	private JRadioButton mJun;
	private JRadioButton mJul;
	private JRadioButton mAug;
	private JRadioButton mSep;
	private JRadioButton mNov;
	private JRadioButton mDec;
	private JRadioButton mYear;
	private JRadioButton mMay;
	private JRadioButton mOct;
	private JTextField textField;
	private JButton mOkButton;
	@SuppressWarnings("unused")
	private Months mTimeFrame = Months.JAN;
	@SuppressWarnings("unused")
	private Date mStartDate;
	@SuppressWarnings("unused")
	private Date mEndDate;

	/**
	 * Create the frame.
	 */
	public GetStatsDialog() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 260, 371);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		
		ButtonGroup group = new ButtonGroup();
		mJan = new JRadioButton("Jan");
		mFeb = new JRadioButton("Feb");
		mMar = new JRadioButton("Mar");
		mApr = new JRadioButton("Apr");
		mMay = new JRadioButton("May");
		mJun = new JRadioButton("Jun");
		mJul = new JRadioButton("Jul");
		mAug = new JRadioButton("Aug");
		mSep = new JRadioButton("Sep");
		mOct = new JRadioButton("Oct");
		mNov = new JRadioButton("Nov");
		mDec = new JRadioButton("Dec");
		mYear = new JRadioButton("Year");
		
		group.add(mJan);
		group.add(mFeb);
		group.add(mMar);
		group.add(mApr);
		group.add(mMay);
		group.add(mJun);
		group.add(mJul);
		group.add(mAug);
		group.add(mSep);
		group.add(mOct);
		group.add(mNov);
		group.add(mDec);
		group.add(mYear);
		
		mJan.setSelected(true);
		
		//Put the radio buttons in a column in a panel.
        JPanel radioPanel = new JPanel();
        
        mJan.addActionListener(this);
        mFeb.addActionListener(this);
        mMar.addActionListener(this);
        mApr.addActionListener(this);
        mMay.addActionListener(this);
        mJun.addActionListener(this);
        mJul.addActionListener(this);
        mAug.addActionListener(this);
        mSep.addActionListener(this);
        mOct.addActionListener(this);
        mNov.addActionListener(this);
        mDec.addActionListener(this);
        mYear.addActionListener(this);
		setContentPane(contentPane);
		
		JLabel lblTimeFrame = new JLabel("Time Frame");
		
		JLabel lblApplicationName = new JLabel("Application Name");
		
		textField = new JTextField();
		textField.setColumns(10);
		
		mOkButton = new JButton("Ok");
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(mOkButton, GroupLayout.PREFERRED_SIZE, 135, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblApplicationName))
							.addPreferredGap(ComponentPlacement.RELATED))
						.addComponent(textField))
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(lblTimeFrame)
						.addComponent(radioPanel, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE))
					.addGap(164))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblTimeFrame)
						.addComponent(lblApplicationName))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
						.addComponent(radioPanel, GroupLayout.PREFERRED_SIZE, 306, GroupLayout.PREFERRED_SIZE)
						.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
							.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
							.addComponent(mOkButton)))
					.addContainerGap())
		);
		GroupLayout gl_radioPanel = new GroupLayout(radioPanel);
		gl_radioPanel.setHorizontalGroup(
			gl_radioPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_radioPanel.createSequentialGroup()
					.addContainerGap()
					.addComponent(mDec)
					.addContainerGap(45, Short.MAX_VALUE))
				.addGroup(gl_radioPanel.createSequentialGroup()
					.addGroup(gl_radioPanel.createParallelGroup(Alignment.TRAILING)
						.addGroup(Alignment.LEADING, gl_radioPanel.createSequentialGroup()
							.addContainerGap()
							.addGroup(gl_radioPanel.createParallelGroup(Alignment.LEADING)
								.addComponent(mJan)
								.addComponent(mFeb)
								.addComponent(mMar)
								.addComponent(mApr)
								.addComponent(mMay)
								.addComponent(mJun)
								.addComponent(mJul)
								.addComponent(mAug)
								.addComponent(mSep)
								.addComponent(mOct)
								.addComponent(mNov, GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)))
						.addGroup(Alignment.LEADING, gl_radioPanel.createSequentialGroup()
							.addContainerGap()
							.addComponent(mYear)))
					.addGap(39))
		);
		gl_radioPanel.setVerticalGroup(
			gl_radioPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_radioPanel.createSequentialGroup()
					.addComponent(mJan)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mFeb)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mMar)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mApr)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mMay)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mJun)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mJul)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mAug)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mSep)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mOct)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mNov)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mDec)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(mYear)
					.addGap(167))
		);
		radioPanel.setLayout(gl_radioPanel);
		contentPane.setLayout(gl_contentPane);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == mJan){
			mTimeFrame = Months.JAN;
		}
				
		if(e.getSource() == mFeb){
			mTimeFrame = Months.FEB;
		}
		
		if(e.getSource() == mMar){
			mTimeFrame = Months.MAR;
		}
		
		if(e.getSource() == mApr){
			mTimeFrame = Months.APR;
		}
		
		if(e.getSource() == mMay){
			mTimeFrame = Months.MAY;
		}
		
		if(e.getSource() == mJun){
			mTimeFrame = Months.JUN;
		}
		
		if(e.getSource() == mJul){
			mTimeFrame = Months.JUL;
		}
		
		if(e.getSource() == mAug){
			mTimeFrame = Months.AUG;
		}
		
		if(e.getSource() == mSep){
			mTimeFrame = Months.SEP;
		}
		
		if(e.getSource() == mOct){
			mTimeFrame = Months.OCT;
		}
		
		if(e.getSource() == mNov){
			mTimeFrame = Months.NOV;
		}
		
		if(e.getSource() == mDec){
			mTimeFrame = Months.DEC;
		}
		
		if(e.getSource() == mYear){
			mTimeFrame = Months.YEAR;
		}
		
		if(e.getSource() == mOkButton){
			
		}
		
	}
}
