/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * pnlDateTimePicker.java
 *
 * Created on Apr 21, 2010, 10:05:11 PM
 */

package uce.ui.components;

import com.toedter.calendar.JDateChooser;
import java.awt.LayoutManager;
import java.util.Calendar;
import uce.ui.components.jpnCondition.MyTime;

/**
 *
 * @author chepa
 */
public class pnlDateTimePicker extends javax.swing.JPanel {

    /** Creates new form pnlDateTimePicker */
    public pnlDateTimePicker() {
        initComponents();
		((JDateChooser)pnlDate).setCalendar(Calendar.getInstance());
    }

    /** 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() {

        jLabel1 = new javax.swing.JLabel();
        pnlDate = new JDateChooser();
        pnlTime = new pnlTimePicker();

        setName("Form"); // NOI18N

        jLabel1.setText("Date : "); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        pnlDate.setName("pnlDate"); // NOI18N
        LayoutManager manager = pnlDate.getLayout();
        pnlDate.setLayout(null);
        pnlDate.setLayout(manager);

        pnlTime.setName("pnlTime"); // NOI18N
        LayoutManager mgrPnlTime = pnlTime.getLayout();
        pnlTime.setLayout(null);
        pnlTime.setLayout(mgrPnlTime);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(2, 2, 2)
                .addComponent(pnlDate, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlTime, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1))
                    .addComponent(pnlDate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlTime, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel pnlDate;
    private javax.swing.JPanel pnlTime;
    // End of variables declaration//GEN-END:variables

	public Calendar getDateTime() {
		Calendar calendar = ((JDateChooser) pnlDate).getCalendar();
		MyTime time = ((pnlTimePicker) pnlTime).getTime();
		calendar.set(Calendar.HOUR, time.getHours());
		calendar.set(Calendar.MINUTE, time.getMins());
		calendar.set(Calendar.SECOND, time.getSecs());
		return calendar;
	}

	public void setDateTime(Calendar value) {
		((JDateChooser) pnlDate).setCalendar(value);
		((pnlTimePicker) pnlTime).setTime(new MyTime(value.get(Calendar.HOUR), value.get(Calendar.MINUTE), value.get(Calendar.SECOND)));
	}
}

