Package cli_fmw.directory.editors.kladr

Source Code of cli_fmw.directory.editors.kladr.PanelCountryEdit

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

/*
* PanelDirectoryCountry.java
*
* Created on 05.09.2009, 13:30:48
*/

package cli_fmw.directory.editors.kladr;

import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.delegate.directory.complex.DirectoryCountry;
import cli_fmw.delegate.directory.complex.DirectoryCountryItem;
import cli_fmw.main.ClipsException;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageGeneric;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;

/**
*
* @author petr
*/
public class PanelCountryEdit extends PageGeneric {
    private final DirectoryCountry dc;

    public PanelCountryEdit(PageContainer container) throws ClipsException {
        super(container);
        initComponents();
        dc = DirectoryLocator.getDirectory(DirectoryCountry.class);
        sortedTable1.setModel(new DirectoryCountryTableModel(dc));
        StateSaver.attachTo(this);
    }

    /** Creates new form PanelDirectoryCountry */

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

        dialogNew = new javax.swing.JDialog();
        tfTitle = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        tfCode = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        btCancel = new javax.swing.JButton();
        btOK = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        sortedTable1 = new cli_fmw.utils.sorted_table.SortedTable();
        jPanel1 = new javax.swing.JPanel();
        btAdd = new javax.swing.JButton();
        btRemove = new javax.swing.JButton();

        dialogNew.setTitle("Введите данные");
        dialogNew.setLocationByPlatform(true);
        dialogNew.setModal(true);
        dialogNew.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                dialogNewWindowOpened(evt);
            }
        });

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

        jLabel2.setText("Код по ОКСМ:");

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

        btOK.setText("Принять");
        btOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogNewLayout = new javax.swing.GroupLayout(dialogNew.getContentPane());
        dialogNew.getContentPane().setLayout(dialogNewLayout);
        dialogNewLayout.setHorizontalGroup(
            dialogNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dialogNewLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tfTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(dialogNewLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tfCode, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dialogNewLayout.createSequentialGroup()
                .addContainerGap(216, Short.MAX_VALUE)
                .addComponent(btOK)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btCancel)
                .addContainerGap())
        );
        dialogNewLayout.setVerticalGroup(
            dialogNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogNewLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dialogNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dialogNewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btCancel)
                    .addComponent(btOK))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        dialogNew.getAccessibleContext().setAccessibleParent(null);

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

        sortedTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(sortedTable1);

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

        btAdd.setText("Добавить");
        btAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddActionPerformed(evt);
            }
        });

        btRemove.setText("Удалить");
        btRemove.setEnabled(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(151, Short.MAX_VALUE)
                .addComponent(btAdd)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btRemove))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btRemove)
                .addComponent(btAdd))
        );

        add(jPanel1, java.awt.BorderLayout.PAGE_END);
    }// </editor-fold>//GEN-END:initComponents

    private void btAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddActionPerformed
        dialogNew.setVisible(true);
    }//GEN-LAST:event_btAddActionPerformed

    private void btOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOKActionPerformed
        if (tfTitle.getText() == null || tfTitle.getText().isEmpty()){
            MessageBox.showError(MessageBox.E_MAKE_FUCKING_EXCEPTION,"Название страны не введено");
            return;
        }
        if (tfCode.getText() == null || tfCode.getText().isEmpty()){
            MessageBox.showError(MessageBox.E_MAKE_FUCKING_EXCEPTION,"Код страны по ОКСМ не введен");
            return;
        }
        try {
            dc.getItems().append(new DirectoryCountryItem(tfTitle.getText(), tfCode.getText(), dc));
            tfTitle.setText("");
            tfCode.setText("");
            dialogNew.setVisible(false);
        } catch (ClipsException ex) {
            MessageBox.showException(ex);
        }
    }//GEN-LAST:event_btOKActionPerformed

    private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
        tfTitle.setText("");
        tfCode.setText("");
        dialogNew.setVisible(false);
    }//GEN-LAST:event_btCancelActionPerformed

    private void dialogNewWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_dialogNewWindowOpened
        dialogNew.pack();
    }//GEN-LAST:event_dialogNewWindowOpened


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAdd;
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOK;
    private javax.swing.JButton btRemove;
    private javax.swing.JDialog dialogNew;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private cli_fmw.utils.sorted_table.SortedTable sortedTable1;
    private javax.swing.JTextField tfCode;
    private javax.swing.JTextField tfTitle;
    // End of variables declaration//GEN-END:variables

    @Override
    public String getPageTitle() {
        return "Редактор стран";
    }

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

}
TOP

Related Classes of cli_fmw.directory.editors.kladr.PanelCountryEdit

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.