Package clips.administrator.certificate

Source Code of clips.administrator.certificate.DlgNewCertificateType

/*
* DlgSetDirectionChoice.java
*
* Created on 18 Август 2008 г., 12:24
*/

package clips.administrator.certificate;

import clips.delegate.directory.complex.DirectoryCertificateTypeItem;
import cli_fmw.delegate.report.ReportLocal;
import cli_fmw.delegate.report.ReportSearchLocal;
import cli_fmw.main.ClipsException;
import cli_fmw.report.panels.model.delegate.DelegateListModel;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import beans.directory.certificate.entity.CertificateTypeDetails;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;

/**
*
* @author  lacoste
*/
public class DlgNewCertificateType extends ModalDialog {
   
    private DelegateListModel<ReportLocal> reportListModel;
    private ReportLocal report;
    DirectoryCertificateTypeItem newItem;
   
    /** Creates new form DlgSetDirectionChoice */
    public DlgNewCertificateType(java.awt.Frame parent) throws ClipsException {
        super(parent, "Выбор типа справки", null);
        initComponents();
       
        Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle dlgSize = this.getBounds();
        this.setLocation((scrSize.width - dlgSize.width) / 2, (scrSize.height - dlgSize.height) / 2);
       
        reportListModel = new DelegateListModel<ReportLocal>(new ReportSearchLocal(getAuditManager()).getReports());
        listReport.setModel(reportListModel);
    StateSaver.attachTo(this);
    }

    public DirectoryCertificateTypeItem getCertificateType() {
        return newItem;
    }

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

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        tfTitle = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        listReport = new javax.swing.JList();
        panelOkCancel = new javax.swing.JPanel();
        btOK = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

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

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

        jLabel1.setText("Название : ");
        jPanel2.add(jLabel1, java.awt.BorderLayout.WEST);
        jPanel2.add(tfTitle, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel2, java.awt.BorderLayout.PAGE_START);

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Отчет"));

        listReport.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        listReport.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listReportValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(listReport);

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

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

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

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

        jPanel1.add(panelOkCancel, java.awt.BorderLayout.SOUTH);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE))
        );

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

private void listReportValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listReportValueChanged
    int pos = listReport.getSelectedIndex();
    if (pos < 0 || pos >= reportListModel.size()) {
        btOK.setEnabled(false);
        return;
    } else {
        if (tfTitle.getText().trim().isEmpty()) {
            tfTitle.setText(listReport.getSelectedValue().toString());
        }
        btOK.setEnabled(true);
        report = (ReportLocal) listReport.getSelectedValue();
    }
}//GEN-LAST:event_listReportValueChanged

private void btOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOKActionPerformed
        try {
            CertificateTypeDetails details = new CertificateTypeDetails();
            details.title = tfTitle.getText();
            details.hidden = false;
            newItem = new DirectoryCertificateTypeItem(details);
            newItem.setReportLocal(report);
            setDlgResult(ModalDialog.DLG_OK);
            this.dispose();
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
}//GEN-LAST:event_btOKActionPerformed

private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
        setDlgResult(ModalDialog.DLG_CANCEL);
        this.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.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JList listReport;
    private javax.swing.JPanel panelOkCancel;
    private javax.swing.JTextField tfTitle;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of clips.administrator.certificate.DlgNewCertificateType

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.