Package clips.administrator.lpu

Source Code of clips.administrator.lpu.PanelLpu$LpuTextModelSuEditable

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

/*
* LpuPanel.java
*
* Created on 22.01.2010, 16:45:48
*/

package clips.administrator.lpu;

import beans.UserRightsSet;
import beans.directory.lpu.entity.LpuDetails;
import cli_fmw.address.DialogAddressM;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.client.Address;
import cli_fmw.delegate.directory.DirectoryItemRO;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.main.ClipsException;
import cli_fmw.main.ContentStateListener;
import cli_fmw.main.OpenCloseSensitive;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageException;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Persistentable;
import cli_fmw.report.panels.model.FilteredComboBoxModel;
import cli_fmw.report.panels.model.ObjectContainer;
import cli_fmw.report.panels.model.delegate.DelegateTextModel;
import cli_fmw.report.panels.model.delegate.DirectoryComboBoxModel;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import clips.delegate.directory.ro.DirectoryLpu;
import clips.delegate.directory.ro.DirectoryLpuItem;
import clips.delegate.directory.simple.insurer.DirectoryInsurer;
import clips.delegate.directory.simple.insurer.DirectoryInsurerItem;
import clips.delegate.directory.simple.mes.DirectoryClinicType;
import clips.delegate.directory.simple.mes.DirectoryClinicTypeItem;
import clips.delegate.lpu.LpuLocal;
import clips.login.UserInfo;
import java.awt.Frame;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;

/**
*
* @author petr
*/
public class PanelLpu extends PageGeneric implements Persistentable, OpenCloseSensitive {

    private void initLpuCombo() throws ClipsException {
        lpuContModel = new DefaultComboBoxModel(DirectoryLocator.getDirectory(DirectoryLpu.class, true).toArray());
        FilteredComboBoxModel lpuModel = new FilteredComboBoxModel(cbLpu, false) {

            @Override
            public Object addItem(String txt) {
                return null;
            }

            @Override
            public void setSelectedItem(Object anItem) {
                super.setSelectedItem(anItem);
                setViewLpu((DirectoryLpuItem) anItem);
            }
        };
        lpuModel.setContainModel(lpuContModel);
        cbLpu.setEnabled(true);
    }

    abstract class LpuTextModelSuEditable extends DelegateTextModel<LpuLocal>{

        public LpuTextModelSuEditable(JTextField component, LpuLocal delegate) {
            super(component, delegate);
        }

        @Override
        protected boolean isEnabled() {
            getComponent().setEditable(canEditData());
            return super.isEnabled();
        }

    }

    private boolean canEditData() {
        try {
            if (UserInfo.get().check(UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY)) {
                System.out.println("true");
                return true;
            }
            if (UserInfo.get().check(UserRightsSet.WRITE_CLINIC_ADMIN_DIRECTORY)
                    && lpuLocal != null
                    && lpuLocal.getID() == UserInfo.get().getCollaborator().getLpu().getID()) {
                System.out.println("true");
                return true;
            }
            System.out.println("false");
            return false;
        } catch (ClipsException ex) {
            System.out.println("error - false");
            return false;
        }
    }

    private LpuLocal lpuLocal;
    private ArrayList<ObjectContainer> containers;
    private DefaultComboBoxModel lpuContModel;

