Package view

Source Code of view.FormPesquisa

/*
* FormPesquisa.java
*
* Created on 9 de Novembro de 2008, 14:04
*/

package view;

import controller.AlunoController;
import controller.AulaAvaliativaController;
import controller.AvaliacaoController;
import controller.CandidatoController;
import controller.EmpresaController;
import controller.PessoaController;
import controller.operating.GerenciadorOperacional;
import java.awt.Cursor;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

/**
*
* @author  Consult
*/
public class FormPesquisa extends javax.swing.JDialog {
   
    private enum  Pesquisa {Contato, Aluno, Empresa, Candidato, Avaliacao, Formulario};   
    private Pesquisa pesquisa;
   
    /** Creates new form FormPesquisa */
    public FormPesquisa(java.awt.Frame parent, boolean modal, String tipo) {       
        super(parent, modal);
        initComponents();
        Vector<String> elementosDaTabela = new Vector<String>();
       
        if(tipo.equals("contato")){
            pesquisa = pesquisa.Contato;
            jLabelTitulo.setText("Pesquisa por Contatos - Clique em um item para selecionar");
            PessoaController pessoaCtrl = new PessoaController();

            elementosDaTabela.addElement("Código");
            elementosDaTabela.addElement("Nome");
            elementosDaTabela.addElement("E-mail");       
            elementosDaTabela.addElement("Telefone");               
            elementosDaTabela.addElement("Celular");                                                          
            DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela,0);
            modeloTabela = pessoaCtrl.getTablePessoas(modeloTabela);
            jTable1.setModel(modeloTabela);
        }else
        if(tipo.equals("aluno")){
            pesquisa = pesquisa.Aluno;
            jLabelTitulo.setText("Pesquisa por Alunos - Clique em um item para selecionar");
            AlunoController alunoCtrl = new AlunoController();

            elementosDaTabela.addElement("Código");
            elementosDaTabela.addElement("Empresa");
            elementosDaTabela.addElement("Estagiário");       
            elementosDaTabela.addElement("Inicio");               
            elementosDaTabela.addElement("Duração");                                                                                            
            DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela,0);
            modeloTabela = alunoCtrl.getTableAlunos(modeloTabela);
            jTable1.setModel(modeloTabela);
        }else
        if(tipo.equals("empresa")){
            pesquisa = pesquisa.Empresa;
            jLabelTitulo.setText("Pesquisa por Empresas - Clique em um item para selecionar");
            EmpresaController empresaCtrl = new EmpresaController();

            elementosDaTabela.addElement("Código");
            elementosDaTabela.addElement("Razão Social");
            elementosDaTabela.addElement("E-mail");       
            elementosDaTabela.addElement("Telefone");               
            elementosDaTabela.addElement("Fax");                                                          
            DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela,0);
            modeloTabela = empresaCtrl.getTableEmpresas(modeloTabela, "pesquisa");
            jTable1.setModel(modeloTabela);
        }else
        if(tipo.equals("candidato")){
            pesquisa = pesquisa.Candidato;
            jLabelTitulo.setText("Pesquisa por Candidatos a Docente - Clique em um item para selecionar");
            CandidatoController candidatoCtrl= new CandidatoController();

            elementosDaTabela.addElement("Código");
            elementosDaTabela.addElement("Nome");
            elementosDaTabela.addElement("E-mail");
            elementosDaTabela.addElement("Celular");
            elementosDaTabela.addElement("Lattes");
            DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela, 0);
            modeloTabela = candidatoCtrl.getTableCandidatos(modeloTabela);
            jTable1.setModel(modeloTabela);
        }else
        if(tipo.equals("avaliacao")){
            pesquisa = pesquisa.Avaliacao;
            jLabelTitulo.setText("Pesquisa por Aulas Avaliativas - Clique em um item para selecionar");
            AulaAvaliativaController entrevistaCtrl= new AulaAvaliativaController();
           
            elementosDaTabela.addElement("Código");
            elementosDaTabela.addElement("Local");
            elementosDaTabela.addElement("Candidato");
            elementosDaTabela.addElement("Data");       
            elementosDaTabela.addElement("Resutado");                                     

            DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela,0);
            modeloTabela = entrevistaCtrl.getTableAulasAvaliativas(modeloTabela);
            jTable1.setModel(modeloTabela);
        }else
        if(tipo.equals("formulario")){
            pesquisa = pesquisa.Formulario;
            jLabelTitulo.setText("Pesquisa por Avaliações - Clique em um item para selecionar");
            AvaliacaoController avaliacaoCtrl = new AvaliacaoController();

            elementosDaTabela.addElement("Código");
            elementosDaTabela.addElement("Nome");
            elementosDaTabela.addElement("E-mail");       
            elementosDaTabela.addElement("Telefone");               
            elementosDaTabela.addElement("Celular");                                                          
            DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela,0);
            modeloTabela = avaliacaoCtrl.getTableAvaliacoes(modeloTabela);
            jTable1.setModel(modeloTabela);
        }
        jTable1.requestFocus();
        setVisible(true);
    }

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

        jPanel1 = new javax.swing.JPanel();
        jLabelTitulo = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Pesquisa");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setBackground(java.awt.Color.white);

        jLabelTitulo.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabelTitulo.setText("Titulo  - Clique para Selecionar");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabelTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelTitulo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTable1.setAutoCreateRowSorter(true);
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTable1MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jTable1MouseExited(evt);
            }
        });
        jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTable1KeyPressed(evt);
            }
        });
        jScrollPane2.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-556)/2, (screenSize.height-386)/2, 556, 386);
    }// </editor-fold>//GEN-END:initComponents

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
// TODO add your handling code here:
    int linhaSelecionada = jTable1.getSelectedRow();
    String codigo = String.valueOf(jTable1.getValueAt(linhaSelecionada, 0));
    String descricao = String.valueOf(jTable1.getValueAt(linhaSelecionada, 1));
    if(pesquisa.equals(pesquisa.Contato)){
        GerenciadorOperacional.setCodigo(codigo);
        GerenciadorOperacional.setDescricao(descricao);
        ContatoView.retornaBusca();
    }else
    if(pesquisa.equals(pesquisa.Aluno)){
        GerenciadorOperacional.setCodigo(codigo);
        GerenciadorOperacional.setDescricao(descricao);
        EstagioView.retornaBusca();
    }else
    if(pesquisa.equals(pesquisa.Empresa)){
        GerenciadorOperacional.setCodigoEmpresa(codigo);
        GerenciadorOperacional.setDescricaoEmpresa(descricao);
        EstagioView.retornaBuscaEmpresa();
    }else
    if(pesquisa.equals(pesquisa.Candidato)){
        GerenciadorOperacional.setCodigo(codigo);
        GerenciadorOperacional.setDescricao(descricao);
        AulaAvaliativaView.retornaBusca();
    }else
    if(pesquisa.equals(pesquisa.Avaliacao)){
        GerenciadorOperacional.setCodigo(codigo);
        GerenciadorOperacional.setDescricao(descricao);
        AvaliacaoView.retornaBusca();
    }else
    if(pesquisa.equals(pesquisa.Formulario)){
        GerenciadorOperacional.setCodigo(codigo);
        GerenciadorOperacional.setDescricao(descricao);
        FormularioView.retornaBusca();
    }
   
    this.dispose();
}//GEN-LAST:event_jTable1MouseClicked

