Package clips.doctor.disease.search

Source Code of clips.doctor.disease.search.PanelDiseaseSearch

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

/*
* PanelDiseaseSearch.java
*
* Created on 08.05.2009, 11:41:49
*/

package clips.doctor.disease.search;

import beans.service.search.DiseaseChunk;
import beans.service.search.SerRenSearchBean;
import beans.service.search.SerRenSearchBeanRemote;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.SharedBean;
import cli_fmw.main.ClipsException;
import cli_fmw.main.PageContainer;
import cli_fmw.main.Printable;
import cli_fmw.main.PageGeneric;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import clips.delegate.client.ClientLocal;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import clips.delegate.doctor.DiseaseLocal;
import clips.doctor.PanelEMC;
import framework.utils.DateTimeUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.Set;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.infotechservice.ICalendar.DateEvent;
import org.infotechservice.ICalendar.DateListener;

/**
*
* @author vip
*/
public class PanelDiseaseSearch extends PageGeneric implements Printable {

    private Date dateFrom, dateTill;
    private ArrayList<DiseaseChunk> diseaseList;
    private SharedBean<SerRenSearchBeanRemote> bean =
        new SharedBean<SerRenSearchBeanRemote>(SerRenSearchBean.class.getSimpleName());

    /** Creates new form PanelDiseaseSearch
     * @param container
     * @throws ClipsException
     */
    public PanelDiseaseSearch(PageContainer container) throws ClipsException {
        super(container);
        initComponents();
        panelCollaboratorSelect1.setWithNull(true);

        dateChooserFrom.addDateListener(new DateListener() {

            @Override
            public void dateChanged(DateEvent evt) {
                dateFrom = dateChooserFrom.getDate();
            }
        });

        dateChooserTill.addDateListener(new DateListener() {

            @Override
            public void dateChanged(DateEvent evt) {
                dateTill = dateChooserTill.getDate();
            }
           
        });

        tabSerRens.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                btSelect.setEnabled(tabSerRens.getSelectedRowSorted() > -1);
            }
        });
        tabSerRens.setModel(new TableModelDiseaseList(null));

        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        panelCollaboratorSelect1 = new clips.accountant.PanelCollaboratorSelect();
        jPanel6 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        dateChooserFrom = new org.infotechservice.ICalendar.components.ICDateChooser();
        jLabel5 = new javax.swing.JLabel();
        dateChooserTill = new org.infotechservice.ICalendar.components.ICDateChooser();
        jPanel7 = new javax.swing.JPanel();
        btSearch = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabSerRens = new cli_fmw.utils.sorted_table.SortedTable();
        jPanel2 = new javax.swing.JPanel();
        btSelect = new javax.swing.JButton();

        jPanel1.setPreferredSize(new java.awt.Dimension(648, 300));

        jPanel3.setLayout(new java.awt.BorderLayout());

        jLabel1.setText("Поиск не закрытых заболеваний");
        jPanel3.add(jLabel1, java.awt.BorderLayout.CENTER);

        jLabel6.setText("Сотрудник: ");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelCollaboratorSelect1, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
            .addComponent(panelCollaboratorSelect1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

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

        jLabel4.setText("Даты посещений: с  ");
        jPanel6.add(jLabel4);

        dateChooserFrom.setPreferredSize(new java.awt.Dimension(130, 27));
        jPanel6.add(dateChooserFrom);

        jLabel5.setText("  по:  ");
        jPanel6.add(jLabel5);

        dateChooserTill.setPreferredSize(new java.awt.Dimension(130, 27));
        jPanel6.add(dateChooserTill);

        btSearch.setText("Поиск");
        btSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(btSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(405, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(btSearch)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(21, 21, 21))
        );

        tabSerRens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tabSerRens.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabSerRensMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tabSerRens);

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

        btSelect.setText("Перейти в ЭМК");
        btSelect.setEnabled(false);
        btSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSelectActionPerformed(evt);
            }
        });
        jPanel2.add(btSelect);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.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, 497, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSearchActionPerformed
        try {
            DirectoryCollaboratorItem collab = panelCollaboratorSelect1.getSelectedItem();
            int collabID;
            if (collab == null || collab.isNullItem()) {
                collabID = 0;
            } else {
                collabID = collab.getID();
            }
            dateFrom = DateTimeUtils.getDateOnly(dateFrom);
            dateTill = DateTimeUtils.getNextDay(DateTimeUtils.getDateOnly(dateTill));

            Set<DiseaseChunk> openedDiseases = bean.get().getOpenedDiseases(collabID, dateFrom, dateTill);
            diseaseList = new ArrayList<DiseaseChunk>(openedDiseases);
            tabSerRens.setModel(new TableModelDiseaseList(diseaseList));
        } catch (Exception ex) {
            bean.clear();
            MessageBox.showException(ex);
        }
}//GEN-LAST:event_btSearchActionPerformed

    private void btSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSelectActionPerformed
        try {
            int row = tabSerRens.getSelectedRowSorted();
            DiseaseChunk dc = diseaseList.get(row);
            ClientLocal client = new ClientLocal(dc.clientID, getAuditManager());
            DiseaseLocal disease = new DiseaseLocal(dc.details.id, getAuditManager());
            PanelEMC panel = new PanelEMC(getContainer(), client);
            getContainer().addNewPage(panel, this);
            panel.selectInEmc(disease);
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
}//GEN-LAST:event_btSelectActionPerformed

    private void tabSerRensMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabSerRensMouseClicked
        try {
            if (evt.getClickCount() == 2) {
                int row = tabSerRens.getSelectedRowSorted();
                if (row >=0 && row < diseaseList.size()) {
                    DiseaseChunk dc = diseaseList.get(row);
                    ClientLocal client = new ClientLocal(dc.clientID, getAuditManager());
                    DiseaseLocal disease = new DiseaseLocal(dc.details.id, getAuditManager());
                    PanelEMC panel = new PanelEMC(getContainer(), client);
                    getContainer().addNewPage(panel, this);
                    panel.selectInEmc(disease);

                }
            }
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_tabSerRensMouseClicked

    @Override
    public String getPageTitle() {
        return "Поиск не закрытых заболеваний";
    }

    @Override
    public DelegateLine2 getDelegate() {
        return null;
    }

    @Override
    public boolean readyForPrint() {
        return false;
    }

    @Override
    public void print() {
        throw new UnsupportedOperationException("Not supported yet.");
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btSearch;
    private javax.swing.JButton btSelect;
    private org.infotechservice.ICalendar.components.ICDateChooser dateChooserFrom;
    private org.infotechservice.ICalendar.components.ICDateChooser dateChooserTill;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private clips.accountant.PanelCollaboratorSelect panelCollaboratorSelect1;
    private cli_fmw.utils.sorted_table.SortedTable tabSerRens;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of clips.doctor.disease.search.PanelDiseaseSearch

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.