/*
* AvaliacaoView.java
*
* Created on 13 de Setembro de 2008, 11:48
*/
package view;
import controller.AvaliacaoController;
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 javax.swing.table.DefaultTableModel;
import controller.operating.Strings;
import java.util.Vector;
import model.Avaliacao;
import model.AulaAvaliativa;
/**
*
* @author Consult
*/
public class AvaliacaoView extends javax.swing.JInternalFrame {
/** Creates new form AvaliacaoView */
private enum Modo {Edicao, Inclusao, Navegacao};
private static Modo modo;
public FormPesquisa pesquisa;
private FormularioView formularioView;
/** Creates new form CandidatoView */
public AvaliacaoView() {
initComponents();
carregaTabela();
modo = Modo.Navegacao;
}
public static void retornaBusca() {
jTextFieldCodigoAulaAvaliativa.setText(GerenciadorOperacional.getCodigo());
jTextFieldEntrevista.setText(GerenciadorOperacional.getDescricao());
JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
habilitaBotoes(listaBotoes, true);
jTextFieldData.requestFocus();
}
public static void cancelaBusca(){
JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
habilitaBotoes(listaBotoes, true);
jTextFieldData.requestFocus();
}
private void habilitaCampos(Boolean pValor) {
// TODO add your handling code here:
Component[] c = jPanel1.getComponents();
for (int i = 0; i < c.length; i++) {
if ((c[i] instanceof JTextField)) {
c[i].setEnabled(pValor);
}
}
}
private void habilitaLabels(boolean habilita){
jLBVisualizar1.setEnabled(habilita);
jLBVisualizar2.setEnabled(habilita);
jLBVisualizar3.setEnabled(habilita);
}
private static void habilitaDesabilitaLabels() {
if (!jTextFieldAvaliador1.getText().isEmpty()) {
jLBVisualizar1.setEnabled(true);
} else {
jLBVisualizar1.setEnabled(false);
}
if (!jTextFieldAvaliador2.getText().isEmpty()) {
jLBVisualizar2.setEnabled(true);
} else {
jLBVisualizar2.setEnabled(false);
}
if (!jTextFieldAvaliador3.getText().isEmpty()) {
jLBVisualizar3.setEnabled(true);
} else {
jLBVisualizar3.setEnabled(false);
}
}
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("");
}
}
}
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("Candidato");
elementosDaTabela.addElement("Data");
elementosDaTabela.addElement("Tema");
AvaliacaoController avaliacaoCtrl = new AvaliacaoController();
DefaultTableModel modeloTabela = new DefaultTableModel(elementosDaTabela, 0);
modeloTabela = avaliacaoCtrl.getTableAvaliacoes(modeloTabela);
jTable.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();
jLabelHora = new javax.swing.JLabel();
jTextFieldCodigoAulaAvaliativa = new javax.swing.JTextField();
jButtonConsultar = new javax.swing.JButton();
jLabelTema = new javax.swing.JLabel();
jLabelDisciplina = new javax.swing.JLabel();
jTextFieldEntrevista = new javax.swing.JFormattedTextField();
jTextFieldDisciplina = new javax.swing.JFormattedTextField();
jTextFieldTema = new javax.swing.JFormattedTextField();
jTextFieldData = new javax.swing.JFormattedTextField();
jTextFieldHora = new javax.swing.JFormattedTextField();
jTextFieldCodigoAvaliacao = new javax.swing.JFormattedTextField();
jLabelAvaliador1 = new javax.swing.JLabel();
jTextFieldAvaliador1 = new javax.swing.JTextField();
jTextFieldAvaliador2 = new javax.swing.JTextField();
jTextFieldAvaliador3 = new javax.swing.JTextField();
jLBVisualizar1 = new view.componentes.JLabelButton("Visualizar Avaliação");
jLBVisualizar2 = new view.componentes.JLabelButton("Visualizar Avaliação");
jLBVisualizar3 = new view.componentes.JLabelButton("Visualizar Avaliação");
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();
jScrollPane4 = new javax.swing.JScrollPane();
jTable = new javax.swing.JTable();
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
setTitle("Avaliação");
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("Local:");
jLabelData.setText("Data:");
jLabelHora.setText("Hora:");
jTextFieldCodigoAulaAvaliativa.setEditable(false);
jTextFieldCodigoAulaAvaliativa.setEnabled(false);
jTextFieldCodigoAulaAvaliativa.setFocusable(false);
jButtonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/images/Pesquisar.png"))); // NOI18N
jButtonConsultar.setText("Aula Avaliativa");
jButtonConsultar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonConsultarActionPerformed(evt);
}
});
jLabelTema.setText("Tema:");
jLabelDisciplina.setText("Disciplina:");
jTextFieldEntrevista.setEditable(false);
jTextFieldEntrevista.setFocusable(false);
jTextFieldEntrevista.setName("Nome"); // NOI18N
jTextFieldDisciplina.setName("Disciplina"); // NOI18N
jTextFieldTema.setName("Tema"); // 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 {
jTextFieldHora.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jTextFieldHora.setName("Hora"); // NOI18N
jTextFieldCodigoAvaliacao.setEditable(false);
jTextFieldCodigoAvaliacao.setEnabled(false);
jTextFieldCodigoAvaliacao.setFocusable(false);
jLabelAvaliador1.setText("Avaliadores:");
jTextFieldAvaliador1.setEditable(false);
jTextFieldAvaliador2.setEditable(false);
jTextFieldAvaliador3.setEditable(false);
jLBVisualizar1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLBVisualizar1.setText("Visualizar");
jLBVisualizar1.setVerticalAlignment(javax.swing.SwingConstants.TOP);
jLBVisualizar1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLBVisualizar1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLBVisualizar1MouseClicked(evt);
}
});
jLBVisualizar2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLBVisualizar2.setText("Visualizar");
jLBVisualizar2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
jLBVisualizar2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLBVisualizar2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLBVisualizar2MouseClicked(evt);
}
});
jLBVisualizar3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLBVisualizar3.setText("Visualizar");
jLBVisualizar3.setVerticalAlignment(javax.swing.SwingConstants.TOP);
jLBVisualizar3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLBVisualizar3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLBVisualizar3MouseClicked(evt);
}
});
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 jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelAvaliador1, javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldCodigoAvaliacao, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextFieldCodigoAulaAvaliativa, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextFieldAvaliador3)
.addComponent(jTextFieldAvaliador2)
.addComponent(jTextFieldAvaliador1, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE))
.addGap(4, 4, 4)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLBVisualizar1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLBVisualizar2, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLBVisualizar3, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelData, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelHora, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelCandidato, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextFieldData, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextFieldHora, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelDisciplina)
.addComponent(jLabelTema, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextFieldDisciplina, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldTema, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextFieldEntrevista, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(18, 18, 18))
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabelDisciplina, jLabelTema});
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(jTextFieldEntrevista, 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(jLabelDisciplina)
.addComponent(jLabelData)
.addComponent(jTextFieldData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldDisciplina, 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(jLabelTema)
.addComponent(jTextFieldHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelHora, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldTema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLBVisualizar1)
.addComponent(jTextFieldAvaliador1, 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(jTextFieldCodigoAvaliacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldCodigoAulaAvaliativa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLBVisualizar2)
.addComponent(jTextFieldAvaliador2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabelAvaliador1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLBVisualizar3)
.addComponent(jTextFieldAvaliador3, 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, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jTable.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, java.awt.Color.darkGray));
jTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
}
));
jTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTableMouseClicked(evt);
}
});
jScrollPane4.setViewportView(jTable);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane4, 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)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE))
);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-551)/2, (screenSize.height-544)/2, 551, 544);
}// </editor-fold>//GEN-END:initComponents
private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
// TODO add your handling code here:
habilitaCampos(false);
if(GerenciadorDeConfiguracoesDoSistema.getUsarConexao()){
jTextFieldCodigoAvaliacao.setVisible(false);
jTextFieldCodigoAulaAvaliativa.setVisible(false);
}
habilitaLabels(false);
JButton[] listaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, jButtonConsultar};
habilitaBotoes(listaBotoes, false);
modo = Modo.Navegacao;
}//GEN-LAST:event_formInternalFrameOpened
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, jButtonConsultar};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnNovo, btnFechar};
habilitaBotoes(ativaBotoes, true);
limpaCampos();
habilitaCampos(false);
this.habilitaLabels(false);
jTable.setEnabled(true);
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:
AvaliacaoController avaliacaoCtrl = new AvaliacaoController();
String codigoSelecionado = 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 (avaliacaoCtrl.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 btnEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarActionPerformed
// TODO add your handling code here:
habilitaCampos(true);
JButton[] desativaBotoes = {btnNovo, btnEditar, btnFechar, btnExcluir};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnSalvar, btnCancelar, jButtonConsultar};
habilitaBotoes(ativaBotoes, true);
habilitaDesabilitaLabels();
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;
if (jTextFieldCodigoAulaAvaliativa.getText().isEmpty()) {
podeSalvar = false;
JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Local"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
jTextFieldEntrevista.requestFocus();
}else if (jTextFieldData.getText().isEmpty()) {
podeSalvar = false;
JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Data"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
jTextFieldData.requestFocus();
}else if (jTextFieldDisciplina.getText().isEmpty()) {
podeSalvar = false;
JOptionPane.showMessageDialog(this, Strings.getMensagemValidacao("Disciplina"), Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
jTextFieldDisciplina.requestFocus();
}
if (podeSalvar) {
AulaAvaliativa aulaAvaliativa = new AulaAvaliativa();
aulaAvaliativa.setCodigoAulaAvaliativa(Integer.parseInt(jTextFieldCodigoAulaAvaliativa.getText()));
Avaliacao avaliacao = new Avaliacao();
avaliacao.setCodigoAvaliacao(Integer.parseInt(jTextFieldCodigoAvaliacao.getText()));
avaliacao.setData(jTextFieldData.getText());
avaliacao.setHora(jTextFieldHora.getText());
avaliacao.setTema(jTextFieldTema.getText());
avaliacao.setDisciplina(jTextFieldDisciplina.getText());
avaliacao.setAulaAvaliativa(aulaAvaliativa);
AvaliacaoController avaliacaoCtrl = new AvaliacaoController();
if (modo == Modo.Inclusao) {
salvou = avaliacaoCtrl.salvar(avaliacao);
} else {
salvou = avaliacaoCtrl.atualizar(avaliacao);
}
if (salvou) {
JButton[] desativaBotoes = {btnSalvar, btnCancelar, btnEditar, btnExcluir, jButtonConsultar};
habilitaBotoes(desativaBotoes, false);
JButton[] ativaBotoes = {btnNovo, btnFechar};
habilitaBotoes(ativaBotoes, true);
habilitaCampos(false);
jTable.setEnabled(true);
modo = Modo.Navegacao;
JOptionPane.showMessageDialog(this, Strings.operacaoSucesso);
carregaTabela();
habilitaLabels(false);
limpaCampos();
}
}
modo = Modo.Navegacao;
}//GEN-LAST:event_btnSalvarActionPerformed
private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
// TODO add your handling code here:
AvaliacaoController avaliacaoCtrl = new AvaliacaoController();
jTextFieldData.requestFocus();
JButton[] ativaBotoes = {btnSalvar, btnCancelar, jButtonConsultar};
habilitaBotoes(ativaBotoes, true);
JButton[] desativaBotoes = {btnFechar, btnEditar, btnExcluir, btnNovo};
habilitaBotoes(desativaBotoes, false);
limpaCampos();
jTextFieldCodigoAvaliacao.setText(avaliacaoCtrl.getNovoCodigo());
habilitaCampos(true);
jTable.setEnabled(false);
habilitaDesabilitaLabels();
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 != Modo.Navegacao) {
JButton[] listaBotoes = {jButtonConsultar, btnSalvar, btnCancelar};
habilitaBotoes(listaBotoes, false);
GerenciadorOperacional.getPesquisa("avaliacao");
} else {
JOptionPane.showMessageDialog(null, Strings.mensagemErroAcesso, Strings.tituloMessage, JOptionPane.INFORMATION_MESSAGE);
}
jTextFieldData.requestFocus();
}//GEN-LAST:event_jButtonConsultarActionPerformed
private void jTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMouseClicked
// TODO add your handling code here:
if(modo.equals(Modo.Navegacao)){
limpaCampos();
AvaliacaoController avaliacaoCtrl = new AvaliacaoController();
int linhaSelecionada = jTable.getSelectedRow();
String codigo = String.valueOf(jTable.getValueAt(linhaSelecionada, 0));
Avaliacao avaliacao = avaliacaoCtrl.getAvaliacao(codigo);
jTextFieldTema.setText(avaliacao.getTema());
jTextFieldDisciplina.setText(avaliacao.getDisciplina());
jTextFieldAvaliador1.setText(avaliacaoCtrl.getAvaliador(avaliacao, 1));
jTextFieldAvaliador2.setText(avaliacaoCtrl.getAvaliador(avaliacao, 2));
jTextFieldAvaliador3.setText(avaliacaoCtrl.getAvaliador(avaliacao, 3));
jTextFieldCodigoAvaliacao.setText(String.valueOf(avaliacao.getCodigoAvaliacao()));
jTextFieldCodigoAulaAvaliativa.setText(String.valueOf(avaliacao.getAulaAvaliativa().getCodigoAulaAvaliativa()));
jTextFieldData.setText(avaliacao.getData());
jTextFieldHora.setText(avaliacao.getHora());
jTextFieldEntrevista.setText(avaliacao.getAulaAvaliativa().getLocal());
JButton[] listaBotoes = {btnEditar, btnExcluir};
habilitaBotoes(listaBotoes, true);
}
}//GEN-LAST:event_jTableMouseClicked
private void abreFormulario(String codigoFormulario,String modo){
formularioView = new FormularioView(jTextFieldCodigoAvaliacao.getText(), codigoFormulario, modo);
formularioView.setVisible(true);
GerenciadorOperacional.addFrame(formularioView);
}
private void jLBVisualizar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLBVisualizar1MouseClicked
// TODO add your handling code here:
abreFormulario("1", "edicao");
}//GEN-LAST:event_jLBVisualizar1MouseClicked
private void jLBVisualizar2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLBVisualizar2MouseClicked
// TODO add your handling code here:
abreFormulario("2", "edicao");
}//GEN-LAST:event_jLBVisualizar2MouseClicked
private void jLBVisualizar3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLBVisualizar3MouseClicked
// TODO add your handling code here:
abreFormulario("3", "edicao");
}//GEN-LAST:event_jLBVisualizar3MouseClicked
// 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 static javax.swing.JLabel jLBVisualizar1;
private static javax.swing.JLabel jLBVisualizar2;
private static javax.swing.JLabel jLBVisualizar3;
private javax.swing.JLabel jLabelAvaliador1;
private javax.swing.JLabel jLabelCandidato;
private javax.swing.JLabel jLabelData;
private javax.swing.JLabel jLabelDisciplina;
private javax.swing.JLabel jLabelHora;
private javax.swing.JLabel jLabelTema;
private static javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane4;
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 jTable;
private static javax.swing.JTextField jTextFieldAvaliador1;
private static javax.swing.JTextField jTextFieldAvaliador2;
private static javax.swing.JTextField jTextFieldAvaliador3;
private static javax.swing.JTextField jTextFieldCodigoAulaAvaliativa;
private static javax.swing.JFormattedTextField jTextFieldCodigoAvaliacao;
private static javax.swing.JFormattedTextField jTextFieldData;
private static javax.swing.JFormattedTextField jTextFieldDisciplina;
private static javax.swing.JFormattedTextField jTextFieldEntrevista;
private static javax.swing.JFormattedTextField jTextFieldHora;
private static javax.swing.JFormattedTextField jTextFieldTema;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables
}