Package view

Source Code of view.FormularioView

/*
* AvaliacaoView.java
*
* Created on 13 de Setembro de 2008, 11:48
*/
package view;

import controller.AvaliacaoController;
import controller.FormularioAvaliacaoController;
import controller.operating.GerenciadorDeConfiguracoesDoSistema;
import controller.operating.GerenciadorOperacional;
import java.awt.Component;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import controller.operating.Strings;
import java.util.ArrayList;
import javax.swing.JComboBox;
import model.Avaliacao;
import model.AvaliacaoItem;
import model.FormularioAvaliacao;

/**
*
* @author  Consult
*/
public class FormularioView extends javax.swing.JInternalFrame {

    /** Creates new form AvaliacaoView */
    private enum Modo {Edicao, Inclusao, Navegacao};
    private static Modo modo;
    public FormPesquisa pesquisa;

    /** Creates new form CandidatoView */
    public FormularioView(String codigoAvaliacao, String codigoFormulario, String pModo) {
        initComponents();
        jTextFieldCodigoAvaliacao.setText(codigoAvaliacao);
        jTextFieldCodigoFormulario.setText(codigoFormulario);
        habilitaCampos(false);     
        if (GerenciadorDeConfiguracoesDoSistema.getUsarConexao()) {
            jTextFieldCodigoFormulario.setVisible(false);
            jTextFieldCodigoAvaliacao.setVisible(false);
       
        if(pModo.equals("edicao")){           
            JButton[] listaBotoesAtivos = {btnEditar, btnExcluir, btnFechar, jButtonConsultar};
            habilitaBotoes(listaBotoesAtivos, true);
           
            JButton[] listaBotoesInativos = {btnSalvar, btnCancelar, btnNovo};
            habilitaBotoes(listaBotoesInativos, false);
           
            modo = Modo.Edicao;
        }else{           
            JButton[] listaBotoesAtivos = {btnNovo, btnFechar};
            habilitaBotoes(listaBotoesAtivos, true);
           
            JButton[] listaBotoesInativos = {btnSalvar, btnEditar, btnCancelar, btnExcluir, jButtonConsultar};
            habilitaBotoes(listaBotoesInativos, false);
           
            modo = Modo.Navegacao;
        }
        carregaDados(codigoAvaliacao, codigoFormulario);
    }

    public static void retornaBusca() {
        jTextFieldCodigoAvaliacao.setText(GerenciadorOperacional.getCodigo());
        jTextFieldCandidatoAvaliacao.setText(GerenciadorOperacional.getDescricao());
        JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
        habilitaBotoes(listaBotoes, true);
        jTextFieldAvaliador.requestFocus();
        FormularioAvaliacaoController formularioCtrl = new FormularioAvaliacaoController();
        jTextFieldCodigoFormulario.setText(formularioCtrl.getNovoCodigo(jTextFieldCodigoAvaliacao.getText()));
    }

    public static void cancelaBusca() {
        JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
        habilitaBotoes(listaBotoes, true);
        jTextFieldAvaliador.requestFocus();
    }
   
    private static void habilitaBotoes(JButton[] pBotoes, Boolean pValor) {
        // TODO add your handling code here:
        for (int i = 0; i < pBotoes.length; i++) {
            pBotoes[i].setEnabled(pValor);
        }
    }

    private void habilitaCampos(Boolean pValor) {
        // TODO add your handling code here:
        Component[] componenteSuperior = jPanel1.getComponents();
        for (int i = 0; i < componenteSuperior.length; i++) {
            if ((componenteSuperior[i] instanceof JTextField)) {
                componenteSuperior[i].setEnabled(pValor);
            }
        }
       
        Component[] componenteInferior = jPanel2.getComponents();
        for (int i = 0; i < componenteInferior.length; i++) {
            if ((componenteInferior[i] instanceof JTextField)) {
                componenteInferior[i].setEnabled(pValor);
            }
            if ((componenteInferior[i] instanceof JComboBox)) {
                componenteInferior[i].setEnabled(pValor);
            }
        }
    }

    private static void limpaCampos() {
        Component[] c = jPanel1.getComponents();
        for (int i = 0; i < c.length; i++) {
            if (c[i] instanceof JTextField) {
                ((JTextField) c[i]).setText("");
            }
        }
    }
   
    public void carregaDados(String codigoAvaliacao, String codigoFormulario) {
        FormularioAvaliacaoController formularioCtrl = new FormularioAvaliacaoController();
        FormularioAvaliacao formulario = new FormularioAvaliacao();

        formulario = formularioCtrl.getFormularioAvaliacao(codigoAvaliacao, codigoFormulario);
        AvaliacaoController avaliacaoCtrl = new AvaliacaoController();        
        Avaliacao avaliacao = avaliacaoCtrl.getAvaliacao(codigoAvaliacao);
       
        if (formulario.getListaDeItens().size() > 0) {
            jTextFieldCandidatoAvaliacao.setText(avaliacao.getAulaAvaliativa().getCandidato().getNome());
            jTextFieldAvaliador.setText(formulario.getNomeAvaliador());
            jComboBoxIntroducao.setSelectedItem(formulario.getListaDeItens().get(0).getConceito());
            jTextFieldIntroducao1.setText(formulario.getListaDeItens().get(0).getComentario());
            jComboBoxDominio.setSelectedItem(formulario.getListaDeItens().get(1).getConceito());
            jTextFieldDominio1.setText(formulario.getListaDeItens().get(1).getComentario());
            jComboBoxMetodologia.setSelectedItem(formulario.getListaDeItens().get(2).getConceito());
            jTextFieldMetodlogia1.setText(formulario.getListaDeItens().get(2).getComentario());
            jComboBoxSeguranca.setSelectedItem(formulario.getListaDeItens().get(3).getConceito());
            jTextFieldSeguranca1.setText(formulario.getListaDeItens().get(3).getComentario());
            jComboBoxRecurso.setSelectedItem(formulario.getListaDeItens().get(4).getConceito());
            jTextFieldRecurso1.setText(formulario.getListaDeItens().get(4).getComentario());
            jComboBoxDicatica.setSelectedItem(formulario.getListaDeItens().get(5).getConceito());
            jTextFieldDidatica1.setText(formulario.getListaDeItens().get(5).getComentario());
            jComboBoxPostura.setSelectedItem(formulario.getListaDeItens().get(6).getConceito());
            jTextFieldPostura1.setText(formulario.getListaDeItens().get(6).getComentario());
            jComboBoxPlanejamento.setSelectedItem(formulario.getListaDeItens().get(7).getConceito());
            jTextFieldPlanejamento1.setText(formulario.getListaDeItens().get(7).getComentario());
            jComboBoxTempo.setSelectedItem(formulario.getListaDeItens().get(8).getConceito());
            jTextFieldTempo1.setText(formulario.getListaDeItens().get(8).getComentario());
            jComboBoxMotivacao.setSelectedItem(formulario.getListaDeItens().get(9).getConceito());
            jTextFieldMotivacao1.setText(formulario.getListaDeItens().get(9).getComentario());
            jComboBoxDiccao.setSelectedItem(formulario.getListaDeItens().get(10).getConceito());
            jTextFieldDiccao1.setText(formulario.getListaDeItens().get(10).getComentario());
        }
    }

    /** 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();
        jLabelCandidato = new javax.swing.JLabel();
        jButtonConsultar = new javax.swing.JButton();
        jTextFieldCandidatoAvaliacao = new javax.swing.JFormattedTextField();
        jLabelCodigoAvaliacao1 = new javax.swing.JLabel();
        jTextFieldAvaliador = new javax.swing.JFormattedTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldIntroducao1 = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldDominio1 = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldMetodlogia1 = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldSeguranca1 = new javax.swing.JFormattedTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldRecurso1 = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldDidatica1 = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldPostura1 = new javax.swing.JFormattedTextField();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldPlanejamento1 = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldTempo1 = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldMotivacao1 = new javax.swing.JFormattedTextField();
        jLabel11 = new javax.swing.JLabel();
        jTextFieldDiccao1 = new javax.swing.JFormattedTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jTextFieldCodigoAvaliacao = new javax.swing.JTextField();
        jTextFieldCodigoFormulario = new javax.swing.JTextField();
        jComboBoxIntroducao = new javax.swing.JComboBox();
        jComboBoxDominio = new javax.swing.JComboBox();
        jComboBoxMetodologia = new javax.swing.JComboBox();
        jComboBoxSeguranca = new javax.swing.JComboBox();
        jComboBoxRecurso = new javax.swing.JComboBox();
        jComboBoxDicatica = new javax.swing.JComboBox();
        jComboBoxPostura = new javax.swing.JComboBox();
        jComboBoxPlanejamento = new javax.swing.JComboBox();
        jComboBoxTempo = new javax.swing.JComboBox();
        jComboBoxMotivacao = new javax.swing.JComboBox();
        jComboBoxDiccao = new javax.swing.JComboBox();
        jToolBar1 = new javax.swing.JToolBar();
        btnNovo = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnSalvar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        btnEditar = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        btnExcluir = new javax.swing.JButton();
        jSeparator5 = new javax.swing.JToolBar.Separator();
        btnCancelar = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        btnFechar = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Formulário");

        jLabelCandidato.setText("Candidato:");

        jButtonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Pesquisar.png"))); // NOI18N
        jButtonConsultar.setText("Avaliação");
        jButtonConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConsultarActionPerformed(evt);
            }
        });

        jTextFieldCandidatoAvaliacao.setEditable(false);
        jTextFieldCandidatoAvaliacao.setFocusable(false);
        jTextFieldCandidatoAvaliacao.setName("Nome"); // NOI18N

        jLabelCodigoAvaliacao1.setText("Avaliador:");

        jTextFieldAvaliador.setName("Nome"); // NOI18N
        jTextFieldAvaliador.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldAvaliadorKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldAvaliadorKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldAvaliadorKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelCandidato)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelCodigoAvaliacao1)
                        .addGap(14, 14, 14)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldAvaliador, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
                    .addComponent(jTextFieldCandidatoAvaliacao, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCandidato)
                    .addComponent(jButtonConsultar)
                    .addComponent(jTextFieldCandidatoAvaliacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCodigoAvaliacao1)
                    .addComponent(jTextFieldAvaliador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(9, Short.MAX_VALUE))
        );

        jPanel2.setAutoscrolls(true);

        jLabel1.setText("Introdução:");

        jLabel2.setText("Dominio:");

        jLabel3.setText("Metodologia:");

        jLabel4.setText("Segurança:");

        jLabel5.setText("Recurso:");

        jLabel6.setText("Didática:");

        jLabel7.setText("Postura:");

        jLabel8.setText("Planejto:");

        jLabel9.setText("Util. Tempo:");

        jLabel10.setText("Motivação:");

        jLabel11.setText("Dicção:");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel12.setText("Conceitos");

        jLabel13.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel13.setText("Excelente");

        jLabel14.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel14.setText("Ótimo");

        jLabel15.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel15.setText("Bom");

        jLabel16.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel16.setText("Regular");

        jLabel17.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel17.setText("Ruim");

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel18.setText("10 - 8,1");

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel19.setText(" 8 - 6,1");

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel20.setText("6 - 4,1");

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel21.setText("4 - 2,1");

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel22.setText(" 2 - 0,0");

        jTextFieldCodigoAvaliacao.setEditable(false);
        jTextFieldCodigoAvaliacao.setEnabled(false);
        jTextFieldCodigoAvaliacao.setFocusable(false);

        jTextFieldCodigoFormulario.setEditable(false);
        jTextFieldCodigoFormulario.setEnabled(false);
        jTextFieldCodigoFormulario.setFocusable(false);

        jComboBoxIntroducao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxDominio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxMetodologia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxSeguranca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxRecurso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxDicatica.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxPostura.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxPlanejamento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxTempo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxMotivacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        jComboBoxDiccao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Conceito", "Excelente", "Ótimo", "Bom", "Regular", "Ruim" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel12)
                        .addGap(15, 15, 15)
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel17))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(85, 85, 85)
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel22)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 150, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTextFieldCodigoAvaliacao, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldCodigoFormulario, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(64, 64, 64))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBoxIntroducao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxDominio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxMetodologia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxSeguranca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxRecurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxDicatica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxPostura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxPlanejamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxTempo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxMotivacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxDiccao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextFieldDiccao1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldMotivacao1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldTempo1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldPlanejamento1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldPostura1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldDidatica1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldRecurso1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldSeguranca1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldMetodlogia1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldDominio1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                    .addComponent(jTextFieldIntroducao1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14)
                        .addComponent(jLabel15)
                        .addComponent(jLabel16)
                        .addComponent(jLabel17)
                        .addComponent(jTextFieldCodigoAvaliacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel19)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22)
                            .addComponent(jLabel18)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jTextFieldCodigoFormulario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldIntroducao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxIntroducao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldDominio1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxDominio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldMetodlogia1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxMetodologia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldSeguranca1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxSeguranca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldRecurso1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxRecurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldDidatica1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxDicatica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldPostura1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxPostura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldPlanejamento1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxPlanejamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextFieldTempo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxTempo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldMotivacao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxMotivacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextFieldDiccao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxDiccao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(71, 71, 71))
        );

        jToolBar1.setBorder(null);
        jToolBar1.setFloatable(false);

        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Novo.png"))); // NOI18N
        btnNovo.setText("Novo");
        btnNovo.setFocusable(false);
        btnNovo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });
        jToolBar1.add(btnNovo);
        jToolBar1.add(jSeparator1);

        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Salvar.png"))); // NOI18N
        btnSalvar.setFocusable(false);
        btnSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnSalvar.setLabel("Salvar");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnSalvar);
        jToolBar1.add(jSeparator3);

        btnEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Editar.png"))); // NOI18N
        btnEditar.setText("Editar");
        btnEditar.setFocusable(false);
        btnEditar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnEditar);
        jToolBar1.add(jSeparator2);

        btnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Excluir.png"))); // NOI18N
        btnExcluir.setText("Excluir");
        btnExcluir.setFocusable(false);
        btnExcluir.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });
        jToolBar1.add(btnExcluir);
        jToolBar1.add(jSeparator5);

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Cancelar.png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.setFocusable(false);
        btnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnCancelar);
        jToolBar1.add(jSeparator4);

        btnFechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Sair.png"))); // NOI18N
        btnFechar.setText("Fechar");
        btnFechar.setFocusable(false);
        btnFechar.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        btnFechar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnFechar.setVerifyInputWhenFocusTarget(false);
        btnFechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFecharActionPerformed(evt);
            }
        });
        jToolBar1.add(btnFechar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            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)
                .addContainerGap(16, Short.MAX_VALUE))
            .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 352, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

private void btnFecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFecharActionPerformed
    // TODO add your handling code here:
    GerenciadorOperacional.removeFrame();
}//GEN-LAST:event_btnFecharActionPerformed

private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
    // TODO add your handling code here:
    limpaCampos();
   
    JButton[] desativaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, jButtonConsultar};
    habilitaBotoes(desativaBotoes, false);

    JButton[] ativaBotoes = {btnNovo, btnFechar};
    habilitaBotoes(ativaBotoes, true);
   
    habilitaCampos(false);
   
    modo = Modo.Navegacao;
}//GEN-LAST:event_btnCancelarActionPerformed

private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
    // TODO add your handling code here:
    FormularioAvaliacaoController formularioCtrl = new FormularioAvaliacaoController();
    String codigoFormulario = jTextFieldCodigoFormulario.getText();
    String codigoAvaliacao = jTextFieldCodigoAvaliacao.getText();
    Object[] opcoes = {"Sim", "Não"};
    int confirma = JOptionPane.showOptionDialog(null, Strings.confirmaExcluir, Strings.tituloExcluir, JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, opcoes, opcoes[0]);
    if (confirma == 0) {
        if (formularioCtrl.excluir(codigoFormulario, codigoAvaliacao)) {
            JOptionPane.showMessageDialog(this, Strings.operacaoSucesso);
        } else {
            JOptionPane.showMessageDialog(this, Strings.operacaoFracasso, Strings.tituloMessage, JOptionPane.ERROR_MESSAGE);
        }
    }
    modo = Modo.Navegacao;
}//GEN-LAST:event_btnExcluirActionPerformed

private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
    // TODO add your handling code here:
    habilitaCampos(true);
    jButtonConsultar.requestFocus();
   
    JButton[] desativaBotoes = {btnNovo, btnEditar, btnFechar, btnExcluir};
    habilitaBotoes(desativaBotoes, false);

    JButton[] ativaBotoes = {btnSalvar, btnCancelar};
    habilitaBotoes(ativaBotoes, true);
   
    jTextFieldCandidatoAvaliacao.setEnabled(false);
    jButtonConsultar.setEnabled(false);
   
    modo = Modo.Edicao;
}//GEN-LAST:event_btnEditarActionPerformed

private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
    // TODO add your handling code here:
    boolean podeSalvar = true;
    boolean salvou = false;
    //System.out.println("Salvar");
    int codigoFormulario = Integer.parseInt(jTextFieldCodigoFormulario.getText());
    int codigoAvaliacao = Integer.parseInt(jTextFieldCodigoAvaliacao.getText());
   
    if (jTextFieldCandidatoAvaliacao.getText().isEmpty()) {
        podeSalvar = false;
        JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Candidato"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
        jButtonConsultar.requestFocus();
    }else
    if (jTextFieldAvaliador.getText().isEmpty()) {
        podeSalvar = false;
        JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Avaliador"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
        jTextFieldAvaliador.requestFocus();
    }

    if (podeSalvar) {
        ArrayList<AvaliacaoItem> listaDeItens = new ArrayList<AvaliacaoItem>();
        AvaliacaoItem item = new AvaliacaoItem();
        item = new AvaliacaoItem(1, codigoFormulario, codigoAvaliacao,
                Strings.listaDeDescricao[0], jComboBoxIntroducao.getSelectedItem().toString(), jTextFieldIntroducao1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(2, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[1], jComboBoxDominio.getSelectedItem().toString(), jTextFieldDominio1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(3, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[2], jComboBoxMetodologia.getSelectedItem().toString(), jTextFieldMetodlogia1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(4, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[3], jComboBoxSeguranca.getSelectedItem().toString(), jTextFieldSeguranca1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(5, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[4], jComboBoxRecurso.getSelectedItem().toString(), jTextFieldRecurso1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(6, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[5], jComboBoxDicatica.getSelectedItem().toString(), jTextFieldDidatica1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(7, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[6], jComboBoxPostura.getSelectedItem().toString(), jTextFieldPostura1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(8, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[7], jComboBoxPlanejamento.getSelectedItem().toString(), jTextFieldPlanejamento1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(9, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[8], jComboBoxTempo.getSelectedItem().toString(), jTextFieldTempo1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(10, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[9], jComboBoxMotivacao.getSelectedItem().toString(), jTextFieldMotivacao1.getText());
        listaDeItens.add(item);
        item = new AvaliacaoItem(11, codigoFormulario,codigoAvaliacao,
                Strings.listaDeDescricao[10], jComboBoxDiccao.getSelectedItem().toString(), jTextFieldDiccao1.getText());
        listaDeItens.add(item);

        FormularioAvaliacaoController fomularioCtrl = new FormularioAvaliacaoController();
        Avaliacao avaliacao = new Avaliacao();
        avaliacao.setCodigoAvaliacao(codigoAvaliacao);

        FormularioAvaliacao formulario = new FormularioAvaliacao();
        formulario.setCodigoFormularioAvaliacao(codigoFormulario);
        formulario.setNomeAvaliador(jTextFieldAvaliador.getText());
        formulario.setAvaliacao(avaliacao);
        formulario.setListaDeItens(listaDeItens);

        if (modo.equals(Modo.Inclusao)) {
            salvou = fomularioCtrl.salvar(formulario);
        } else {
            salvou = fomularioCtrl.atualizar(formulario);
        }

        if (salvou) {
            Object[] opcoes = {"Sim", "Não"};
            int confirma = JOptionPane.showOptionDialog(null, Strings.operacaoSucesso + "\n" + Strings.confirmaFechamento, Strings.tituloProcesso,JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, opcoes, opcoes[0]);
            if (confirma != 0) {
                GerenciadorOperacional.removeFrame();
            }           
        }else{
            JOptionPane.showMessageDialog(this, Strings.operacaoFracasso);
        }
    }
}//GEN-LAST:event_btnSalvarActionPerformed

private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
    // TODO add your handling code here:   
    limpaCampos()
    jButtonConsultar.requestFocus();
   
    JButton[] ativaBotoes = {btnSalvar, btnCancelar, jButtonConsultar};
    habilitaBotoes(ativaBotoes, true);
   
    JButton[] desativaBotoes = {btnFechar, btnEditar, btnExcluir, btnNovo};
    habilitaBotoes(desativaBotoes, false);
     
    habilitaCampos(true);

    modo = Modo.Inclusao;
}//GEN-LAST:event_btnNovoActionPerformed

private void jButtonConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConsultarActionPerformed
    // TODO add your handling code here:
    if (!modo.equals(Modo.Navegacao)){
        JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
        habilitaBotoes(listaBotoes, false);
        GerenciadorOperacional.getPesquisa("formulario");       
    } else {
        JOptionPane.showMessageDialog(null, "Favor entrar em modo de edição ou inclusão.", Strings.tituloMessage, JOptionPane.INFORMATION_MESSAGE);
    }

}//GEN-LAST:event_jButtonConsultarActionPerformed
  
private void jTextFieldAvaliadorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldAvaliadorKeyPressed
// TODO add your handling code here:
    if (jTextFieldAvaliador.getText().equals("")) {
        btnSalvar.setEnabled(false);
    } else {
        btnSalvar.setEnabled(true);
    }
}//GEN-LAST:event_jTextFieldAvaliadorKeyPressed

private void jTextFieldAvaliadorKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldAvaliadorKeyReleased
// TODO add your handling code here:
    if (jTextFieldAvaliador.getText().equals("")) {
        btnSalvar.setEnabled(false);
    } else {
        btnSalvar.setEnabled(true);
    }
}//GEN-LAST:event_jTextFieldAvaliadorKeyReleased

private void jTextFieldAvaliadorKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldAvaliadorKeyTyped
// TODO add your handling code here:
    if (jTextFieldAvaliador.getText().equals("")) {
        btnSalvar.setEnabled(false);
    } else {
        btnSalvar.setEnabled(true);
    }
}//GEN-LAST:event_jTextFieldAvaliadorKeyTyped
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private static javax.swing.JButton btnCancelar;
    private static javax.swing.JButton btnEditar;
    private static javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnFechar;
    private static javax.swing.JButton btnNovo;
    private static javax.swing.JButton btnSalvar;
    private static javax.swing.JButton jButtonConsultar;
    private javax.swing.JComboBox jComboBoxDicatica;
    private javax.swing.JComboBox jComboBoxDiccao;
    private javax.swing.JComboBox jComboBoxDominio;
    private javax.swing.JComboBox jComboBoxIntroducao;
    private javax.swing.JComboBox jComboBoxMetodologia;
    private javax.swing.JComboBox jComboBoxMotivacao;
    private javax.swing.JComboBox jComboBoxPlanejamento;
    private javax.swing.JComboBox jComboBoxPostura;
    private javax.swing.JComboBox jComboBoxRecurso;
    private javax.swing.JComboBox jComboBoxSeguranca;
    private javax.swing.JComboBox jComboBoxTempo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelCandidato;
    private javax.swing.JLabel jLabelCodigoAvaliacao1;
    private static javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private static javax.swing.JFormattedTextField jTextFieldAvaliador;
    private static javax.swing.JFormattedTextField jTextFieldCandidatoAvaliacao;
    private static javax.swing.JTextField jTextFieldCodigoAvaliacao;
    private static javax.swing.JTextField jTextFieldCodigoFormulario;
    private javax.swing.JFormattedTextField jTextFieldDiccao1;
    private javax.swing.JFormattedTextField jTextFieldDidatica1;
    private javax.swing.JFormattedTextField jTextFieldDominio1;
    private javax.swing.JFormattedTextField jTextFieldIntroducao1;
    private javax.swing.JFormattedTextField jTextFieldMetodlogia1;
    private javax.swing.JFormattedTextField jTextFieldMotivacao1;
    private javax.swing.JFormattedTextField jTextFieldPlanejamento1;
    private javax.swing.JFormattedTextField jTextFieldPostura1;
    private javax.swing.JFormattedTextField jTextFieldRecurso1;
    private javax.swing.JFormattedTextField jTextFieldSeguranca1;
    private javax.swing.JFormattedTextField jTextFieldTempo1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of view.FormularioView

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.