/*
* EstagiarioView.java
*
* Created on 13 de Setembro de 2008, 11:48
*/
package view;
import controller.AulaAvaliativaController;
import controller.CandidatoController;
import controller.DocenteController;
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.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import model.Candidato;
import model.AulaAvaliativa;
/**
*
* @author Consult
*/
public class AulaAvaliativaView extends javax.swing.JInternalFrame {
/** Creates new form AulaAvaliativaView */
private enum Modo {Edicao, Inclusao, Navegacao};
private Modo modo;
public FormPesquisa pesquisa;
private String valorAnterior;
/** Creates new form CandidatoView */
public AulaAvaliativaView() {
initComponents();
carregaTabela();
modo = Modo.Navegacao;
}
public static void retornaBusca(){
jTextFieldCodigoCandidato.setText(GerenciadorOperacional.getCodigo());
jTextFieldNomeCandidato.setText(GerenciadorOperacional.getDescricao());
JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
habilitaBotoes(listaBotoes, true);
}
public static void cancelaBusca(){
JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
habilitaBotoes(listaBotoes, true);
}
private void habilitaCampos(Boolean pValor) {
// TODO add your handling code here:
Component[] c = jPanel1.getComponents();
jTextAreaConteudo.setEnabled(pValor);
for (int i = 0; i < c.length; i++) {
if ((c[i] instanceof JTextField)) {
c[i].setEnabled(pValor);
}
if (c[i] instanceof JComboBox){
c[i].setEnabled(pValor);
}
}
}
private void limpaCampos() {
Component[] c = jPanel1.getComponents();
for (int i = 0; i < c.length; i++) {
if (c[i] instanceof JTextField) {
((JTextField) c[i]).setText("");
}
if (c[i] instanceof JComboBox){
((JComboBox)c[i]).setSelectedItem("Em Processo");
}
}
jTextAreaConteudo.setText("");
}
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 carregaTabela(){
Vector<String> elementosDaTabela = new Vector<String>();
elementosDaTabela.addElement("Código");
elementosDaTabela.addElement("Local");
elementosDaTabela.addElement("Nome");
elementosDaTabela.addElement("Data");
elementosDaTabela.addElement("Resutado");
AulaAvaliativaController entrevistaCtrl= new AulaAvaliativaController();
DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela,0);
modeloTabela = entrevistaCtrl.getTableAulasAvaliativas(modeloTabela);
jTable1.setModel(modeloTabela);
}
/** 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();
jLabelData = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextAreaConteudo = new javax.swing.JTextArea();
jLabelDuracao = new javax.swing.JLabel();
jButtonConsultar = new javax.swing.JButton();
jLabelLocal = new javax.swing.JLabel();
jTextFieldNomeCandidato = new javax.swing.JFormattedTextField();
jTextFieldData = new javax.swing.JFormattedTextField();
jTextFieldDuracao = new javax.swing.JFormattedTextField();
jTextFieldLocal = new javax.swing.JFormattedTextField();
jLabel1 = new javax.swing.JLabel();
jTextFieldCodigoAulaAvaliativa = new javax.swing.JTextField();
jTextFieldCodigoCandidato = new javax.swing.JTextField();
jComboBoxResultado = new javax.swing.JComboBox();
jButtonReprocessar = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
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("Aula Avaliativa");
addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
formInternalFrameOpened(evt);
}
});
jLabelCandidato.setText("Nome:");
jLabelData.setText("Data:");
jTextAreaConteudo.setColumns(20);
jTextAreaConteudo.setFont(new java.awt.Font("Arial", 0, 12));
jTextAreaConteudo.setLineWrap(true);
jTextAreaConteudo.setRows(5);
jTextAreaConteudo.setText("\n");
jTextAreaConteudo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Conteúdo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(51, 51, 51))); // NOI18N
jTextAreaConteudo.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jTextAreaConteudoKeyPressed(evt);
}
});
jScrollPane1.setViewportView(jTextAreaConteudo);
jLabelDuracao.setText("Duração:");
jButtonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Pesquisar.png"))); // NOI18N
jButtonConsultar.setText("Candidato");
jButtonConsultar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonConsultarActionPerformed(evt);
}
});
jLabelLocal.setText("Local:");
jTextFieldNomeCandidato.setFocusable(false);
jTextFieldNomeCandidato.setName("Nome do Candidato"); // NOI18N
try {
jTextFieldData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldData.setName("Data"); // NOI18N
try {
jTextFieldDuracao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter(" ##:##")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldDuracao.setName("Duração"); // NOI18N
jTextFieldLocal.setName("Local"); // NOI18N
jLabel1.setText("Resultado:");
jTextFieldCodigoAulaAvaliativa.setEditable(false);
jTextFieldCodigoAulaAvaliativa.setEnabled(false);
jTextFieldCodigoAulaAvaliativa.setFocusable(false);
jTextFieldCodigoCandidato.setEditable(false);
jComboBoxResultado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Em Processo", "Em Espera", "Não Aprovado", "Aprovado" }));
jComboBoxResultado.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxResultadoActionPerformed(evt);
}
});
jButtonReprocessar.setText("Reprocessar");
jButtonReprocessar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonReprocessarActionPerformed(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()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelData, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelCandidato))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldData)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldCodigoAulaAvaliativa, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addComponent(jTextFieldCodigoCandidato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(8, 8, 8)
.addComponent(jLabelDuracao, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldDuracao, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBoxResultado, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jTextFieldNomeCandidato, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButtonReprocessar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonConsultar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(jTextFieldLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 483, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 521, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabelCandidato, jLabelData, jLabelLocal});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelCandidato)
.addComponent(jTextFieldNomeCandidato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonConsultar))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelData)
.addComponent(jComboBoxResultado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(jTextFieldData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonReprocessar)
.addComponent(jTextFieldCodigoAulaAvaliativa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldCodigoCandidato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldDuracao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelDuracao, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelLocal, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldLocal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Código", "Candidato", "Data", "Resultado"
}
));
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTable1MouseClicked(evt);
}
});
jScrollPane2.setViewportView(jTable1);
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)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 548, 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.RELATED)
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
);
setBounds(10, 10, 558, 544);
}// </editor-fold>//GEN-END:initComponents
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
// TODO add your handling code here:
if(modo.equals(Modo.Navegacao)){
limpaCampos();
AulaAvaliativaController entrevistaCtrl = new AulaAvaliativaController();
int linhaSelecionada = jTable1.getSelectedRow();
String codigo = String.valueOf(jTable1.getValueAt(linhaSelecionada, 0));
AulaAvaliativa entrevista = entrevistaCtrl.getAulaAvaliativa(codigo);
jTextFieldCodigoAulaAvaliativa.setText(String.valueOf(entrevista.getCodigoAulaAvaliativa()));
jTextFieldCodigoCandidato.setText(String.valueOf(entrevista.getCandidato().getCodigoPessoa()));
jTextFieldData.setText(entrevista.getData());
jTextFieldLocal.setText(entrevista.getLocal());
jTextFieldNomeCandidato.setText(entrevista.getCandidato().getNome());
jTextFieldDuracao.setText(entrevista.getDuracao());
jTextAreaConteudo.setText(entrevista.getConteudo());
jComboBoxResultado.setSelectedItem(entrevista.getResultado());
valorAnterior = jComboBoxResultado.getSelectedItem().toString();
JButton[] listaBotoes = {btnEditar, btnExcluir};
habilitaBotoes(listaBotoes, true);
}
evt.consume();
}//GEN-LAST:event_jTable1MouseClicked
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 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, jButtonReprocessar};
habilitaBotoes(desativaBotoes, false);
AulaAvaliativaController entrevistaCtrl = new AulaAvaliativaController();
jTextFieldCodigoAulaAvaliativa.setText(entrevistaCtrl.getNovoCodigo());
habilitaCampos(true);
jTable1.setEnabled(false);
jTable1.setFocusable(false);
jComboBoxResultado.setEnabled(false);
modo = Modo.Inclusao;
}//GEN-LAST:event_btnNovoActionPerformed
private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
// TODO add your handling code here:
JButton[] desativaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, jButtonConsultar, jButtonReprocessar};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnNovo, btnFechar};
habilitaBotoes(ativaBotoes, true);
limpaCampos();
habilitaCampos(false);
jTable1.setEnabled(true);
jTable1.setFocusable(true);
modo = Modo.Navegacao;
}//GEN-LAST:event_btnCancelarActionPerformed
private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
// TODO add your handling code here:
habilitaCampos(false);
if(GerenciadorDeConfiguracoesDoSistema.getUsarConexao()){
jTextFieldCodigoAulaAvaliativa.setVisible(false);
jTextFieldCodigoCandidato.setVisible(false);
}
JButton[] listaBotoes = {btnSalvar, btnCancelar, btnEditar,btnExcluir,jButtonConsultar, jButtonReprocessar};
habilitaBotoes(listaBotoes, false);
modo = Modo.Navegacao;
}//GEN-LAST:event_formInternalFrameOpened
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, jButtonConsultar};
habilitaBotoes(ativaBotoes, true);
jTextFieldCodigoCandidato.setEnabled(false);
jTable1.setEnabled(false);
jTable1.setFocusable(false);
if(jComboBoxResultado.getSelectedItem().equals("Aprovado")){
jComboBoxResultado.setEnabled(false);
jButtonReprocessar.setEnabled(true);
}else{
jComboBoxResultado.setEnabled(true);
jButtonReprocessar.setEnabled(false);
}
modo = Modo.Edicao;
}//GEN-LAST:event_btnEditarActionPerformed
private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
// TODO add your handling code here:
AulaAvaliativaController entrevistaCtrl = new AulaAvaliativaController();
String codigoSelecionado = jTextFieldCodigoAulaAvaliativa.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 (entrevistaCtrl.excluir(codigoSelecionado)) {
JOptionPane.showMessageDialog(this, Strings.operacaoSucesso);
carregaTabela();
} else {
JOptionPane.showMessageDialog(this, Strings.operacaoFracasso, Strings.tituloMessage, JOptionPane.ERROR_MESSAGE);
}
}
modo = Modo.Navegacao;
}//GEN-LAST:event_btnExcluirActionPerformed
private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
// TODO add your handling code here:
boolean podeSalvar = true;
boolean salvou = false;
if (jTextFieldCodigoCandidato.getText().isEmpty()) {
podeSalvar = false;
JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Candidato"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
jTextFieldNomeCandidato.requestFocus();
}else if (jTextFieldData.getText().isEmpty()) {
podeSalvar = false;
JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Data"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
jTextFieldData.requestFocus();
}
if(podeSalvar){
int codigo = Integer.parseInt(jTextFieldCodigoCandidato.getText());
Candidato candidato = new Candidato();
candidato.setCodigoCandidato(codigo);
candidato.setCodigoPessoa(codigo);
AulaAvaliativa aulaAvaliativa = new AulaAvaliativa();
aulaAvaliativa.setCodigoAulaAvaliativa(Integer.parseInt(jTextFieldCodigoAulaAvaliativa.getText()));
aulaAvaliativa.setData(jTextFieldData.getText());
aulaAvaliativa.setDuracao(jTextFieldDuracao.getText());
aulaAvaliativa.setLocal(jTextFieldLocal.getText());
aulaAvaliativa.setConteudo(jTextAreaConteudo.getText());
aulaAvaliativa.setResultado(jComboBoxResultado.getSelectedItem().toString());
aulaAvaliativa.setCandidato(candidato);
AulaAvaliativaController entrevistaCtrl = new AulaAvaliativaController();
if (modo.equals(Modo.Inclusao))
salvou = entrevistaCtrl.salvar(aulaAvaliativa);
else
salvou = entrevistaCtrl.atualizar(aulaAvaliativa);
if(salvou){
JButton[] desativaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, jButtonConsultar, jButtonReprocessar};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnNovo, btnFechar};
habilitaBotoes(ativaBotoes, true);
habilitaCampos(false);
jTable1.setEnabled(true);
jTable1.setFocusable(true);
JOptionPane.showMessageDialog(this, Strings.operacaoSucesso);
carregaTabela();
modo = Modo.Navegacao;
}
}
}//GEN-LAST:event_btnSalvarActionPerformed
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("candidato");
}else{
JOptionPane.showMessageDialog(null, Strings.mensagemErroAcesso, Strings.tituloMessage, JOptionPane.INFORMATION_MESSAGE);
}
}//GEN-LAST:event_jButtonConsultarActionPerformed
private void jTextAreaConteudoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextAreaConteudoKeyPressed
// TODO add your handling code here:
if (evt.getKeyCode() == KeyEvent.VK_TAB){
evt.consume();
KeyboardFocusManager.
getCurrentKeyboardFocusManager().focusNextComponent();
}
if (evt.getKeyCode() == KeyEvent.VK_TAB && evt.isShiftDown()){
evt.consume();
KeyboardFocusManager.
getCurrentKeyboardFocusManager().focusPreviousComponent();
}
}//GEN-LAST:event_jTextAreaConteudoKeyPressed
private void jButtonReprocessarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReprocessarActionPerformed
// TODO add your handling code here:
boolean reprocessou = false;
if(!modo.equals(Modo.Navegacao)){
Object[] opcoes = {"Sim", "Não"};
int confirma = JOptionPane.showOptionDialog(null, "Você está cancelando a aprovação deste Candidato." + Strings.confirmaProcesso, Strings.tituloProcesso, JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, opcoes, opcoes[0]);
if (confirma == 0) {
AulaAvaliativaController aulaCtrl = new AulaAvaliativaController();
reprocessou = aulaCtrl.reprocessar(jTextFieldCodigoAulaAvaliativa.getText());
DocenteController docenteCtrl = new DocenteController();
reprocessou = docenteCtrl.cancelarAprovacao(jTextFieldCodigoCandidato.getText());
if(reprocessou){
jComboBoxResultado.setSelectedItem("Em Processo");
carregaTabela();
}else{
JOptionPane.showMessageDialog(null, "Reprocessar " + Strings.mensagemErroProcesso, Strings.tituloMessage, JOptionPane.INFORMATION_MESSAGE);
}
}
}
}//GEN-LAST:event_jButtonReprocessarActionPerformed
private void jComboBoxResultadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxResultadoActionPerformed
// TODO add your handling code here:
if(jComboBoxResultado.getSelectedItem().equals("Aprovado")){
if(!modo.equals(Modo.Navegacao)){
Object[] opcoes = {"Sim", "Não"};
int confirma = JOptionPane.showOptionDialog(null, "Você está aprovando este Candidato." + Strings.confirmaProcesso, Strings.tituloProcesso,JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, opcoes, opcoes[0]);
if (confirma == 0) {
boolean aprovou = false;
CandidatoController candidatoCtrl = new CandidatoController();
aprovou = candidatoCtrl.aprovarCandidato(jTextFieldCodigoCandidato.getText());
AulaAvaliativaController aulaCtrl = new AulaAvaliativaController();
aprovou = aulaCtrl.aprovarCandidato(jTextFieldCodigoAulaAvaliativa.getText());
if(aprovou){
jComboBoxResultado.setEnabled(false);
jButtonReprocessar.setEnabled(true);
carregaTabela();
}else{
JOptionPane.showMessageDialog(null, "Aprovar Candidato " + Strings.mensagemErroProcesso, Strings.tituloMessage, JOptionPane.INFORMATION_MESSAGE);
}
}else{
jComboBoxResultado.setSelectedItem(valorAnterior);
}
}else{
jButtonReprocessar.setEnabled(false);
}
}else{
jButtonReprocessar.setEnabled(false);
}
}//GEN-LAST:event_jComboBoxResultadoActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private static javax.swing.JButton btnCancelar;
private javax.swing.JButton btnEditar;
private javax.swing.JButton btnExcluir;
private javax.swing.JButton btnFechar;
private javax.swing.JButton btnNovo;
private static javax.swing.JButton btnSalvar;
private static javax.swing.JButton jButtonConsultar;
private javax.swing.JButton jButtonReprocessar;
private javax.swing.JComboBox jComboBoxResultado;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabelCandidato;
private javax.swing.JLabel jLabelData;
private javax.swing.JLabel jLabelDuracao;
private javax.swing.JLabel jLabelLocal;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
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 javax.swing.JTable jTable1;
private javax.swing.JTextArea jTextAreaConteudo;
private javax.swing.JTextField jTextFieldCodigoAulaAvaliativa;
private static javax.swing.JTextField jTextFieldCodigoCandidato;
private javax.swing.JFormattedTextField jTextFieldData;
private javax.swing.JFormattedTextField jTextFieldDuracao;
private javax.swing.JFormattedTextField jTextFieldLocal;
private static javax.swing.JFormattedTextField jTextFieldNomeCandidato;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables
}