Package clips.doctor.sicklist.clientSicklist

Source Code of clips.doctor.sicklist.clientSicklist.PanelSicklistList

/*
* PanelSicklist.java
*
* Created on 28 Март 2008 г., 18:21
*/

package clips.doctor.sicklist.clientSicklist;

import clips.delegate.doctor.sicklist.SicklistLocal;
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.report.TableReportOptions;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import clips.doctor.newEMC.wrappers.collectors.SicklistCollector;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import javax.swing.ListSelectionModel;

/**
*
* @author  vip
*/
public class PanelSicklistList extends PageGeneric implements Printable {
    private SicklistCollector collector;

//    public PanelSicklistList(PageContainer container, List<SicklistLocal> sicklistList) throws ClipsException {
//        super(container);
//        initComponents();
//        reloadTable();
//    resizeColumn();
//    StateSaver.attachTo(this);
//    }

    public PanelSicklistList(PageContainer container, SicklistCollector sc) throws ClipsException {
//        this(container, sc.getChildren());
        super(container);
        collector = sc;
        initComponents();
        reloadTable();
    resizeColumn();
    StateSaver.attachTo(this);
    }

   
    private void reloadTable() throws ClipsException {
        //Анонимный класс, расширяющий модель таблицы, просто запрещает редактирование
        jTable.setModel(new TableModelSicklist(collector.getChildren()) {
           
            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
           
        });
        jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
   
    /** 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) {
                try {
                    SicklistLocal sl = collector.getChildren().get(row);
                    if (getContainer() instanceof PanelEMC) {
                        ((PanelEMC) getContainer()).selectInEmc(sl);
                    }
                } 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 "Больничные листы";
    }

    public String getPageIcon() {
        return null;
    }

    private void resizeColumn() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelSicklist.COL_COLLABORATOR,    18);
    state.setPreferredWidth(TableModelSicklist.COL_CLIENT,        18);
    state.setPreferredWidth(TableModelSicklist.COL_SERIAL,        12);
    state.setPreferredWidth(TableModelSicklist.COL_DATEOPEN,            8);
    state.setPreferredWidth(TableModelSicklist.COL_DIAGNOSIS,    35);
    state.setPreferredWidth(TableModelSicklist.COL_CLOSED,        7);
      StateSaver.setDefaultState(this, jTable, state);
    }

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

    @Override
    public void print() {
        if (readyForPrint()) {
            HashMap<String, Object> data = new LinkedHashMap<String, Object>();
            String title = "Список больничных листов пациента";
            data.put("client", "Пациент: " + collector != null ? collector.getClientLocal().toString() : "неизвестно");
            TableReportOptions ops = new TableReportOptions(TableReportOptions.PageOrentation.horizontal);
            PrintCreators.createGeneratedReport(title, ops, data.entrySet(), null, jTable.getModel(), getClass());
        }
    }

    @Override
    public DelegateLine2 getDelegate() {
        return collector != null ? collector.getClientLocal() : null;
    }
   
}
TOP

Related Classes of clips.doctor.sicklist.clientSicklist.PanelSicklistList

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.