Package clips.kek.committee

Source Code of clips.kek.committee.PanelCommitteeSearch

/*
* PanelComitteeSearch.java
*
* Created on 29 Апрель 2008 г., 14:44
*/

package clips.kek.committee;

import clips.delegate.client.ClientLocal;
import cli_fmw.delegate.DelegateLine2;
import clips.kek.*;
import cli_fmw.main.ClipsException;
import cli_fmw.main.MainWindow;
import clips.delegate.kek.CommitteeFactoryLocal;
import clips.delegate.kek.CommitteeLocal;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageException;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.PrintCreators;
import cli_fmw.main.Printable;
import clips.userseach.PanelUserSearch;
import cli_fmw.utils.EmptyDialog;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import framework.utils.Converter;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.infotechservice.ICalendar.DateEvent;
import org.infotechservice.ICalendar.DateListener;

/**
* панель поиска заседаний комиссии по дате, а также создания новой комиссии
* @author  lacoste
*/
public class PanelCommitteeSearch extends PageGeneric implements Printable {
   
    private Date dateFrom, dateTill;
    private List<CommitteeLocal> comList = new ArrayList<CommitteeLocal>();
    private CommitteeFactoryLocal factory;
    private ClientLocal client = null;
   
    /** Creates new form PanelComitteeSearch */
    public PanelCommitteeSearch(PageContainer container) throws ClipsException {
        super(container);
        initComponents();
       
        factory = new CommitteeFactoryLocal(getAuditManager());
       
        tabComitteeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        dateTill = new Date();

        Calendar cal = new GregorianCalendar();
        cal.setTime(dateTill);
        cal.add(Calendar.MONTH, -1);

        dateFrom = cal.getTime();

       
        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();
            }
        });
    resizeColumn();
    StateSaver.attachTo(this);
    }

  private void resizeColumn() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelCommitteeList.COL_DATE,    2);
    state.setPreferredWidth(TableModelCommitteeList.COL_MEMBERS,  8);
      StateSaver.setDefaultState(this, tabComitteeList, state);
    }


    /** 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();
        dateChooserFrom = new org.infotechservice.ICalendar.components.ICDateChooser();
        jLabel2 = new javax.swing.JLabel();
        dateChooserTill = new org.infotechservice.ICalendar.components.ICDateChooser();
        jPanel2 = new javax.swing.JPanel();
        btFind = new javax.swing.JButton();
        btNew = new javax.swing.JButton();
        btDel = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabComitteeList = new cli_fmw.utils.sorted_table.SortedTable();
        jPanel3 = new javax.swing.JPanel();
        btOpenCommittee = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        cbClient = new javax.swing.JCheckBox();
        tfClient = new javax.swing.JTextField();
        btClient = new javax.swing.JButton();

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

        jLabel1.setText("Найти комиссии с:");
        jPanel1.add(jLabel1);

        dateChooserFrom.setPreferredSize(new java.awt.Dimension(120, 27));
        jPanel1.add(dateChooserFrom);

        jLabel2.setText("по:");
        jPanel1.add(jLabel2);

        dateChooserTill.setPreferredSize(new java.awt.Dimension(120, 27));
        jPanel1.add(dateChooserTill);

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

        btFind.setText("Поиск");
        btFind.setPreferredSize(new java.awt.Dimension(90, 29));
        btFind.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFindActionPerformed(evt);
            }
        });
        jPanel2.add(btFind);

        btNew.setText("Создать");
        btNew.setPreferredSize(new java.awt.Dimension(90, 29));
        btNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNewActionPerformed(evt);
            }
        });
        jPanel2.add(btNew);

        btDel.setText("Удалить");
        btDel.setPreferredSize(new java.awt.Dimension(90, 29));
        btDel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDelActionPerformed(evt);
            }
        });
        jPanel2.add(btDel);

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

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

        btOpenCommittee.setText("Открыть");
        btOpenCommittee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOpenCommitteeActionPerformed(evt);
            }
        });
        jPanel3.add(btOpenCommittee);

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

        cbClient.setText("по пациенту:  ");
        cbClient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbClientActionPerformed(evt);
            }
        });
        jPanel4.add(cbClient, java.awt.BorderLayout.LINE_START);

        tfClient.setColumns(40);
        jPanel4.add(tfClient, java.awt.BorderLayout.CENTER);

        btClient.setText("...");
        btClient.setEnabled(false);
        btClient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btClientActionPerformed(evt);
            }
        });
        jPanel4.add(btClient, java.awt.BorderLayout.LINE_END);

        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, 640, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 640, 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.UNRELATED)
                .addComponent(jPanel4, 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(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btFindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFindActionPerformed
        try {
            comList = factory.findComitteeList(dateFrom, dateTill, client);
            for (int i = 0; i < comList.size(); i++) {
                CommitteeLocal comLocal = comList.get(i);
                comLocal.addContentStateListener(getContainer());           
            }
            tabComitteeList.setModel(new TableModelCommitteeList(comList));

        } catch (ClipsException e) {
            MessageBox.showException(e);
        }
}//GEN-LAST:event_btFindActionPerformed

    private void btOpenCommitteeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOpenCommitteeActionPerformed
        if (comList == null || tabComitteeList.getSelectedRowCount() == 0) {
            MessageBox.showWarning(MessageBox.W_LIST_ELEMENT_NOT_SELECT);
            return;
        }
        try {
            CommitteeLocal comLocal = comList.get(tabComitteeList.getSelectedRowSorted());                       
            PanelEditCommittee panel = new PanelEditCommittee(getContainer(), comLocal);
            PageGeneric page = getContainer().addNewPage(panel, this);
            getContainer().activatePage(page);
        } catch (PageException ex) {
            MessageBox.showException(ex);
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btOpenCommitteeActionPerformed

    private void btNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNewActionPerformed
        try {
            CommitteeLocal comLocal = new CommitteeLocal(getAuditManager());
            comLocal.addContentStateListener(getContainer());           
           
            PanelEditCommittee panel = new PanelEditCommittee(getContainer(),comLocal);
            PageGeneric page = getContainer().addNewPage(panel, null);
            getContainer().activatePage(page);
        } catch (PageException ex) {
            MessageBox.showException(ex);
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btNewActionPerformed

private void btDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDelActionPerformed
    try {
        int row = tabComitteeList.getSelectedRowSorted();
        if (row < 0) {
            return;
        }
        CommitteeLocal committee = comList.get(row);
       
        committee.remove();
        comList.remove(committee);
       
        tabComitteeList.updateUI();
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btDelActionPerformed

private void cbClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbClientActionPerformed
    try {
        if (cbClient.isSelected()) {
            EmptyDialog dlg = new EmptyDialog(MainWindow.mainWindow, "Выбор пациента", getAuditManager());
            PanelUserSearch panel = new PanelUserSearch(dlg, PanelUserSearch.MODE_SELECT);
            dlg.addNewPage(panel, null);
            dlg.setVisible(true);
            if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
                client = panel.getSelectedClient();
                tfClient.setText(client.toString());
                btClient.setEnabled(true);
            }
            else {
                client = null;
                tfClient.setText("");
                btClient.setEnabled(false);
                cbClient.setSelected(false);
            }
        }
        else {
            client = null;
            tfClient.setText("");
            btClient.setEnabled(false);
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_cbClientActionPerformed

private void btClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btClientActionPerformed
    try {
        EmptyDialog dlg = new EmptyDialog(MainWindow.mainWindow, "Выбор пациента", getAuditManager());
        PanelUserSearch panel = new PanelUserSearch(dlg, PanelUserSearch.MODE_SELECT);
        dlg.addNewPage(panel, null);
        dlg.setVisible(true);
        if (dlg.getDlgResult() == ModalDialog.DLG_OK) {
            client = panel.getSelectedClient();
            tfClient.setText(client.toString());
            btClient.setEnabled(true);
        }
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btClientActionPerformed

private void tabComitteeListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabComitteeListMouseClicked
        if (evt.getClickCount() == 2 && tabComitteeList.getSelectedRowCount() > 0) {
            btOpenCommitteeActionPerformed(null);
        }
}//GEN-LAST:event_tabComitteeListMouseClicked
   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btClient;
    private javax.swing.JButton btDel;
    private javax.swing.JButton btFind;
    private javax.swing.JButton btNew;
    private javax.swing.JButton btOpenCommittee;
    private javax.swing.JCheckBox cbClient;
    private org.infotechservice.ICalendar.components.ICDateChooser dateChooserFrom;
    private org.infotechservice.ICalendar.components.ICDateChooser dateChooserTill;
    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 jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable tabComitteeList;
    private javax.swing.JTextField tfClient;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Поиск комиссий";
    }

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

    @Override
    public void print() {
        if (readyForPrint()) {
            //производим поиск чтоб результаты соответствовали фильтру
            btFindActionPerformed(null);
           
            HashMap<String, Object> data = new LinkedHashMap<String, Object>();
            data.put("date", "Дата с: " + Converter.dateToString(dateFrom) +
                    "   по: " + Converter.dateToString(dateTill));
            if (client != null) {
                data.put("client", "пациент: " + client.toString());
            }
            String title = "Список комиссий по фильтру";
            PrintCreators.createGeneratedReport(title, null, data.entrySet(), null, tabComitteeList.getModel(), getClass());
        }
    }

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

Related Classes of clips.kek.committee.PanelCommitteeSearch

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.