Package cli_fmw.address

Source Code of cli_fmw.address.DialogNewKladrItem

/*//GEN-FIRST:event_btOkActionPerformed
* To change this template, choose Tools | Templates//GEN-LAST:event_btOkActionPerformed
* and open the template in the editor.
*/

/*
* DialogNewKladrItem.java
*
* Created on 26.01.2009, 15:28:17
*/

package cli_fmw.address;

import cli_fmw.delegate.directory.complex.DirectoryKladr;
import cli_fmw.delegate.directory.complex.DirectoryKladrItem;
import cli_fmw.delegate.directory.complex.DirectoryKladrType;
import cli_fmw.delegate.directory.complex.DirectoryKladrTypeItem;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.main.ClipsException;
import cli_fmw.main.audit.AuditManager;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.SelectorEditableExceptional;
import cli_fmw.utils.table_config_states.StateSaver;
import framework.beans.address.entities.AddressObjectDetails;
import java.awt.Window;
import javax.swing.DefaultComboBoxModel;

/**
*
* @author petr
*/
public class DialogNewKladrItem extends ModalDialog {

    private DirectoryKladr kladr;
    private DirectoryKladrType kladrType;
    private AddressObjectDetails details;

    public DialogNewKladrItem(Window parent, AddressObjectDetails details, int level, AuditManager am) throws ClipsException {
        super(parent, "Новый адресуемый объект", am);
        initComponents();
        kladr = DirectoryLocator.getDirectory(DirectoryKladr.class, false);
        kladrType = DirectoryLocator.getDirectory(DirectoryKladrType.class, false);
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        SelectorEditableExceptional<DirectoryKladrTypeItem> items = kladrType.getItems();
        for (int i = 0; i<items.size(); i++){
            if (items.get(i).getLevel() == level){
                model.addElement(items.get(i));
            }else if (level != DirectoryKladrType.LAST_USING_LEVEL
                    && items.get(i).isType(DirectoryKladrType.TYPE_STREET)){
                model.addElement(items.get(i));
            }
        }
        model.removeElement(kladrType.getNullItem());
        cbType.setModel(model);
        tfTitle.setText(details.title);
        this.details = details;
        StateSaver.attachTo(this);
    }

    /** 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">                         
    private void initComponents() {

        btOk = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        tfTitle = new javax.swing.JTextField();
        cbType = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Добавление адресуемого объекта");

        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);
            }
        });

        tfTitle.setText("jTextField1");

        cbType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel1.setText("Название");

        jLabel2.setText("Тип");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tfTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(tfTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(cbType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        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(175, Short.MAX_VALUE)
                .addComponent(btOk, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btCancel)
                    .addComponent(btOk))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                       

    private void btOkActionPerformed(java.awt.event.ActionEvent evt) {                                    
        setDlgResult(ModalDialog.DLG_OK);
        dispose();
    }                                   

    private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {                                        
        setDlgResult(ModalDialog.DLG_CANCEL);
        dispose();
    }                                       

    public DirectoryKladrItem getKladrItem(){
        details.title = tfTitle.getText();
        details.typeId = ((DirectoryKladrTypeItem)cbType.getSelectedItem()).getID();
        DirectoryKladrItem item = new DirectoryKladrItem(details, kladr);
        return item;
    }


    // Variables declaration - do not modify                    
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOk;
    private javax.swing.JComboBox cbType;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField tfTitle;
    // End of variables declaration                  

}
TOP

Related Classes of cli_fmw.address.DialogNewKladrItem

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.