    public PanelLpu(PageContainer container) throws ClipsException {
        super(container);
        initComponents();
        containers = new ArrayList<ObjectContainer>();

        pscChiefAccauntant.setWithNull(true);
        pscChiefDoctor.setWithNull(true);

        btCreate.setEnabled(UserInfo.get().check(UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY));
        initLpuCombo();

        DirectoryComboBoxModel<LpuLocal, DirectoryClinicTypeItem> clinType
                = new DirectoryComboBoxModel<LpuLocal, DirectoryClinicTypeItem>(cbLpuType,
                                                                                DirectoryLocator.getDirectory(DirectoryClinicType.class),
                                                                                lpuLocal) {

            @Override
            public DirectoryClinicTypeItem getSelectedDirectoryItem() throws ClipsException {
                return lpuLocal.getClinicType();
            }

            @Override
            public void setSelectedDirectoryItem(DirectoryClinicTypeItem item) throws ClipsException {
                lpuLocal.setClinicType(item);
            }

            @Override
            public boolean isEnabled() {
                return canEditData();
            }


        };

        DirectoryComboBoxModel<LpuLocal, DirectoryInsurerItem> insurer
                = new DirectoryComboBoxModel<LpuLocal, DirectoryInsurerItem>(cbInsurer,
                                                                                DirectoryLocator.getDirectory(DirectoryInsurer.class),
                                                                                lpuLocal) {

            @Override
            public DirectoryInsurerItem getSelectedDirectoryItem() throws ClipsException {
                return lpuLocal.getDefaultInsurer();
            }

            @Override
            public void setSelectedDirectoryItem(DirectoryInsurerItem item) throws ClipsException {
                lpuLocal.setDefaultInsurer(item);
            }

            @Override
            public boolean isEnabled() {
                return canEditData();
            }
        };

        LpuTextModelSuEditable address = new LpuTextModelSuEditable(tfAddress, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getAddress().toString();
            }

            @Override
            protected boolean isEnabled() {
                return true;
            }

        };

        LpuTextModelSuEditable postIndex = new LpuTextModelSuEditable(tfPostIndex, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
//                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
//                throw new UnsupportedOperationException("Not supported yet.");
                return getObject().getAddress().getPostIndex();
            }

