Package clips.doctor.followup

Source Code of clips.doctor.followup.NewFollowUpEventDialog

/*
* NewFollowUpEventDialog.java
*
* Created on 25 Март 2008 г., 11:07
*/

package clips.doctor.followup;

import cli_fmw.delegate.utils.TimeLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.main.audit.AuditManager;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import framework.utils.PairIntStr;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;
import org.infotechservice.ICalendar.DateEvent;
import org.infotechservice.ICalendar.DateListener;

/**
*
* @author  lacoste
*/
public class NewFollowUpEventDialog extends ModalDialog {

    private Date date, dateNext;
    public static final int WEEK = 0;
    public static final int ONE_MONTH = 1;
    public static final int THREE_MONTHS = 2;
    public static final int SIX_MONTHS = 3;
    /** id шаблонного договора */
    public static final int TEMPLATE_CONTRACT_ID = 1;
    public static final PairIntStr [] TIMES_ARRAY = new PairIntStr [] {
        new PairIntStr(WEEK,        "через неделю"),
        new PairIntStr(ONE_MONTH,   "через месяц"),
        new PairIntStr(THREE_MONTHS, "через 3 месяца"),
        new PairIntStr(SIX_MONTHS,  "через полгода")
    };

    /** Creates new form NewFollowUpEventDialog */
    public NewFollowUpEventDialog(Window parent, AuditManager am) throws ClipsException {
        super(parent, "Назначение дня приема", am);
        initComponents();
        this.date = TimeLocal.getCurrentTime().getTime();
       
        dateChooserfuEvent.addDateListener(new DateListener() {

            @Override
            public void dateChanged(DateEvent event) {
                dateNext = event.getNewValue();
                btOk.setEnabled(dateNext != null && dateNext.after(date));
            }
        });

        cbPeriod.setModel(new DefaultComboBoxModel(TIMES_ARRAY));
        cbPeriod.setSelectedIndex(-1);

        cbPeriod.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                GregorianCalendar calendar = new GregorianCalendar();
                calendar.setTime(date);
                switch (cbPeriod.getSelectedIndex()) {
                    case WEEK:          calendar.add(GregorianCalendar.DAY_OF_MONTH, 7); break;
                    case ONE_MONTH:     calendar.add(GregorianCalendar.MONTH, 1); break;
                    case THREE_MONTHS:  calendar.add(GregorianCalendar.MONTH, 3); break;
                    case SIX_MONTHS:    calendar.add(GregorianCalendar.MONTH, 6); break;
                }
                dateNext = calendar.getTime();
                dateChooserfuEvent.setDate(dateNext);
                btOk.setEnabled(true);
            }
        });

    StateSaver.attachTo(this);
    }
   
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        cbPeriod = new javax.swing.JComboBox();
        dateChooserfuEvent = new org.infotechservice.ICalendar.components.ICDateChooser();
        jPanel2 = new javax.swing.JPanel();
        btOk = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Дата следующего приема"));
        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 15, 5));

        cbPeriod.setPreferredSize(new java.awt.Dimension(150, 23));
        jPanel1.add(cbPeriod);

        dateChooserfuEvent.setPreferredSize(new java.awt.Dimension(125, 23));
        jPanel1.add(dateChooserfuEvent);

        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        btOk.setText("Задать дату");
        btOk.setEnabled(false);
        btOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOkActionPerformed(evt);
            }
        });
        jPanel2.add(btOk);

        btCancel.setText("Отменить");
        btCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelActionPerformed(evt);
            }
        });
        jPanel2.add(btCancel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOkActionPerformed
        setDlgResult(DLG_OK);
        setVisible(false);       
    }//GEN-LAST:event_btOkActionPerformed

    private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
        setDlgResult(DLG_CANCEL);
        setVisible(false);
    }//GEN-LAST:event_btCancelActionPerformed

    public Date getNextDate() {
        return dateNext;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOk;
    private javax.swing.JComboBox cbPeriod;
    private org.infotechservice.ICalendar.components.ICDateChooser dateChooserfuEvent;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration//GEN-END:variables
   
}
TOP

Related Classes of clips.doctor.followup.NewFollowUpEventDialog

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.