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

/*
 * Banco.java
 *
 * Created on 02/05/2009, 04:32:48
 */

package br.com.syndic.frame;

import br.com.syndic.controller.BancoController;
import br.com.syndic.controller.BancoDetalheController;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.ListSelectionModel;
import org.openswing.swing.mdi.client.InternalFrame;

/**
 *
 * @author Albert Eije
 */
public class Banco extends InternalFrame implements ActionListener {

    private Connection conn = null;

    /** Creates new form GridFrame2 */
    public Banco(Connection conn, BancoController controller) {
        this.conn = conn;
        try {
            initComponents();
            setSize(750, 300);
            gridControl1.setController(controller);
            gridControl1.setGridDataLocator(controller);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void reloadData() {
        gridControl1.reloadData();
    }
    
    /** 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() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        insertButton1 = new org.openswing.swing.client.InsertButton();
        editButton1 = new org.openswing.swing.client.EditButton();
        deleteButton1 = new org.openswing.swing.client.DeleteButton();
        reloadButton1 = new org.openswing.swing.client.ReloadButton();
        exportButton1 = new org.openswing.swing.client.ExportButton();
        importButton1 = new org.openswing.swing.client.ImportButton();
        navigatorBar1 = new org.openswing.swing.client.NavigatorBar();
        gridControl1 = new org.openswing.swing.client.GridControl();
        integerColumn1 = new org.openswing.swing.table.columns.client.IntegerColumn();
        integerColumn2 = new org.openswing.swing.table.columns.client.IntegerColumn();
        textColumn1 = new org.openswing.swing.table.columns.client.TextColumn();
        textColumn2 = new org.openswing.swing.table.columns.client.TextColumn();

        setTitle("Cadastro de Bancos");
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jPanel1.setBackground(new java.awt.Color(0, 204, 204));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel1.setText("Cadastro de Bancos");
        jPanel1.add(jLabel1);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        getContentPane().add(jPanel1, gridBagConstraints);

        jPanel2.setBackground(new java.awt.Color(0, 204, 204));
        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        insertButton1.addActionListener(this);
        jPanel2.add(insertButton1);
        jPanel2.add(editButton1);
        jPanel2.add(deleteButton1);
        jPanel2.add(reloadButton1);
        jPanel2.add(exportButton1);
        jPanel2.add(importButton1);
        jPanel2.add(navigatorBar1);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        getContentPane().add(jPanel2, gridBagConstraints);

        gridControl1.setDeleteButton(deleteButton1);
        gridControl1.setEditButton(editButton1);
        gridControl1.setExportButton(exportButton1);
        gridControl1.setFunctionId("banco");
        gridControl1.setImportButton(importButton1);
        gridControl1.setNavBar(navigatorBar1);
        gridControl1.setReloadButton(reloadButton1);
        gridControl1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        gridControl1.setValueObjectClassName("br.com.syndic.vo.BancoVO");
        gridControl1.getColumnContainer().setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        integerColumn1.setColumnName("codBanco");
        integerColumn1.setColumnSortable(true);
        integerColumn1.setHeaderColumnName("Código Banco");
        integerColumn1.setSortVersus(org.openswing.swing.util.java.Consts.ASC_SORTED);
        gridControl1.getColumnContainer().add(integerColumn1);

        integerColumn2.setColumnName("codCompensacao");
        integerColumn2.setColumnSortable(true);
        integerColumn2.setHeaderColumnName("Cód Compensação");
        gridControl1.getColumnContainer().add(integerColumn2);

        textColumn1.setColumnFilterable(true);
        textColumn1.setColumnName("nomeBanco");
        textColumn1.setColumnSortable(true);
        textColumn1.setHeaderColumnName("Nome do Banco");
        textColumn1.setPreferredWidth(250);
        gridControl1.getColumnContainer().add(textColumn1);

        textColumn2.setColumnFilterable(true);
        textColumn2.setColumnName("siteBanco");
        textColumn2.setColumnSortable(true);
        textColumn2.setHeaderColumnName("Site do Banco");
        textColumn2.setPreferredWidth(200);
        gridControl1.getColumnContainer().add(textColumn2);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        getContentPane().add(gridControl1, gridBagConstraints);

        pack();
    }

    // Code for dispatching events from components to event handlers.

    public void actionPerformed(java.awt.event.ActionEvent evt) {
        if (evt.getSource() == insertButton1) {
            Banco.this.insertButton1ActionPerformed(evt);
        }
    }// </editor-fold>//GEN-END:initComponents

    private void insertButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertButton1ActionPerformed
        new BancoDetalheController(this, null, conn);
    }//GEN-LAST:event_insertButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.openswing.swing.client.DeleteButton deleteButton1;
    private org.openswing.swing.client.EditButton editButton1;
    private org.openswing.swing.client.ExportButton exportButton1;
    private org.openswing.swing.client.GridControl gridControl1;
    private org.openswing.swing.client.ImportButton importButton1;
    private org.openswing.swing.client.InsertButton insertButton1;
    private org.openswing.swing.table.columns.client.IntegerColumn integerColumn1;
    private org.openswing.swing.table.columns.client.IntegerColumn integerColumn2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private org.openswing.swing.client.NavigatorBar navigatorBar1;
    private org.openswing.swing.client.ReloadButton reloadButton1;
    private org.openswing.swing.table.columns.client.TextColumn textColumn1;
    private org.openswing.swing.table.columns.client.TextColumn textColumn2;
    // End of variables declaration//GEN-END:variables

}