private void jTable1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseEntered
// TODO add your handling code here:
    jTable1.setCursor(new Cursor(Cursor.HAND_CURSOR));
}//GEN-LAST:event_jTable1MouseEntered

private void jTable1MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseExited
// TODO add your handling code here:
    jTable1.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_jTable1MouseExited

private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed
// TODO add your handling code here:
    if(KeyEvent.VK_ENTER == evt.getKeyCode()){
        jTable1MouseClicked(new MouseEvent(this, WIDTH, WIDTH, WIDTH, WIDTH, WIDTH, WIDTH, rootPaneCheckingEnabled));
    }
}//GEN-LAST:event_jTable1KeyPressed

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// TODO add your handling code here:
   
}//GEN-LAST:event_formWindowClosing

private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
// TODO add your handling code here:
    if(pesquisa.equals(pesquisa.Contato)){
        ContatoView.cancelaBusca();
    }else
    if(pesquisa.equals(pesquisa.Aluno)){
        EstagioView.cancelaBusca();
    }else
    if(pesquisa.equals(pesquisa.Empresa)){
        EstagioView.cancelaBusca();
    }else
    if(pesquisa.equals(pesquisa.Candidato)){
        AulaAvaliativaView.cancelaBusca();
    }else
    if(pesquisa.equals(pesquisa.Avaliacao)){
        AvaliacaoView.cancelaBusca();
    }else
    if(pesquisa.equals(pesquisa.Avaliacao)){
        FormularioView.cancelaBusca();
    }
}//GEN-LAST:event_formWindowClosed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                FormPesquisa dialog = new FormPesquisa(new javax.swing.JFrame(), true, "");
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabelTitulo;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of view.FormPesquisa

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.