Package clips.doctor.checkup.viewAnalyseList

Source Code of clips.doctor.checkup.viewAnalyseList.PanelAnalyseList

/*
* PanelCertificateList.java
*
* Created on 1 Апрель 2008 г., 12:02
*/

package clips.doctor.checkup.viewAnalyseList;

import clips.delegate.client.ClientLocal;
import clips.delegate.doctor.checkup.CheckupFactoryLocal;
import clips.delegate.doctor.checkup.CheckupLocal;
import cli_fmw.delegate.DelegateLine2;
import clips.doctor.PanelEMC;
import cli_fmw.main.ClipsException;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.PrintCreators;
import cli_fmw.main.Printable;
import cli_fmw.main.PageGeneric;
import cli_fmw.report.FormReportCreator;
import cli_fmw.report.ReporterFactory;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import javax.swing.ListSelectionModel;

/**
* Панель отображающая список анализов данного пациента
* @author  vip
*/
public class PanelAnalyseList extends PageGeneric implements Printable {
    ClientLocal clientLocal;
    private ArrayList<CheckupLocal> checkupList;
    boolean isAnalysis;
    CheckupFactoryLocal cfl;
   
    /** Creates new form PanelCertificateList
     * @param container
     * @param clientLocal
     * @param isAnalysis
     * @throws ClipsException
     */
    public PanelAnalyseList(PageContainer container, ClientLocal clientLocal, boolean isAnalysis) throws ClipsException {
        super(container);
        initComponents();
        this.clientLocal = clientLocal;
        this.isAnalysis = isAnalysis;
        cfl = new CheckupFactoryLocal(getAuditManager());
        reloadTable();
    resizeColumn();
    StateSaver.attachTo(this);
    }

    public PanelAnalyseList(PageContainer container, ClientLocal clientLocal) throws ClipsException {
        this(container, clientLocal, true);
    }



    private void reloadTable() throws ClipsException {
        if (isAnalysis) {
            checkupList = cfl.getAnalyseList(clientLocal);
        } else {
            checkupList = cfl.getCheckupList(clientLocal);
        }
        jTable.setModel(new TableModelAnalyseList(checkupList));
        jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    private void resizeColumn() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelAnalyseList.COL_DATE,      10);
    state.setPreferredWidth(TableModelAnalyseList.COL_DIRECTOR,    20);
    state.setPreferredWidth(TableModelAnalyseList.COL_RENDERER,    20);
    state.setPreferredWidth(TableModelAnalyseList.COL_TYPE,      20);
      StateSaver.setDefaultState(this, jTable, 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() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable = new cli_fmw.utils.sorted_table.SortedTable();

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

        jScrollPane1.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jScrollPane1ComponentResized(evt);
            }
        });

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

        add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

private void jTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMouseClicked
        if (evt.getClickCount() == 2) {
            int row = jTable.getSelectedRowSorted();
                if (row >=0 ) {
                CheckupLocal ch = checkupList.get(row);
                if (getContainer() instanceof PanelEMC) {
                    try {
                        ((PanelEMC) getContainer()).selectInEmc(ch);
                    } catch (ClipsException ex) {
                        ex.printStackTrace();
                        MessageBox.showException(ex);
                    }
                }
            }
        }
}//GEN-LAST:event_jTableMouseClicked

private void jScrollPane1ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jScrollPane1ComponentResized
}//GEN-LAST:event_jScrollPane1ComponentResized
   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable jTable;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Список анализов";
    }

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

    @Override
    public void print() {
        if (readyForPrint()) {
            HashMap<String, Object> data = new LinkedHashMap<String, Object>();
            String title = "Список " + (isAnalysis ? "анализов" : "осмотров") + " пациента";
            data.put("client", "Пациент: " + clientLocal.toString());
            PrintCreators.createGeneratedReport(title, null, data.entrySet(), null, jTable.getModel(), getClass());
        }
    }

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

Related Classes of clips.doctor.checkup.viewAnalyseList.PanelAnalyseList

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.