Package clips.doctor.disease

Source Code of clips.doctor.disease.DialogAddSerren

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

/*
* DialogAddSerren.java
*
* Created on 26.06.2009, 11:44:42
*/

package clips.doctor.disease;

import cli_fmw.main.ClipsException;
import cli_fmw.main.audit.AuditManager;
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 clips.delegate.doctor.DiseaseLocal;
import clips.delegate.service.SerRenLocal;
import clips.service.TableModelSerRenList;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
*
* @author vip
*/
public class DialogAddSerren extends ModalDialog {

    private DiseaseLocal disease;
    private List<SerRenLocal> serRenList;
    private ArrayList<SerRenLocal> newSerrenList = new ArrayList<SerRenLocal>();

    /** Creates new form DialogAddSerren */
    public DialogAddSerren(java.awt.Frame parent, DiseaseLocal disease, AuditManager am) throws ClipsException {
        super(parent, "Добавление услуги (посещения)", am);
        initComponents();
        this.disease = disease;
        serRenList = disease.getEmcLocal().getClient().getSerRenListOutofDisease();
        serrenTable.setModel(new TableModelSerRenList(serRenList));
        serrenTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        serrenTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            @Override
            public void valueChanged(ListSelectionEvent e) {
                setEnabledComponents();
            }
        });
        setEnabledComponents();
        resizeColumn();
        StateSaver.attachTo(this);
    }

    private void setEnabledComponents() {
        int[] rows = serrenTable.getSelectedRowsSorted();
        btOK.setEnabled(rows.length > 0);
    }

    private void resizeColumn() {
    TableState          state = new TableState();
    state.setPreferredWidth(TableModelSerRenList.COL_PACKET,    3);
    state.setPreferredWidth(TableModelSerRenList.COL_SERVICE,    18);
    state.setPreferredWidth(TableModelSerRenList.COL_DIRECTED,    15);
    state.setPreferredWidth(TableModelSerRenList.COL_RENDERED,    10);
    state.setPreferredWidth(TableModelSerRenList.COL_PRICE,      6);
    state.setPreferredWidth(TableModelSerRenList.COL_MONEY,      6);
    state.setPreferredWidth(TableModelSerRenList.COL_DISCOUNT,    5);
    state.setPreferredWidth(TableModelSerRenList.COL_REST,      8);
    state.setPreferredWidth(TableModelSerRenList.COL_PAY,      6);
    state.setPreferredWidth(TableModelSerRenList.COL_STT,      3);
      StateSaver.setDefaultState(this, serrenTable, state);

    }

    public ArrayList<SerRenLocal> getNewSerrenList() {
        return newSerrenList;
    }

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

        jPanel12 = new javax.swing.JPanel();
        btOK = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        serrenTable = new cli_fmw.utils.sorted_table.SortedTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        btOK.setText("Записать");
        btOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOKActionPerformed(evt);
            }
        });

        btCancel.setText("Отменить");
        btCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap(731, Short.MAX_VALUE)
                .addComponent(btOK)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btCancel)
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btCancel)
                .addComponent(btOK))
        );

        serrenTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(serrenTable);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().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, 907, Short.MAX_VALUE)
                    .addComponent(jPanel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOKActionPerformed
        try {
            int[] rows = serrenTable.getSelectedRowsSorted();
            newSerrenList.clear();
            for (int i = 0; i < rows.length; i++) {
                newSerrenList.add(serRenList.get(rows[i]));
            }
            setDlgResult(ModalDialog.DLG_OK);
            dispose();
        } catch (Exception ex) {
            MessageBox.showException(new ClipsException("", ex));
        }
}//GEN-LAST:event_btOKActionPerformed

    private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
        setDlgResult(ModalDialog.DLG_CANCEL);
        dispose();
}//GEN-LAST:event_btCancelActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOK;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable serrenTable;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of clips.doctor.disease.DialogAddSerren

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.