Package clips.doctor

Source Code of clips.doctor.PanelAnamnesInfo

/*
* PanelAnamnesInfo.java
*
* Created on 18 Декабрь 2007 г., 19:59
*/

package clips.doctor;

import cli_fmw.delegate.DelegateLine2;
import cli_fmw.main.ClipsException;
import cli_fmw.main.PageContainer;
import clips.delegate.doctor.EmcLocal;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Persistentable;
import cli_fmw.main.Printable;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.CombinedReportOptions;
import cli_fmw.report.PageOptions.PageOrentation;
import cli_fmw.report.ReporterFactory;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;

/**
*
* @author  Администратор
*/
public class PanelAnamnesInfo extends PageGeneric implements Persistentable, Printable
{
    private EmcLocal emcLocal;
   
    /** Creates new form PanelAnamnesInfo */
    public PanelAnamnesInfo(PageContainer container, EmcLocal myEmcLocal) throws ClipsException {
        super(container);
        initComponents();
        setEnableComponents();
        this.emcLocal = myEmcLocal;
        editAnamnes.setText(myEmcLocal.getLifeAnamnez());
        editAnamnes.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void insertUpdate(DocumentEvent arg0) {
                setText(arg0);
            }

            @Override
            public void removeUpdate(DocumentEvent arg0) {
                setText(arg0);
            }

            @Override
            public void changedUpdate(DocumentEvent arg0) {
                setText(arg0);
            }
            private void setText(DocumentEvent docEvent) {
                try {
                    emcLocal.setLifeAnamnez(docEvent.getDocument().getText(0, docEvent.getDocument().getLength()));
                } catch (BadLocationException ex) {
                    MessageBox.showException(ex);
                } catch (ClipsException ex) {
                    MessageBox.showException(ex);
                }
            }
        });

        String emc = emcLocal.getClient().getNumberEmc();
        if (emc == null) {
            emc = "";
        }
        jLabel1.setText("Номер ЭМК: " + emc);
    StateSaver.attachTo(this);
    }

    /**
     * в зависимости от режима (editing) выставляет доступность компонентов страницы
     */
    private void setEnableComponents() {
    }
   
    /** 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();
        editAnamnes = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        setLayout(new java.awt.BorderLayout());

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Анамнез"));

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

        add(jScrollPane1, java.awt.BorderLayout.CENTER);

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

        jLabel1.setText("Номер ЭМК:");
        jPanel1.add(jLabel1);

        add(jPanel1, java.awt.BorderLayout.PAGE_START);
    }// </editor-fold>//GEN-END:initComponents
   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea editAnamnes;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Анамнез";
    }

    @Override
    public boolean isDirty() {
        return emcLocal.isDirty();
    }

    @Override
    public void save() throws ClipsException {
        emcLocal.save1();
    }

    @Override
    public void restore() {
        if (emcLocal.isDirty()) {
            emcLocal.restore();
            try {
                editAnamnes.setText(emcLocal.getLifeAnamnez());
            } catch(ClipsException ex) {
                //do nothing
                ex.printStackTrace();
            }
        }
    }

    @Override
    public boolean readyForPrint() {
        return !isDirty();
    }

    @Override
    public void print() {
        try {
            if (readyForPrint()) {
                CombinedReportCreator parCreator = ReporterFactory.createCombinedReporter(getClass(), 1);
                CombinedReportOptions ops = new CombinedReportOptions();
                ops.topMargin =0;
                ops.bottomMargin = 0;
                ops.leftMargin =0;
                ops.rightMargin = 0;
                ops.setPageA5();
                ops.setOrentation(PageOrentation.horizontal);
                parCreator.setUpReport(null, ops, null);

                emcLocal.getClient().print(parCreator);
                parCreator.finish();
            }
        }catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }

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

Related Classes of clips.doctor.PanelAnamnesInfo

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.