            @Override
            protected boolean isEnabled() {
                return true;
            }

        };

        LpuTextModelSuEditable title = new LpuTextModelSuEditable(tfTitle, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setTitle(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getTitle();
            }
        };

        LpuTextModelSuEditable rfoms = new LpuTextModelSuEditable(tfRfoms, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setBranchCode(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getBranchCode();
            }
        };

        LpuTextModelSuEditable divisionCode = new LpuTextModelSuEditable(tfDivisionCode, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setLpuSubdivisionCode(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getLpuSubdivisionCode();
            }
        };

        LpuTextModelSuEditable email = new LpuTextModelSuEditable(tfEmail, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setEmail(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getEmail();
            }
        };
        LpuTextModelSuEditable fax = new LpuTextModelSuEditable(tfFax, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setFax(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getFax();
            }
        };
        LpuTextModelSuEditable ogrn = new LpuTextModelSuEditable(tfOgrn, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOgrn(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOgrn();
            }

        };
        LpuTextModelSuEditable okato = new LpuTextModelSuEditable(tfOkato, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {

            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkato();
            }

            @Override
            protected boolean isEnabled() {
                return true;
            }


        };
        LpuTextModelSuEditable okfs = new LpuTextModelSuEditable(tfOkfs, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOkfs(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkfs();
            }
        };
        LpuTextModelSuEditable okogu = new LpuTextModelSuEditable(tfOkogu, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOkogu(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkogu();
            }
        };
        LpuTextModelSuEditable okonh = new LpuTextModelSuEditable(tfOkonh, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOkonh(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkonh();
            }
        };
        LpuTextModelSuEditable okopf = new LpuTextModelSuEditable(tfOkopf, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOkopf(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkopf();
            }
        };
        LpuTextModelSuEditable okpo = new LpuTextModelSuEditable(tfOkpo, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOkpo(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkpo();
            }
        };
        LpuTextModelSuEditable okved = new LpuTextModelSuEditable(tfOkved, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setOkved(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getOkved();
            }
        };
        LpuTextModelSuEditable phone = new LpuTextModelSuEditable(tfPhone, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setPhone(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getPhone();
            }
        };
        LpuTextModelSuEditable code = new LpuTextModelSuEditable(tfCode, lpuLocal) {

            @Override
            protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
                getObject().setLpuCode(text);
            }

            @Override
            protected String getModelTextChecked() throws ClipsException {
                return getObject().getLpuCode();
            }
        };

        btAddress.setEnabled(canEditData());
        pscChiefDoctor.addContentStateListener(new ContentStateListener() {

            @Override
            public void contentStateChanged() {
                if (lpuLocal != null && pscChiefDoctor.getSelectedItem() != null){
                    try {
                        lpuLocal.setChiefDoctor(pscChiefDoctor.getSelectedItem());
                    } catch (ClipsException ex) {
                        MessageBox.showException(ex);
                    }
                }
            }
        });
        pscChiefAccauntant.addContentStateListener(new ContentStateListener() {

            @Override
            public void contentStateChanged() {
                if (lpuLocal != null && pscChiefAccauntant.getSelectedItem() != null){
                    try {
                        lpuLocal.setAccountant(pscChiefAccauntant.getSelectedItem());
                    } catch (ClipsException ex) {
                        MessageBox.showException(ex);
                    }
                }
            }
        });

        pscChiefAccauntant.setEnabled(canEditData());
        pscChiefDoctor.setEnabled(canEditData());

        containers.add(address);
        containers.add(code);
        containers.add(divisionCode);
        containers.add(email);
        containers.add(fax);
        containers.add(ogrn);
        containers.add(okato);
        containers.add(okfs);
        containers.add(okogu);
        containers.add(okonh);
        containers.add(okopf);
        containers.add(okpo);
        containers.add(okved);
        containers.add(phone);
        containers.add(postIndex);
        containers.add(clinType);
        containers.add(insurer);
        containers.add(title);
        containers.add(rfoms);

        setViewLpu(UserInfo.get().getCollaborator().getLpu());

        StateSaver.attachTo(this);
    }


    private void setViewLpu(DirectoryLpuItem item){
        setViewLpu(new LpuLocal(item.getDetails().clone(), getAuditManager()));
    }

    private void setViewLpu(LpuLocal lpuLocal){
        try {
            this.lpuLocal = lpuLocal;
            for (ObjectContainer container : containers) {
                container.setObject(lpuLocal);
            }
            lpuLocal.addContentStateListener(getContainer());
            pscChiefAccauntant.setSelectedCollaborator(lpuLocal.getAccountant());
            pscChiefDoctor.setSelectedCollaborator(lpuLocal.getChiefDoctor());
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }

    /** 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() {

        jScrollPane1 = new javax.swing.JScrollPane();
        main = new javax.swing.JPanel();
        center = new javax.swing.JPanel();
        center_north = new javax.swing.JPanel();
        center_north_west = new javax.swing.JPanel();
        lblTitle = new javax.swing.JLabel();
        lblClinicType = new javax.swing.JLabel();
        lblChiefDoctor = new javax.swing.JLabel();
        lblAccountant = new javax.swing.JLabel();
        lblinsurer = new javax.swing.JLabel();
        lblAddress = new javax.swing.JLabel();
        lblPostIndex = new javax.swing.JLabel();
        lblOkato = new javax.swing.JLabel();
        lblTfoms = new javax.swing.JLabel();
        lblRfoms = new javax.swing.JLabel();
        lblOgrn = new javax.swing.JLabel();
        lblPhone = new javax.swing.JLabel();
        lblFax = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        lblOkpo = new javax.swing.JLabel();
        lblOkonh = new javax.swing.JLabel();
        lblOkved = new javax.swing.JLabel();
        lblOkogu = new javax.swing.JLabel();
        lblOkopf = new javax.swing.JLabel();
        lblOkfc = new javax.swing.JLabel();
        lblDivisionCode = new javax.swing.JLabel();
        center_north_center = new javax.swing.JPanel();
        tfTitle = new javax.swing.JTextField();
        cbLpuType = new javax.swing.JComboBox();
        pscChiefDoctor = new clips.accountant.PanelCollaboratorSelect();
        pscChiefAccauntant = new clips.accountant.PanelCollaboratorSelect();
        cbInsurer = new javax.swing.JComboBox();
        pnlAddress = new javax.swing.JPanel();
        tfAddress = new javax.swing.JTextField();
        btAddress = new javax.swing.JButton();
        tfPostIndex = new javax.swing.JTextField();
        tfOkato = new javax.swing.JTextField();
        tfCode = new javax.swing.JTextField();
        tfRfoms = new javax.swing.JTextField();
        tfOgrn = new javax.swing.JTextField();
        tfPhone = new javax.swing.JTextField();
        tfFax = new javax.swing.JTextField();
        tfEmail = new javax.swing.JTextField();
        tfOkpo = new javax.swing.JTextField();
        tfOkonh = new javax.swing.JTextField();
        tfOkved = new javax.swing.JTextField();
        tfOkogu = new javax.swing.JTextField();
        tfOkopf = new javax.swing.JTextField();
        tfOkfs = new javax.swing.JTextField();
        tfDivisionCode = new javax.swing.JTextField();
        north = new javax.swing.JPanel();
        north_west = new javax.swing.JPanel();
        lblLpu = new javax.swing.JLabel();
        north_center = new javax.swing.JPanel();
        cbLpu = new javax.swing.JComboBox();
        south = new javax.swing.JPanel();
        btCreate = new javax.swing.JButton();

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

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

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

        center_north_west.setLayout(new java.awt.GridLayout(0, 1, 0, 2));

        lblTitle.setText("Название ЛПУ:");
        center_north_west.add(lblTitle);

        lblClinicType.setText("Тип ЛПУ:");
        center_north_west.add(lblClinicType);

        lblChiefDoctor.setText("Главный врач:");
        center_north_west.add(lblChiefDoctor);

        lblAccountant.setText("Главный бухгалтер:");
        center_north_west.add(lblAccountant);

        lblinsurer.setText("Страховая компания:");
        center_north_west.add(lblinsurer);

        lblAddress.setText("Адрес ЛПУ:");
        center_north_west.add(lblAddress);

        lblPostIndex.setText("Почтовый индекс Адреса ЛПУ:");
        center_north_west.add(lblPostIndex);

        lblOkato.setText("Код территории по ОКАТО:");
        center_north_west.add(lblOkato);

        lblTfoms.setText("Код ЛПУ в кодировке ТФОМС:");
        center_north_west.add(lblTfoms);

        lblRfoms.setText("Код филиала РФОМС:");
        center_north_west.add(lblRfoms);

        lblOgrn.setText("Код ЛПУ по ОГРН:");
        center_north_west.add(lblOgrn);

        lblPhone.setText("Телефон (с кодом города):");
        center_north_west.add(lblPhone);

        lblFax.setText("Факс (с кодом города):");
        center_north_west.add(lblFax);

        lblEmail.setText("Адрес электронной почты:");
        center_north_west.add(lblEmail);

        lblOkpo.setText("Код организации по ОКПО:");
        center_north_west.add(lblOkpo);

        lblOkonh.setText("Код отрасли по ОКОНХ:");
        center_north_west.add(lblOkonh);

        lblOkved.setText("Код вида деятельности по ОКВЭД:");
        center_north_west.add(lblOkved);

        lblOkogu.setText("Код органа управления по ОКОГУ:");
        center_north_west.add(lblOkogu);

        lblOkopf.setText("Код орг.-прав. формы по ОКОПФ:");
        center_north_west.add(lblOkopf);

        lblOkfc.setText("Код формы собственности поОКФС:");
        center_north_west.add(lblOkfc);

        lblDivisionCode.setText("Код подразделения ЛПУ:");
        center_north_west.add(lblDivisionCode);

        center_north.add(center_north_west, java.awt.BorderLayout.WEST);

        center_north_center.setLayout(new java.awt.GridLayout(0, 1, 0, 2));

        tfTitle.setText("jTextField1");
        center_north_center.add(tfTitle);

        cbLpuType.setEditable(true);
        cbLpuType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        center_north_center.add(cbLpuType);
        center_north_center.add(pscChiefDoctor);
        center_north_center.add(pscChiefAccauntant);

        cbInsurer.setEditable(true);
        cbInsurer.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        center_north_center.add(cbInsurer);

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

        tfAddress.setEditable(false);
        tfAddress.setText("jTextField1");
        pnlAddress.add(tfAddress, java.awt.BorderLayout.CENTER);

        btAddress.setText("...");
        btAddress.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddressActionPerformed(evt);
            }
        });
        pnlAddress.add(btAddress, java.awt.BorderLayout.EAST);

        center_north_center.add(pnlAddress);

        tfPostIndex.setEditable(false);
        tfPostIndex.setText("jTextField1");
        center_north_center.add(tfPostIndex);

        tfOkato.setEditable(false);
        tfOkato.setText("jTextField1");
        center_north_center.add(tfOkato);

        tfCode.setText("jTextField1");
        center_north_center.add(tfCode);

        tfRfoms.setText("jTextField1");
        center_north_center.add(tfRfoms);

        tfOgrn.setText("jTextField1");
        center_north_center.add(tfOgrn);

        tfPhone.setText("jTextField1");
        center_north_center.add(tfPhone);

        tfFax.setText("jTextField1");
        center_north_center.add(tfFax);

        tfEmail.setText("jTextField1");
        center_north_center.add(tfEmail);

        tfOkpo.setText("jTextField1");
        center_north_center.add(tfOkpo);

        tfOkonh.setText("jTextField1");
        center_north_center.add(tfOkonh);

        tfOkved.setText("jTextField1");
        center_north_center.add(tfOkved);

        tfOkogu.setText("jTextField1");
        center_north_center.add(tfOkogu);

        tfOkopf.setText("jTextField1");
        center_north_center.add(tfOkopf);

        tfOkfs.setText("jTextField1");
        center_north_center.add(tfOkfs);

        tfDivisionCode.setText("jTextField1");
        center_north_center.add(tfDivisionCode);

        center_north.add(center_north_center, java.awt.BorderLayout.CENTER);

        center.add(center_north, java.awt.BorderLayout.NORTH);

        main.add(center, java.awt.BorderLayout.CENTER);

        jScrollPane1.setViewportView(main);

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

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

        lblLpu.setText("Лечебно-профилактическое учреждение:");
        north_west.add(lblLpu, java.awt.BorderLayout.CENTER);

        north.add(north_west, java.awt.BorderLayout.WEST);

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

        cbLpu.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        north_center.add(cbLpu, java.awt.BorderLayout.PAGE_START);

        north.add(north_center, java.awt.BorderLayout.CENTER);

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

        btCreate.setText("Создать");
        btCreate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCreateActionPerformed(evt);
            }
        });
        south.add(btCreate);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(south, javax.swing.GroupLayout.DEFAULT_SIZE, 727, Short.MAX_VALUE)
            .addComponent(north, javax.swing.GroupLayout.DEFAULT_SIZE, 727, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 727, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(north, 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, 381, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(south, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btAddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddressActionPerformed
        try {
            Address address = UserInfo.get().getCollaborator().getLpu().getAddress();
            DialogAddressM dialog = new DialogAddressM((Frame) getContainer(), lpuLocal.getAddress(), address, getAuditManager());
            dialog.setVisible(true);
            if (dialog.getDlgResult() == ModalDialog.DLG_OK)
            {
                if (!dialog.getAddress().equals(lpuLocal.getAddress())){
                    lpuLocal.setAddress(dialog.getAddress());
                }
            }
            getContainer().contentStateChanged();
//            editAddress.setText(clientLocal.getAddress().toString());
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btAddressActionPerformed

    private void btCreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCreateActionPerformed
        try {
            LpuLocal lpuLocalNew = new LpuLocal(getAuditManager());
            setViewLpu(lpuLocalNew);
            LpuDetails lpuDetails = new LpuDetails();
            lpuDetails.title = "";
            lpuContModel.setSelectedItem(new DirectoryLpuItem(lpuDetails));
            fireContainerEventStateChanged();
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btCreateActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAddress;
    private javax.swing.JButton btCreate;
    private javax.swing.JComboBox cbInsurer;
    private javax.swing.JComboBox cbLpu;
    private javax.swing.JComboBox cbLpuType;
    private javax.swing.JPanel center;
    private javax.swing.JPanel center_north;
    private javax.swing.JPanel center_north_center;
    private javax.swing.JPanel center_north_west;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblAccountant;
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblChiefDoctor;
    private javax.swing.JLabel lblClinicType;
    private javax.swing.JLabel lblDivisionCode;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblFax;
    private javax.swing.JLabel lblLpu;
    private javax.swing.JLabel lblOgrn;
    private javax.swing.JLabel lblOkato;
    private javax.swing.JLabel lblOkfc;
    private javax.swing.JLabel lblOkogu;
    private javax.swing.JLabel lblOkonh;
    private javax.swing.JLabel lblOkopf;
    private javax.swing.JLabel lblOkpo;
    private javax.swing.JLabel lblOkved;
    private javax.swing.JLabel lblPhone;
    private javax.swing.JLabel lblPostIndex;
    private javax.swing.JLabel lblRfoms;
    private javax.swing.JLabel lblTfoms;
    private javax.swing.JLabel lblTitle;
    private javax.swing.JLabel lblinsurer;
    private javax.swing.JPanel main;
    private javax.swing.JPanel north;
    private javax.swing.JPanel north_center;
    private javax.swing.JPanel north_west;
    private javax.swing.JPanel pnlAddress;
    private clips.accountant.PanelCollaboratorSelect pscChiefAccauntant;
    private clips.accountant.PanelCollaboratorSelect pscChiefDoctor;
    private javax.swing.JPanel south;
    private javax.swing.JTextField tfAddress;
    private javax.swing.JTextField tfCode;
    private javax.swing.JTextField tfDivisionCode;
    private javax.swing.JTextField tfEmail;
    private javax.swing.JTextField tfFax;
    private javax.swing.JTextField tfOgrn;
    private javax.swing.JTextField tfOkato;
    private javax.swing.JTextField tfOkfs;
    private javax.swing.JTextField tfOkogu;
    private javax.swing.JTextField tfOkonh;
    private javax.swing.JTextField tfOkopf;
    private javax.swing.JTextField tfOkpo;
    private javax.swing.JTextField tfOkved;
    private javax.swing.JTextField tfPhone;
    private javax.swing.JTextField tfPostIndex;
    private javax.swing.JTextField tfRfoms;
    private javax.swing.JTextField tfTitle;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Панель редактирования данных ЛПУ";
    }

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

    @Override
    public boolean isDirty() {
        return lpuLocal != null ? lpuLocal.isDirty() : false;
    }

    @Override
    public void save() throws ClipsException {
        if (lpuLocal != null){
            lpuLocal.save1();
            DirectoryLocator.getDirectory(DirectoryLpu.class, true);
            initLpuCombo();
            for (DirectoryItemRO item : DirectoryLocator.getDirectory(DirectoryLpu.class).toArray()) {
                if (item.getID() == lpuLocal.getID()){
                    cbLpu.setSelectedItem(item);
                }
            }
        }
    }

    @Override
    public void restore() {
        if (lpuLocal != null){
            if (lpuLocal.isNewlyCreated()){
                lpuLocal = null;
                try{
                    cbLpu.setSelectedItem(UserInfo.get().getCollaborator().getLpu());
                    setViewLpu(UserInfo.get().getCollaborator().getLpu());
                }catch(ClipsException ex){
                    MessageBox.showException(ex);
                    try {
                        getContainer().removePage(this, true);
                    } catch (PageException ex1) {
                        MessageBox.showException(ex1);
                    }
                }
            }else{
                lpuLocal.restore();
                setViewLpu((DirectoryLpuItem) cbLpu.getSelectedItem());
            }
//            try{
//                pscChiefAccauntant.setSelectedCollaborator(lpuLocal.getAccountant());
//                pscChiefDoctor.setSelectedCollaborator(lpuLocal.getChiefDoctor());
//            }catch (ClipsException ex){
//                pscChiefAccauntant.setSelectedCollaborator(lpuLocal.getAccountant());
//                pscChiefDoctor.setSelectedCollaborator(lpuLocal.getChiefDoctor());
//            }
        }
    }

    @Override
    public void beforeOpen() {
        //DO NOTHING
    }

    @Override
    public void beforeClose() {
        for (int i = 0; i < containers.size(); i++) {
            ObjectContainer d = containers.get(i);
            d.setObject(null);
        }

    }



}
TOP

Related Classes of clips.administrator.lpu.PanelLpu$LpuTextModelSuEditable

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.