/*
* DocenteView.java
*
* Created on 13 de Setembro de 2008, 11:48
*/
package view;
import controller.DocenteController;
import controller.operating.GerenciadorOperacional;
import java.awt.Component;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import model.Docente;
import model.Endereco;
import model.Pessoa;
import controller.operating.Strings;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import util.DocumentoDeTamanhoFixo;
/**
*
* @author Consult
*/
public class DocenteView extends javax.swing.JInternalFrame {
private enum Modo {Edicao, Navegacao};
private Modo modo;
/** Creates new form DocenteView */
public DocenteView() {
initComponents();
carregaTabela();
modo = Modo.Navegacao;
}
private void habilitaCampos(Boolean pValor) {
// TODO add your handling code here:
Component[] c = jPanel1.getComponents();
jTextAreaObservacao.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("-");
}
}
jTextAreaObservacao.setText("");
}
private 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("Nome");
elementosDaTabela.addElement("E-mail");
elementosDaTabela.addElement("Celular");
elementosDaTabela.addElement("Lattes");
DocenteController docenteCtrl = new DocenteController();
DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela, 0);
modeloTabela = docenteCtrl.getTableDocentes(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() {
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jToolBar1 = new javax.swing.JToolBar();
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();
btnCancelarAprovacao = new javax.swing.JButton();
jSeparator1 = new javax.swing.JToolBar.Separator();
btnFechar = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabelObservacao = new javax.swing.JLabel();
jLabelCodigo = new javax.swing.JLabel();
jLabelNome = new javax.swing.JLabel();
jLabelCidade = new javax.swing.JLabel();
jLabelEmail = new javax.swing.JLabel();
jLabelCelular = new javax.swing.JLabel();
jLabelBairro = new javax.swing.JLabel();
jLabelEndereco = new javax.swing.JLabel();
jLabelTelefone = new javax.swing.JLabel();
jLabelCPF = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextAreaObservacao = new javax.swing.JTextArea();
jLabelUF = new javax.swing.JLabel();
jLabelRG = new javax.swing.JLabel();
jLabelNumero = new javax.swing.JLabel();
jLabelCEP = new javax.swing.JLabel();
jLabelLattes = new javax.swing.JLabel();
jTextFieldNome = new javax.swing.JFormattedTextField();
jComboBoxUf = new javax.swing.JComboBox();
jComboBoxCidade = new javax.swing.JComboBox();
jTextFieldCPF = new javax.swing.JFormattedTextField();
jTextFieldRG = new javax.swing.JFormattedTextField();
jTextFieldCodigoDocente = new javax.swing.JTextField();
jTextFieldTelefone = new javax.swing.JFormattedTextField();
jTextFieldCelular = new javax.swing.JFormattedTextField();
jTextFieldEmail = new javax.swing.JFormattedTextField();
jTextFieldLattes = new javax.swing.JFormattedTextField();
jTextFieldEndereco = new javax.swing.JFormattedTextField();
jTextFieldNumero = new javax.swing.JFormattedTextField();
jLabelNascimento = new javax.swing.JLabel();
jTextFieldNascimento = new javax.swing.JFormattedTextField();
jTextFieldBairro = new javax.swing.JFormattedTextField();
jTextFieldCEP = new javax.swing.JFormattedTextField();
jLabel1 = new javax.swing.JLabel();
jTextFieldComplemento = new javax.swing.JTextField();
jTextFieldTitulacao = new javax.swing.JFormattedTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextFieldDataAprovacao = new javax.swing.JFormattedTextField();
jTextFieldUsuarioResponsavel = new javax.swing.JFormattedTextField();
jLabel4 = new javax.swing.JLabel();
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
setTitle("Professor");
setAutoscrolls(true);
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);
}
});
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);
}
});
jScrollPane2.setViewportView(jTable1);
jToolBar1.setBorder(null);
jToolBar1.setFloatable(false);
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);
btnCancelarAprovacao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Usuario.png"))); // NOI18N
btnCancelarAprovacao.setText("Desvincular");
btnCancelarAprovacao.setFocusable(false);
btnCancelarAprovacao.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
btnCancelarAprovacao.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnCancelarAprovacao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelarAprovacaoActionPerformed(evt);
}
});
jToolBar1.add(btnCancelarAprovacao);
jToolBar1.add(jSeparator1);
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);
jLabelObservacao.setText("Observações:");
jLabelCodigo.setText("Código:");
jLabelNome.setText("Nome:");
jLabelCidade.setText("Cidade:");
jLabelEmail.setText("E-Mail:");
jLabelCelular.setText("Celular:");
jLabelBairro.setText("Bairro:");
jLabelEndereco.setText("Endereço:");
jLabelTelefone.setText("Telefone:");
jLabelCPF.setText("CPF:");
jTextAreaObservacao.setColumns(20);
jTextAreaObservacao.setFont(new java.awt.Font("Arial", 0, 12));
jTextAreaObservacao.setLineWrap(true);
jTextAreaObservacao.setRows(5);
jTextAreaObservacao.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jTextAreaObservacaoKeyPressed(evt);
}
});
jScrollPane1.setViewportView(jTextAreaObservacao);
jLabelUF.setText("UF:");
jLabelRG.setText("RG:");
jLabelNumero.setText("N°:");
jLabelCEP.setText("CEP:");
jLabelLattes.setText("Lattes:");
jTextFieldNome.setDocument(new DocumentoDeTamanhoFixo(20));
jTextFieldNome.setName("Nome"); // NOI18N
jComboBoxUf.setModel(new javax.swing.DefaultComboBoxModel(Strings.comboUFsBrasil));
jComboBoxCidade.setModel(new javax.swing.DefaultComboBoxModel(Strings.comboCidades));
try {
jTextFieldCPF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldCPF.setName("CPF"); // NOI18N
jTextFieldRG.setName("RG(Registro Geral)"); // NOI18N
jTextFieldCodigoDocente.setEditable(false);
jTextFieldCodigoDocente.setEnabled(false);
try {
jTextFieldTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldTelefone.setName("Telefone"); // NOI18N
try {
jTextFieldCelular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldCelular.setName("Celular"); // NOI18N
jTextFieldEmail.setName("E-Mail"); // NOI18N
jTextFieldEmail.setSelectionEnd(1);
jTextFieldLattes.setName("Currículo Lattes"); // NOI18N
jTextFieldEndereco.setName("Endereço"); // NOI18N
jTextFieldNumero.setName("Número"); // NOI18N
jLabelNascimento.setText("Nascimento:");
try {
jTextFieldNascimento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldNascimento.setName("Nascimento"); // NOI18N
jTextFieldBairro.setName("Bairro"); // NOI18N
try {
jTextFieldCEP.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldCEP.setName("Cep"); // NOI18N
jLabel1.setText("Complemento:");
jLabel2.setText("Titulação:");
jLabel3.setText("Aprovação:");
try {
jTextFieldDataAprovacao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldDataAprovacao.setEnabled(false);
jTextFieldUsuarioResponsavel.setEnabled(false);
jLabel4.setText("Responsável:");
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(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelCodigo)
.addComponent(jLabelCPF)
.addComponent(jLabelTelefone)
.addComponent(jLabel2))
.addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldCodigoDocente, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabelNome)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextFieldNome, javax.swing.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextFieldTelefone, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextFieldCPF, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelRG, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelCelular))
.addGap(7, 7, 7)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldRG, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addComponent(jLabelNascimento)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldCelular, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
.addGap(92, 92, 92)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldDataAprovacao, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextFieldTitulacao, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
.addComponent(jTextFieldLattes, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(jLabelEmail))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextFieldUsuarioResponsavel)
.addComponent(jTextFieldEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE))))
.addContainerGap())
.addComponent(jLabelLattes)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabelObservacao)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelEndereco)
.addComponent(jLabelBairro)
.addComponent(jLabelCEP))
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldCEP, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabelCidade)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBoxCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
.addComponent(jLabelUF)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBoxUf, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldBairro, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
.addGap(10, 10, 10)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabelNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap())))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jComboBoxUf, jTextFieldNumero});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabelNumero, jLabelUF});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabelNascimento});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelCodigo)
.addComponent(jTextFieldCodigoDocente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelNome)
.addComponent(jTextFieldNome, 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(jLabelCPF)
.addComponent(jTextFieldNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelRG, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelNascimento)
.addComponent(jTextFieldRG, 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(jLabelTelefone)
.addComponent(jTextFieldTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelCelular)
.addComponent(jTextFieldDataAprovacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jTextFieldCelular, 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(jLabel2)
.addComponent(jTextFieldTitulacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldUsuarioResponsavel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelLattes)
.addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldLattes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelEmail))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelEndereco)
.addComponent(jLabelNumero)
.addComponent(jTextFieldEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldNumero, 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(jLabelBairro)
.addComponent(jTextFieldComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelCEP)
.addComponent(jTextFieldCEP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBoxUf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelUF)
.addComponent(jComboBoxCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelObservacao)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(8, 8, 8))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
.addComponent(jPanel1, 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, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(11, 11, 11)
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
);
setBounds(10, 10, 551, 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();
DocenteController docenteCtrl = new DocenteController();
int linhaSelecionada = jTable1.getSelectedRow();
String codigo = String.valueOf(jTable1.getValueAt(linhaSelecionada, 0));
Docente docente = docenteCtrl.getDocente(codigo);
jTextFieldCodigoDocente.setText(String.valueOf(docente.getCodigoPessoa()));
jTextFieldNome.setText(docente.getNome());
jTextFieldEmail.setText(docente.getEmail());
jTextFieldRG.setText(docente.getRg());
jTextFieldCelular.setText(docente.getCelular());
jTextFieldBairro.setText(docente.getEndereco().getBairro());
jTextFieldCEP.setText(docente.getEndereco().getCep());
jTextFieldComplemento.setText(docente.getEndereco().getComplemento());
jTextFieldCPF.setText(docente.getCpf());
jTextFieldEndereco.setText(docente.getEndereco().getLogradouro());
jTextFieldLattes.setText(docente.getLattes());
jTextFieldNascimento.setText(docente.getNascimento());
jTextFieldNumero.setText(docente.getEndereco().getNumero());
jTextFieldTelefone.setText(docente.getTelefone());
jComboBoxUf.setSelectedItem(docente.getEndereco().getUf());
jComboBoxCidade.setSelectedItem(docente.getEndereco().getNomeCidade());
jTextAreaObservacao.setText(docente.getObservacao());
jTextFieldUsuarioResponsavel.setText(docente.getUsuario());
jTextFieldDataAprovacao.setText(docente.getDataAprovacao());
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 btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
// TODO add your handling code here:
JButton[] desativaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, btnCancelarAprovacao};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnFechar};
habilitaBotoes(ativaBotoes, true);
limpaCampos();
habilitaCampos(false);
jTable1.setEnabled(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);
JButton[] listaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, btnCancelarAprovacao};
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);
jTextFieldNome.requestFocus();
JButton[] desativaBotoes = {btnEditar, btnFechar, btnExcluir, btnCancelarAprovacao};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnSalvar, btnCancelar};
habilitaBotoes(ativaBotoes, true);
jTextFieldCodigoDocente.setEnabled(false);
jTable1.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:
DocenteController candidatoCtrl = new DocenteController();
String codigoSelecionado = jTextFieldCodigoDocente.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 (candidatoCtrl.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;
/**
* Esse trecho aqui valida todos os campos
* mas aqui so precisa fazer no nome
* então tem que apagar isso aqui
* e ai testar so pro nome
*/
if (jTextFieldNome.getText().isEmpty()) {
podeSalvar = false;
JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Nome"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
jTextFieldNome.requestFocus();
}
if (podeSalvar) {
Pessoa pessoa = new Pessoa();
pessoa.setCodigoPessoa(Integer.parseInt(jTextFieldCodigoDocente.getText()));
Endereco endereco = new Endereco(
jTextFieldEndereco.getText(),
jTextFieldNumero.getText(),
jTextFieldBairro.getText(),
jTextFieldCEP.getText(),
jTextFieldComplemento.getText(),
jComboBoxCidade.getSelectedItem().toString(),
jComboBoxUf.getSelectedItem().toString(),
pessoa);
Docente docente = new Docente();
docente.setCodigoPessoa(Integer.parseInt(jTextFieldCodigoDocente.getText()));
docente.setCodigoCandidato(Integer.parseInt(jTextFieldCodigoDocente.getText()));
docente.setCodigoDocente(Integer.parseInt(jTextFieldCodigoDocente.getText()));
docente.setNome(jTextFieldNome.getText());
docente.setEmail(jTextFieldEmail.getText());
docente.setTelefone(jTextFieldTelefone.getText());
docente.setCelular(jTextFieldCelular.getText());
docente.setRg(jTextFieldRG.getText());
docente.setCpf(jTextFieldCPF.getText());
docente.setNascimento(jTextFieldNascimento.getText());
docente.setLattes(jTextFieldLattes.getText());
docente.setObservacao(jTextAreaObservacao.getText());
docente.setEndereco(endereco);
DocenteController candidatoController = new DocenteController();
salvou = candidatoController.atualizar(docente);
if (salvou) {
JButton[] desativaBotoes = {btnSalvar, btnCancelar, btnExcluir, btnEditar, btnCancelarAprovacao};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnFechar};
habilitaBotoes(ativaBotoes, true);
habilitaCampos(false);
jTable1.setEnabled(true);
JOptionPane.showMessageDialog(this, Strings.operacaoSucesso);
carregaTabela();
modo = Modo.Navegacao;
}
}
}//GEN-LAST:event_btnSalvarActionPerformed
private void jTextAreaObservacaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextAreaObservacaoKeyPressed
// 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_jTextAreaObservacaoKeyPressed
private void btnCancelarAprovacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarAprovacaoActionPerformed
// TODO add your handling code here:
DocenteController candidatoCtrl = new DocenteController();
String codigoSelecionado = jTextFieldCodigoDocente.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 (candidatoCtrl.excluir(codigoSelecionado)) {
JOptionPane.showMessageDialog(this, Strings.operacaoSucesso);
carregaTabela();
} else {
JOptionPane.showMessageDialog(this, Strings.operacaoFracasso, Strings.tituloMessage, JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_btnCancelarAprovacaoActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancelar;
private javax.swing.JButton btnCancelarAprovacao;
private javax.swing.JButton btnEditar;
private javax.swing.JButton btnExcluir;
private javax.swing.JButton btnFechar;
private javax.swing.JButton btnSalvar;
private javax.swing.JComboBox jComboBoxCidade;
private javax.swing.JComboBox jComboBoxUf;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabelBairro;
private javax.swing.JLabel jLabelCEP;
private javax.swing.JLabel jLabelCPF;
private javax.swing.JLabel jLabelCelular;
private javax.swing.JLabel jLabelCidade;
private javax.swing.JLabel jLabelCodigo;
private javax.swing.JLabel jLabelEmail;
private javax.swing.JLabel jLabelEndereco;
private javax.swing.JLabel jLabelLattes;
private javax.swing.JLabel jLabelNascimento;
private javax.swing.JLabel jLabelNome;
private javax.swing.JLabel jLabelNumero;
private javax.swing.JLabel jLabelObservacao;
private javax.swing.JLabel jLabelRG;
private javax.swing.JLabel jLabelTelefone;
private javax.swing.JLabel jLabelUF;
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 jTextAreaObservacao;
private javax.swing.JFormattedTextField jTextFieldBairro;
private javax.swing.JFormattedTextField jTextFieldCEP;
private javax.swing.JFormattedTextField jTextFieldCPF;
private javax.swing.JFormattedTextField jTextFieldCelular;
private javax.swing.JTextField jTextFieldCodigoDocente;
private javax.swing.JTextField jTextFieldComplemento;
private javax.swing.JFormattedTextField jTextFieldDataAprovacao;
private javax.swing.JFormattedTextField jTextFieldEmail;
private javax.swing.JFormattedTextField jTextFieldEndereco;
private javax.swing.JFormattedTextField jTextFieldLattes;
private javax.swing.JFormattedTextField jTextFieldNascimento;
private javax.swing.JFormattedTextField jTextFieldNome;
private javax.swing.JFormattedTextField jTextFieldNumero;
private javax.swing.JFormattedTextField jTextFieldRG;
private javax.swing.JFormattedTextField jTextFieldTelefone;
private javax.swing.JFormattedTextField jTextFieldTitulacao;
private javax.swing.JFormattedTextField jTextFieldUsuarioResponsavel;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables
}