Package clips.doctor.followup

Source Code of clips.doctor.followup.DialogFollowDown

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

/*
* DialogFollowupDown.java
*
* Created on 25.05.2009, 16:41:35
*/

package clips.doctor.followup;

import cli_fmw.delegate.directory.complex.DirectoryLocator;
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 clips.delegate.directory.simple.reasonDown.DirectoryReasonDown;
import clips.delegate.directory.simple.reasonDown.DirectoryReasonDownItem;
import clips.delegate.doctor.followup.FollowupLocal;
import clips.delegate.service.SerRenLocal;
import java.awt.Window;
import java.util.List;
import javax.swing.DefaultComboBoxModel;

/**
*
* @author petr
*/
public class DialogFollowDown extends ModalDialog {

    private SerRenLocal srl;
    private SerRenLocal lastSerren;
    private DirectoryReasonDownItem drdi;
    private List<SerRenLocal> serRenLocals;
    private static String noSerrensItem = "У пациента нет талона на текущую дату";

    public DialogFollowDown(Window parent, FollowupLocal followup, AuditManager am) throws ClipsException {
        super(parent, "Снятие пациента с диспансерного учёта", am);
        initComponents();
        serRenLocals = followup.getClient().getSerRenListByToday();
        if (serRenLocals.isEmpty()){
            cbSerren.setModel(new DefaultComboBoxModel(new String[] {noSerrensItem}));
            cbSerren.setEnabled(false);
            cbSerren.setSelectedItem(noSerrensItem);
        }else{
            DefaultComboBoxModel model = new DefaultComboBoxModel(serRenLocals.toArray());
            model.insertElementAt("Без посещения", 0);
            cbSerren.setModel(model);
        }
        //причина снятия
        DirectoryReasonDown directoryRD = DirectoryLocator.getDirectory(DirectoryReasonDown.class);
        cbReasonDown.setModel(new DefaultComboBoxModel(directoryRD.toArray()));
        cbReasonDown.setSelectedItem(directoryRD.getNullItem());
        btOK.setEnabled(false);

        this.pack();
        StateSaver.attachTo(this);
    }

    private void changeState() {
        drdi = (DirectoryReasonDownItem) cbReasonDown.getSelectedItem();
        btOK.setEnabled(drdi != null && drdi.getID() != 0);
    }

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

        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        pnlLeft = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        pnlRight = new javax.swing.JPanel();
        cbReasonDown = new javax.swing.JComboBox();
        cbSerren = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        btOK = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        jPanel3.setLayout(new java.awt.BorderLayout());

        pnlLeft.setLayout(new java.awt.GridLayout(0, 1, 5, 5));

        jLabel1.setText("Причина снятия:");
        pnlLeft.add(jLabel1);

        jLabel2.setText("Посещение");
        pnlLeft.add(jLabel2);

        pnlRight.setLayout(new java.awt.GridLayout(0, 1, 5, 5));

        cbReasonDown.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbReasonDown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbReasonDownActionPerformed(evt);
            }
        });
        pnlRight.add(cbReasonDown);

        cbSerren.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbSerren.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbSerrenActionPerformed(evt);
            }
        });
        pnlRight.add(cbSerren);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(pnlLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addComponent(pnlRight, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(pnlRight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {pnlLeft, pnlRight});

        jPanel3.add(jPanel1, java.awt.BorderLayout.NORTH);

        btOK.setText("Принять");
        btOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOKActionPerformed(evt);
            }
        });
        jPanel2.add(btOK);

        jButton2.setText("Отмена");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);

        jPanel3.add(jPanel2, java.awt.BorderLayout.SOUTH);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
        );

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

    private void btOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOKActionPerformed
        this.setDlgResult(ModalDialog.DLG_OK);
        this.dispose();
}//GEN-LAST:event_btOKActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        this.setDlgResult(ModalDialog.DLG_CANCEL);
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void cbSerrenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSerrenActionPerformed
        Object selectedItem = cbSerren.getSelectedItem();
        if (selectedItem != null && selectedItem instanceof SerRenLocal){
            srl = (SerRenLocal) selectedItem;
            lastSerren = srl;
        }else{
            srl = null;
        }

    }//GEN-LAST:event_cbSerrenActionPerformed



    private void cbReasonDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbReasonDownActionPerformed
        changeState();
    }//GEN-LAST:event_cbReasonDownActionPerformed

    public DirectoryReasonDownItem getReasonDown() {
        return drdi;
    }

    public SerRenLocal getSerRenLocal() {
        return srl;
    }



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btOK;
    private javax.swing.JComboBox cbReasonDown;
    private javax.swing.JComboBox cbSerren;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel pnlLeft;
    private javax.swing.JPanel pnlRight;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of clips.doctor.followup.DialogFollowDown

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.