Package clips.kek.resolution

Source Code of clips.kek.resolution.ComResDlg

/*
* ComResDlg.java
*
* Created on 25 Апрель 2008 г., 14:54
*/

package clips.kek.resolution;

import cli_fmw.delegate.directory.DirectoryItem;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.utils.SelectorEditableExceptional;
import clips.delegate.directory.complex.DirectoryMKB10Item;
import cli_fmw.main.ClipsException;
import cli_fmw.main.ContentStateListener;
import cli_fmw.main.audit.AuditManager;
import clips.delegate.directory.simple.committeeResolution.DirectoryCommitteeResolutionItem;
import clips.delegate.kek.CommitteeResolutionData;
import clips.directory.dialogs.mkb10.DirectoryDialogMKB10;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.Selector;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import clips.delegate.directory.complex.DirectoryMKB10;
import clips.delegate.directory.simple.committeeResolution.DirectoryCommitteeResolution;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.text.ParseException;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;

/**
*панель вынесения решения по какому-то направлению
* @author  lacoste
*/
public class ComResDlg extends ModalDialog {
   
    private CommitteeResolutionData comResLocal;    //делегат - решение комиссии
    private DirectoryMKB10 dirMkb;
   
    /** Creates new form ComResDlg */
    public ComResDlg(Window parent, CommitteeResolutionData comResLocally, AuditManager am) throws ClipsException {
        super(parent, "Ввод решения комиссии",am);
        initComponents();
        this.comResLocal = comResLocally;

        panelSelColl.addContentStateListener(new ContentStateListener() {

            @Override
            public void contentStateChanged() {
                    comResLocal.setCollaborator(panelSelColl.getSelectedItem());
            }
        });

        //заполняем комбобокс
        DirectoryCommitteeResolution directory = DirectoryLocator.getDirectory(DirectoryCommitteeResolution.class);
        SelectorEditableExceptional<DirectoryCommitteeResolutionItem> items = directory.getItems();

        for (int i = 0; i < items.size(); i++) {
                cbResTypes.addItem(items.get(i));
        }

        //слушатель для комбобокса типов решения
        cbResTypes.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (((DirectoryItem)cbResTypes.getSelectedItem()).getID() == 0) {
                    btOK.setEnabled(false);
                }
                else {
                    try {
                        comResLocal.setType( (DirectoryCommitteeResolutionItem) cbResTypes.getSelectedItem());
                        btOK.setEnabled(true);
                    } catch (ClipsException ex) {
                        MessageBox.showException(ex);
                    }
                }
            }
        });                     

        cbResTypes.setSelectedItem(comResLocal.getType());

        //слушатель для ComRes.description
        taResDesc.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void insertUpdate(DocumentEvent arg0) {
                setField(arg0.getDocument());
            }

            @Override
            public void removeUpdate(DocumentEvent arg0) {
                setField(arg0.getDocument());
            }

            @Override
            public void changedUpdate(DocumentEvent arg0) {
            }

            private void setField(Document doc) {
                try {
                    comResLocal.setDescription(doc.getText(0, doc.getLength()));
                } catch (ClipsException ex) {
                    MessageBox.showException(ex);
                } catch (BadLocationException ex) {
                    MessageBox.showException(ex);
                }
            }
        });

        pmkbDiagnosis.addContentStateListener(new ContentStateListener() {

            @Override
            public void contentStateChanged() {
                comResLocal.setMkb(pmkbDiagnosis.getSelectedItem());
            }
        });

        taResDesc.setText(comResLocal.getDescription());
       
        //center dialog       
        Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle dlgSize = this.getBounds();               
        this.setLocation((scrSize.width - dlgSize.width) / 2, (scrSize.height - dlgSize.height) / 2);
        dirMkb = DirectoryLocator.getDirectory(DirectoryMKB10.class);
        setEnableComp();
    StateSaver.attachTo(this);
    }
       
    private void setEnableComp() throws ClipsException {
        boolean b = !comResLocal.isRendered();
        cbResTypes.setEnabled(b);
        panelSelColl.setEnabled(b);
        taResDesc.setEditable(b);
        pmkbDiagnosis.setEnabled(b);
    }
   
    public CommitteeResolutionData getComRes() {
        return comResLocal;
    }
   
    /** 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();
        jLabel1 = new javax.swing.JLabel();
        cbResTypes = new javax.swing.JComboBox();
        jPanel4 = new javax.swing.JPanel();
        btOK = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        pmkbDiagnosis = new clips.doctor.diagnosis.PanelMkbInput();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taResDesc = new javax.swing.JTextArea();
        jPanel3 = new javax.swing.JPanel();
        panelSelColl = new clips.accountant.PanelCollaboratorSelect();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 0));

        jLabel1.setText("Выберите тип решения КЭК: ");
        jPanel1.add(jLabel1);

        jPanel1.add(cbResTypes);

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

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

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(338, Short.MAX_VALUE)
                .addComponent(btOK, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btCancel))
        );

        jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btCancel, btOK});

        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btCancel)
                .addComponent(btOK))
        );

        jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btCancel, btOK});

        jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
        jPanel2.setLayout(new java.awt.BorderLayout(5, 5));
        jPanel2.add(pmkbDiagnosis, java.awt.BorderLayout.CENTER);

        jLabel3.setText("Диагноз:");
        jPanel2.add(jLabel3, java.awt.BorderLayout.WEST);

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Примечание:"));

        taResDesc.setColumns(20);
        taResDesc.setLineWrap(true);
        taResDesc.setRows(5);
        jScrollPane1.setViewportView(taResDesc);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelSelColl, javax.swing.GroupLayout.PREFERRED_SIZE, 302, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelSelColl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, 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)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

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

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

    private void btOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOKActionPerformed
        setDlgResult(ModalDialog.DLG_OK);
        dispose();
    }//GEN-LAST:event_btOKActionPerformed
      
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOK;
    private javax.swing.JComboBox cbResTypes;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private clips.accountant.PanelCollaboratorSelect panelSelColl;
    private clips.doctor.diagnosis.PanelMkbInput pmkbDiagnosis;
    private javax.swing.JTextArea taResDesc;
    // End of variables declaration//GEN-END:variables
   
}
TOP

Related Classes of clips.kek.resolution.ComResDlg

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.