Package reportgen.gui.genepanel.corepanel.entitypanel.dlg

Source Code of reportgen.gui.genepanel.corepanel.entitypanel.dlg.NewReportEntityDlg

/*
* NewReportEntityDlg.java
*
* Created on 1 Ноябрь 2008 г., 12:32
*/

package reportgen.gui.genepanel.corepanel.entitypanel.dlg;

import java.awt.Window;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import reportgen.prototype.entity.QEntity;
import reportgen.utils.ReportDialog;

/**
*
* @author  axe
*/
public class NewReportEntityDlg extends ReportDialog {

    public NewReportEntityDlg(Window parent, List<QEntity> entities) {
        super(parent, "Новый запрос");
        initComponents();
       
        mainList.setModel(new DefaultComboBoxModel(entities.toArray()));
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel5 = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        mainList = new javax.swing.JList();
        jPanel1 = new javax.swing.JPanel();
        description = new javax.swing.JLabel();
        jSplitPane2 = new javax.swing.JSplitPane();
        jPanel4 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        simpleItemList = new javax.swing.JList();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        itemList = new javax.swing.JList();
        jPanel2 = new javax.swing.JPanel();
        okBtn = new javax.swing.JButton();
        cancelBtn = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

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

        jScrollPane1.setPreferredSize(new java.awt.Dimension(250, 154));

        mainList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                mainListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(mainList);

        jSplitPane1.setLeftComponent(jScrollPane1);

        jPanel1.setLayout(new java.awt.BorderLayout(20, 20));
        jPanel1.add(description, java.awt.BorderLayout.NORTH);

        jSplitPane2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jPanel4.setLayout(new java.awt.BorderLayout(5, 5));

        jLabel2.setText("Cодержит данные:");
        jPanel4.add(jLabel2, java.awt.BorderLayout.NORTH);

        simpleItemList.setEnabled(false);
        jScrollPane3.setViewportView(simpleItemList);

        jPanel4.add(jScrollPane3, java.awt.BorderLayout.CENTER);

        jSplitPane2.setTopComponent(jPanel4);

        jPanel3.setLayout(new java.awt.BorderLayout(5, 5));

        jLabel1.setText("Cвязан с объектами:");
        jPanel3.add(jLabel1, java.awt.BorderLayout.NORTH);

        itemList.setEnabled(false);
        jScrollPane2.setViewportView(itemList);

        jPanel3.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jSplitPane2.setBottomComponent(jPanel3);

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

        jSplitPane1.setRightComponent(jPanel1);

        jPanel5.add(jSplitPane1, java.awt.BorderLayout.CENTER);

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

        okBtn.setText("    OK    ");
        okBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okBtnActionPerformed(evt);
            }
        });
        jPanel2.add(okBtn);

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

        jPanel5.add(jPanel2, 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(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 757, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
                .addContainerGap())
        );

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

private void mainListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_mainListValueChanged
    QEntity ren = (QEntity) mainList.getSelectedValue();
    if(ren != null) {
        description.setText(ren.getDescription() != null
                ? ren.getDescription() : "нет описания");

        QEntity[] availEntities = ren.getAvialiableEntities();
        if(availEntities != null) {
            itemList.setModel(new DefaultComboBoxModel(availEntities));
        } else {
            itemList.setModel(new DefaultComboBoxModel());
        }
        simpleItemList.setModel(new DefaultComboBoxModel(ren.getAvialiableProperties().toArray()));
    } else {
        description.setText("");
       
        DefaultListModel model = new DefaultListModel();
        itemList.setModel(model);
        simpleItemList.setModel(model);
    }
   
}//GEN-LAST:event_mainListValueChanged

private void okBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBtnActionPerformed
    setDlgResult(true);
    setVisible(false);
}//GEN-LAST:event_okBtnActionPerformed

private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
    setVisible(false);
}//GEN-LAST:event_cancelBtnActionPerformed

    public int getSelectedIndex() {
        return  mainList.getSelectedIndex();
    }
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelBtn;
    private javax.swing.JLabel description;
    private javax.swing.JList itemList;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JList mainList;
    private javax.swing.JButton okBtn;
    private javax.swing.JList simpleItemList;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of reportgen.gui.genepanel.corepanel.entitypanel.dlg.NewReportEntityDlg

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.