Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.com.atmatech.sac.view; import br.com.atmatech.sac.beans.AtendimentoBeans; import br.com.atmatech.sac.beans.DBConfigBeans; import br.com.atmatech.sac.beans.DBConfigTempBeans; import br.com.atmatech.sac.beans.UsuarioLogadoBeans; import br.com.atmatech.sac.config.DBConfig; import br.com.atmatech.sac.controller.Crypto; import br.com.atmatech.sac.controller.Email; import br.com.atmatech.sac.controller.NivelAcesso; import br.com.atmatech.sac.controller.PintarLinhasTabelaAtend; import br.com.atmatech.sac.dao.AtendimentoDao; import br.com.atmatech.sac.report.Report; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.net.MalformedURLException; import java.sql.SQLException; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.KeyStroke; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellRenderer; import org.apache.commons.mail.EmailException; /** * * @author MARCOS */ public class ViewListaAtendimento extends javax.swing.JPanel { /** * Creates new form ViewModulo */ List<AtendimentoBeans> lab; ViewPrincipal viewprincipal; Boolean buscaatendimento; int coluna; Thread constecnico; Boolean inicializatela = false; public ViewListaAtendimento(ViewPrincipal viewprincipal, Boolean buscaatebdimento, Boolean buscaautomatica) { initComponents(); jDaguarde.setUndecorated(true); this.viewprincipal = viewprincipal; this.buscaatendimento = buscaatebdimento; inicializatela = true; permissaoUsuario(); inicializaAtalhos(); inicializaTabela(); jCBTipo.setSelectedIndex(new DBConfigBeans().getIndextipo()); // buscaAtendimentoAutomatica(); if (buscaautomatica) { formComponentShown(null); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The viewprincipal 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() { jPopupMenu1 = new javax.swing.JPopupMenu(); jMemail = new javax.swing.JMenuItem(); jMreport = new javax.swing.JMenuItem(); jDconsulta = new javax.swing.JDialog(); jLcampo = new javax.swing.JLabel(); jTparametro1 = new javax.swing.JTextField(); jCcondicao = new javax.swing.JComboBox(); jDaguarde = new javax.swing.JDialog(); jPanel3 = new javax.swing.JPanel(); jLabel21 = new javax.swing.JLabel(); buttonGroup1 = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); jBnovo = new javax.swing.JButton(); jBexcluir = new javax.swing.JButton(); jPatendimento = new javax.swing.JPanel(); jCfechado = new javax.swing.JCheckBox(); jCaberto = new javax.swing.JCheckBox(); jCpendente = new javax.swing.JCheckBox(); jCiniciado = new javax.swing.JCheckBox(); jPanel5 = new javax.swing.JPanel(); jDinicial = new com.toedter.calendar.JDateChooser(); jDfinal = new com.toedter.calendar.JDateChooser(); jBpesquisa = new javax.swing.JButton(); jCtpdata = new javax.swing.JComboBox(); jCtecnico = new javax.swing.JCheckBox(); jPTipo = new javax.swing.JPanel(); jCBTipo = new javax.swing.JComboBox<>(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTatendimento = new javax.swing.JTable(); jMemail.setText("Enviar Email"); jMemail.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMemailActionPerformed(evt); } }); jPopupMenu1.add(jMemail); jMreport.setText("Imprimir Chamado"); jMreport.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMreportActionPerformed(evt); } }); jPopupMenu1.add(jMreport); jDconsulta.setTitle("Consulta"); jDconsulta.setMinimumSize(new java.awt.Dimension(400, 130)); jDconsulta.setModal(true); jTparametro1.setDocument(new br.com.atmatech.sac.controller.LimitaCaracterUpper(80, true)); jTparametro1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTparametro1KeyPressed(evt); } }); jCcondicao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "=", ">", "<", "!=", "contem" })); jCcondicao.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jCcondicaoItemStateChanged(evt); } }); jCcondicao.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jCcondicaoFocusLost(evt); } }); javax.swing.GroupLayout jDconsultaLayout = new javax.swing.GroupLayout(jDconsulta.getContentPane()); jDconsulta.getContentPane().setLayout(jDconsultaLayout); jDconsultaLayout.setHorizontalGroup(jDconsultaLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jDconsultaLayout.createSequentialGroup().addGap(21, 21, 21).addGroup(jDconsultaLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jDconsultaLayout.createSequentialGroup() .addComponent(jLcampo, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(241, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDconsultaLayout.createSequentialGroup().addComponent(jTparametro1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCcondicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(25, 25, 25))))); jDconsultaLayout.setVerticalGroup(jDconsultaLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jDconsultaLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLcampo, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jDconsultaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTparametro1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCcondicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(109, 109, 109))); jDaguarde.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); jDaguarde.setMinimumSize(new java.awt.Dimension(247, 90)); jDaguarde.setResizable(false); jPanel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jLabel21.setForeground(new java.awt.Color(255, 0, 0)); jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel21.setText("AGUARDE...."); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel21, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(37, 37, 37).addComponent(jLabel21) .addContainerGap(24, Short.MAX_VALUE))); javax.swing.GroupLayout jDaguardeLayout = new javax.swing.GroupLayout(jDaguarde.getContentPane()); jDaguarde.getContentPane().setLayout(jDaguardeLayout); jDaguardeLayout.setHorizontalGroup( jDaguardeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); jDaguardeLayout.setVerticalGroup( jDaguardeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); setName(""); // NOI18N setPreferredSize(new java.awt.Dimension(1058, 613)); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentHidden(java.awt.event.ComponentEvent evt) { formComponentHidden(evt); } public void componentMoved(java.awt.event.ComponentEvent evt) { formComponentMoved(evt); } public void componentShown(java.awt.event.ComponentEvent evt) { formComponentShown(evt); } }); jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); jPanel1.setPreferredSize(new java.awt.Dimension(1097, 75)); jBnovo.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jBnovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/atmatech/sac/icon/Knob Add.png"))); // NOI18N jBnovo.setText("F1-Novo"); jBnovo.setMaximumSize(new java.awt.Dimension(117, 41)); jBnovo.setMinimumSize(new java.awt.Dimension(117, 41)); jBnovo.setPreferredSize(new java.awt.Dimension(113, 41)); jBnovo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBnovoActionPerformed(evt); } }); jBexcluir.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jBexcluir.setIcon( new javax.swing.ImageIcon(getClass().getResource("/br/com/atmatech/sac/icon/Knob Remove Red.png"))); // NOI18N jBexcluir.setText("F4-Excluir"); jBexcluir.setMaximumSize(new java.awt.Dimension(118, 41)); jBexcluir.setMinimumSize(new java.awt.Dimension(118, 41)); jBexcluir.setPreferredSize(new java.awt.Dimension(118, 41)); jBexcluir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBexcluirActionPerformed(evt); } }); jPatendimento.setBorder(javax.swing.BorderFactory.createTitledBorder("Status")); jCfechado.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jCfechado.setText("Fechado"); jCfechado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCfechadoActionPerformed(evt); } }); jCaberto.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jCaberto.setSelected(true); jCaberto.setText("Aberto"); jCaberto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCabertoActionPerformed(evt); } }); jCpendente.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jCpendente.setSelected(true); jCpendente.setText("Pendente"); jCpendente.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCpendenteActionPerformed(evt); } }); jCiniciado.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jCiniciado.setSelected(true); jCiniciado.setText("Iniciado"); jCiniciado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCiniciadoActionPerformed(evt); } }); javax.swing.GroupLayout jPatendimentoLayout = new javax.swing.GroupLayout(jPatendimento); jPatendimento.setLayout(jPatendimentoLayout); jPatendimentoLayout.setHorizontalGroup( jPatendimentoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPatendimentoLayout.createSequentialGroup().addComponent(jCfechado) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCaberto) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCpendente) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jCiniciado).addGap(0, 15, Short.MAX_VALUE))); jPatendimentoLayout.setVerticalGroup(jPatendimentoLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPatendimentoLayout.createSequentialGroup().addGroup(jPatendimentoLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jCfechado) .addComponent(jCaberto).addComponent(jCpendente).addComponent(jCiniciado)) .addGap(0, 3, Short.MAX_VALUE))); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Data")); jPanel5.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jPanel5KeyPressed(evt); } }); jBpesquisa.setText("..."); jBpesquisa.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBpesquisaActionPerformed(evt); } }); jCtpdata.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jCtpdata.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Abertura", "Inicial", "Final" })); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout .setHorizontalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jCtpdata, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(1, 1, 1) .addComponent(jDinicial, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jDfinal, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(1, 1, 1).addComponent(jBpesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(1, 1, 1))); jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { jDfinal, jDinicial }); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup().addGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jCtpdata, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBpesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jDinicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jDfinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))); jCtecnico.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jCtecnico.setText("Tecnico"); jCtecnico.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jCtecnicoStateChanged(evt); } }); jCtecnico.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCtecnicoActionPerformed(evt); } }); jPTipo.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo")); jCBTipo.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { "I", "E", "P", "I/E/P", "I/E", "I/P", "E/I", "E/P" })); jCBTipo.addPopupMenuListener(new javax.swing.event.PopupMenuListener() { public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) { } public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) { jCBTipoPopupMenuWillBecomeInvisible(evt); } public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) { } }); javax.swing.GroupLayout jPTipoLayout = new javax.swing.GroupLayout(jPTipo); jPTipo.setLayout(jPTipoLayout); jPTipoLayout.setHorizontalGroup(jPTipoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jCBTipo, 0, 71, Short.MAX_VALUE)); jPTipoLayout.setVerticalGroup(jPTipoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPTipoLayout.createSequentialGroup() .addComponent(jCBTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(2, 2, 2) .addComponent(jBnovo, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(1, 1, 1) .addComponent(jBexcluir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jCtecnico).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(1, 1, 1) .addComponent(jPTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(1, 1, 1) .addComponent(jPatendimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(2, 2, 2))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addGap(6, 6, 6).addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jBnovo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBexcluir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCtecnico)) .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPatendimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPTipo, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap())); jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { jBexcluir, jBnovo }); jPanel2.setPreferredSize(new java.awt.Dimension(779, 294)); jTatendimento.setAutoCreateRowSorter(true); jTatendimento.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { }, new String[] { "OS", "CLIENTE", "DATA", "TECNICO", "ABERTURA", "STATUS", "TIPO" }) { boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); jTatendimento.getTableHeader().setReorderingAllowed(false); jTatendimento.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jTatendimentoMouseClicked(evt); } }); jTatendimento.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTatendimentoKeyPressed(evt); } }); jScrollPane1.setViewportView(jTatendimento); if (jTatendimento.getColumnModel().getColumnCount() > 0) { jTatendimento.getColumnModel().getColumn(0).setMinWidth(100); jTatendimento.getColumnModel().getColumn(0).setPreferredWidth(100); jTatendimento.getColumnModel().getColumn(1).setMinWidth(500); jTatendimento.getColumnModel().getColumn(1).setPreferredWidth(500); jTatendimento.getColumnModel().getColumn(2).setMinWidth(150); jTatendimento.getColumnModel().getColumn(2).setPreferredWidth(150); jTatendimento.getColumnModel().getColumn(3).setMinWidth(150); jTatendimento.getColumnModel().getColumn(3).setPreferredWidth(150); jTatendimento.getColumnModel().getColumn(4).setMinWidth(100); jTatendimento.getColumnModel().getColumn(4).setPreferredWidth(100); jTatendimento.getColumnModel().getColumn(5).setMinWidth(100); jTatendimento.getColumnModel().getColumn(5).setPreferredWidth(100); } javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout .setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1038, Short.MAX_VALUE)); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 516, Short.MAX_VALUE)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 1038, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 1038, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 516, Short.MAX_VALUE))); }// </editor-fold>//GEN-END:initComponents private void jBnovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBnovoActionPerformed // TODO add your handling code here: if ((!new UsuarioLogadoBeans().getAlttecnico()) && (!new UsuarioLogadoBeans().getTecnico())) { JOptionPane.showMessageDialog(this, "Parametros Incorreto no Cadastro do Usurio", "Atendimento", JOptionPane.ERROR_MESSAGE); } else { ViewAtendimento view = new ViewAtendimento(viewprincipal, ViewListaAtendimento.this, null, new UsuarioLogadoBeans().getAlttecnico(), true); viewprincipal.jTaabas.getSelectedIndex(); viewprincipal.jTaabas.setComponentAt(viewprincipal.jTaabas.getSelectedIndex(), view); } }//GEN-LAST:event_jBnovoActionPerformed private void jTatendimentoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTatendimentoMouseClicked // TODO add your handling code here: if (new NivelAcesso().getAcesso("ViewAtendimento", "acessar")) { if (evt.getClickCount() == 2) { ViewAtendimento view = new ViewAtendimento(viewprincipal, this, clickAtendimento(), new UsuarioLogadoBeans().getAlttecnico(), false); viewprincipal.jTaabas.getSelectedIndex(); viewprincipal.jTaabas.setComponentAt(viewprincipal.jTaabas.getSelectedIndex(), view); if (!new UsuarioLogadoBeans().getBconsulta()) { if (constecnico.isAlive()) { if (!constecnico.isInterrupted()) { constecnico.stop(); } } //constecnico.stop(); } } } if (jTatendimento.getSelectedRow() >= 0) { if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) { jPopupMenu1.show(jTatendimento, evt.getX(), evt.getY()); } } }//GEN-LAST:event_jTatendimentoMouseClicked private void jBexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBexcluirActionPerformed // TODO add your handling code here: if (jTatendimento.getSelectedRow() >= 0) { if ((Integer) jTatendimento.getValueAt(jTatendimento.getSelectedRow(), 0) > 0) { if (JOptionPane.showConfirmDialog(this, "Deseja Excluir o Atendimento: " + jTatendimento.getValueAt(jTatendimento.getSelectedRow(), 0), "Atendimento", JOptionPane.OK_CANCEL_OPTION) == 0) { deleteAtendimento(); } } else { JOptionPane.showMessageDialog(this, "Selecione um Registro Para Excluir", "Atendimento", JOptionPane.INFORMATION_MESSAGE); } } }//GEN-LAST:event_jBexcluirActionPerformed private void jCfechadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCfechadoActionPerformed // TODO add your handling code here: tipoAtendimento(); }//GEN-LAST:event_jCfechadoActionPerformed private void jCabertoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCabertoActionPerformed // TODO add your handling code here: tipoAtendimento(); }//GEN-LAST:event_jCabertoActionPerformed private void jCpendenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCpendenteActionPerformed // TODO add your handling code here: tipoAtendimento(); }//GEN-LAST:event_jCpendenteActionPerformed private void jCiniciadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCiniciadoActionPerformed // TODO add your handling code here: tipoAtendimento(); }//GEN-LAST:event_jCiniciadoActionPerformed private void jMemailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMemailActionPerformed try { // TODO add your handling code here: AtendimentoBeans atendimento = clickAtendimento(); UsuarioLogadoBeans ubl = new UsuarioLogadoBeans(); if (atendimento.getSTATUS().equals("FECHADO")) { if (atendimento.getEmail().length() == 0) { JOptionPane.showMessageDialog(this, "Cliente no Possui Email\n", "Atendimento", JOptionPane.ERROR_MESSAGE); } else if ((ubl.getEmail().length() == 0) || (ubl.getSmtp().length() == 0) || (ubl.getSenha().length() == 0) || (ubl.getPorta() == 0) || (ubl.getSsl().toString().length() == 0) || (ubl.getTls().toString().length() == 0)) { JOptionPane.showMessageDialog(this, "Tecnico no Possui Email\n", "Atendimento", JOptionPane.ERROR_MESSAGE); } else { SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); new Email().emailAtendimento(ubl.getSmtp(), ubl.getEmail(), ubl.getSenhaemail(), ubl.getPorta(), ubl.getSsl(), ubl.getTls(), "" + atendimento.getEmail(), ubl.getEmail(), "" + atendimento.getSOLICITANTE(), atendimento.getIDATENDIMENTO().toString(), atendimento.getRazao(), sdf.format(atendimento.getDTFINAL()), "" + atendimento.getSOLICITACAO(), atendimento.getREALIZADO(), atendimento.getTecniconome(), ubl.getAssinatura()); } } else { JOptionPane.showMessageDialog(this, "So e Permitido o Envio de Email Para Atendimentos Fechados\n", "Atendimento", JOptionPane.ERROR_MESSAGE); } } /*catch (EmailException ex) { Logger.getLogger("\nmarcos "+ViewListaAtendimento.class.getName()).log(Level.SEVERE, null, ex);*/ catch (EmailException ex) { JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE); } catch (MalformedURLException ex) { JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE); } catch (NullPointerException ex) { JOptionPane.showMessageDialog(this, "Erro ao Enviar Email\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE); } }//GEN-LAST:event_jMemailActionPerformed private void jTatendimentoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTatendimentoKeyPressed // TODO add your handling code here: if (jTatendimento.getSelectedColumn() >= 0) { coluna = jTatendimento.getSelectedColumn(); } else { coluna = 1; } if ((evt.getKeyCode() == KeyEvent.VK_F) && (coluna >= 0) && (!jTatendimento.getColumnName(coluna).equals("DATA"))) { if (evt.isControlDown()) { jLcampo.setText(jTatendimento.getColumnName(coluna)); jTparametro1.setText(""); jCcondicao.setSelectedIndex(4); jDconsulta.setLocationRelativeTo(this); jDconsulta.setVisible(true); // } } }//GEN-LAST:event_jTatendimentoKeyPressed private void jCcondicaoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCcondicaoItemStateChanged // TODO add your handling code here: }//GEN-LAST:event_jCcondicaoItemStateChanged private void jCcondicaoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCcondicaoFocusLost // TODO add your handling code here: // if (jCcondicao.getSelectedItem().toString().equals("entre")) { // jTparametro2.setVisible(true); // jDconsulta.validate(); // } else { // jTparametro2.setVisible(false); // jDconsulta.validate(); // } }//GEN-LAST:event_jCcondicaoFocusLost private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown // TODO add your handling code here: if (this.inicializatela) { this.jTatendimento.requestFocusInWindow(); Timestamp dtini = new Timestamp(new Date().getTime()); Date dtin = new Date(); Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -30); jDinicial.setDate(c.getTime()); jDfinal.setDate(new Timestamp(new Date().getTime())); if (new UsuarioLogadoBeans().getTecnico()) { if (new UsuarioLogadoBeans().getTecnico()) { jCtecnico.doClick(); } else { // jCtecnico.setSelected(new UsuarioLogadoBeans().getTecnico()); desativaPpesquisa(); } } else if (this.buscaatendimento) { new Thread(new Runnable() { @Override public void run() { buscaAtendimento(getTipoSelected(), "'ABERTO','INICIADO','PENDENTE'", new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), "dtabertura"); } }).start(); } trocaCor(); this.inicializatela = false; } }//GEN-LAST:event_formComponentShown private void jPanel5KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel5KeyPressed // TODO add your handling code here: }//GEN-LAST:event_jPanel5KeyPressed private void jBpesquisaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBpesquisaActionPerformed // TODO add your handling code here: new Thread(new Runnable() { @Override public void run() { buscaAtendimento(getTipoSelected(), verificaStatus(), new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), getTipoData()); } }).start(); }//GEN-LAST:event_jBpesquisaActionPerformed private void jTparametro1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTparametro1KeyPressed // TODO add your handling code here: }//GEN-LAST:event_jTparametro1KeyPressed private void jMreportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMreportActionPerformed // TODO add your handling code here: new Thread(new Runnable() { @Override public void run() { showAguarde(); } }).start(); new Thread(new Runnable() { @Override public void run() { getReportChamado(); } }).start(); }//GEN-LAST:event_jMreportActionPerformed private void formComponentHidden(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentHidden // TODO add your handling code here: }//GEN-LAST:event_formComponentHidden private void jCtecnicoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCtecnicoStateChanged // TODO add your handling code here: }//GEN-LAST:event_jCtecnicoStateChanged private void jCtecnicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCtecnicoActionPerformed // TODO add your handling code here: consultaAutomatica(); if (jCtecnico.isSelected()) { desativaPpesquisa(); } else { ativaPpesquisa(); } }//GEN-LAST:event_jCtecnicoActionPerformed private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved // TODO add your handling code here: }//GEN-LAST:event_formComponentMoved private void jCBTipoPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_jCBTipoPopupMenuWillBecomeInvisible // TODO add your handling code here: DBConfigBeans dbc = new DBConfigBeans(); try { // dbc.setIndextipo(jCBTipo.getSelectedIndex()); // dbc.setPassword(new Crypto().codifica(new DBConfigBeans().getPassword())); // dbc.setUser(new Crypto().codifica(new DBConfigBeans().getUser())); // new DBConfig().createConfig(dbc); alterarConfig(); dbc = new DBConfig().getConfig(); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Erro ao Salvar Em Arquivo .ini\n" + ex); } //alterarConfig(); }//GEN-LAST:event_jCBTipoPopupMenuWillBecomeInvisible // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jBexcluir; private javax.swing.JButton jBnovo; private javax.swing.JButton jBpesquisa; private javax.swing.JComboBox<String> jCBTipo; private javax.swing.JCheckBox jCaberto; private javax.swing.JComboBox jCcondicao; private javax.swing.JCheckBox jCfechado; private javax.swing.JCheckBox jCiniciado; private javax.swing.JCheckBox jCpendente; private javax.swing.JCheckBox jCtecnico; private javax.swing.JComboBox jCtpdata; private javax.swing.JDialog jDaguarde; private javax.swing.JDialog jDconsulta; private com.toedter.calendar.JDateChooser jDfinal; private com.toedter.calendar.JDateChooser jDinicial; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLcampo; private javax.swing.JMenuItem jMemail; private javax.swing.JMenuItem jMreport; private javax.swing.JPanel jPTipo; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPatendimento; private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTatendimento; private javax.swing.JTextField jTparametro1; // End of variables declaration//GEN-END:variables public void buscaAtendimento(String tipo, final String status, final Integer idtecnico, final Date ini, final Date fin, String campo) { new Thread(new Runnable() { @Override public void run() { showAguarde(); } }).start(); DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); tabelaatendimento.setNumRows(0); try { lab = new AtendimentoDao().getAtendimento(tipo, status, idtecnico, new UsuarioLogadoBeans().getVchamados(), ini, fin, getTipoData()); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro ao consultar Atendimento\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE); jDaguarde.setVisible(false); } SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); TableCellRenderer renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); for (AtendimentoBeans ab : lab) { tabelaatendimento .addRow(new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()), ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() }); } jDaguarde.setVisible(false); } //utilizado na atualizacao automatica dos atendimento public void buscaAtendimento() { String status = "'ABERTO','INICIADO','PENDENTE'"; Integer idtecnico = new UsuarioLogadoBeans().getIdusuario(); Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -30); Date ini = c.getTime(); Date fin = new Timestamp(new Date().getTime()); String campo = "dtabertura"; List<AtendimentoBeans> labt = new ArrayList<>(); DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); try { labt = new AtendimentoDao().getAtendimento(getTipoSelected(), status, idtecnico, new UsuarioLogadoBeans().getVchamados(), ini, fin, getTipoData()); if (!caparaArrayList(labt, lab)) { lab = labt; tabelaatendimento.setNumRows(0); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); TableCellRenderer renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); for (AtendimentoBeans ab : lab) { tabelaatendimento.addRow( new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()), ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() }); } } } catch (SQLException ex) { lab.clear(); tabelaatendimento.setNumRows(0); //Logger.getLogger(ViewListaAtendimento.class.getName()).log(Level.SEVERE, null, ex); } } private void buscaAtendimento(String campo, String parametro, Integer idusuario, Boolean supervisor) { DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); tabelaatendimento.setNumRows(0); //String status=verificaStatus(); lab = new AtendimentoDao().getAtendimento(verificaStatus(), campo, parametro, idusuario, supervisor, jDinicial.getDate(), jDfinal.getDate(), getTipoData()); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); TableCellRenderer renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); for (AtendimentoBeans ab : lab) { tabelaatendimento .addRow(new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()), ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() }); } jDconsulta.setVisible(false); } private AtendimentoBeans clickAtendimento() { AtendimentoBeans ab = new AtendimentoBeans(); for (AtendimentoBeans lab1 : lab) { if (Objects.equals( Integer.valueOf(jTatendimento.getValueAt(jTatendimento.getSelectedRow(), 0).toString()), lab1.getIDATENDIMENTO())) { ab = lab1; return ab; } } return null; } private void deleteAtendimento() { try { new AtendimentoDao() .deleteAtendimento((Integer) jTatendimento.getValueAt(jTatendimento.getSelectedRow(), 0)); if (!jCtecnico.isSelected()) { buscaAtendimento(getTipoSelected(), "'ABERTO','INICIADO','PENDENTE'", new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), getTipoData()); } // buscaAtendimento("'ABERTO','INICIADO','PENDENTE'", new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), getTipoData()); JOptionPane.showMessageDialog(this, "Registro Excluido Com Sucesso", "Atendimento", JOptionPane.INFORMATION_MESSAGE); } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "Erro ao Excluir Registro\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE); } } private void tipoAtendimento() { new Thread(new Runnable() { @Override public void run() { String tipo = "''"; if (jCaberto.isSelected()) { tipo = tipo + ",'ABERTO',''"; } if (jCfechado.isSelected()) { tipo = tipo + ",'FECHADO',''"; } if (jCiniciado.isSelected()) { tipo = tipo + ",'INICIADO',''"; } if (jCpendente.isSelected()) { tipo = tipo + ",'PENDENTE',''"; } buscaAtendimento(getTipoSelected(), tipo, new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), getTipoData()); } }).start(); } private void permissaoUsuario() { if (!new NivelAcesso().getAcesso("ViewListaAtendimento", "cadastrar", false)) { jBnovo.setVisible(false); } if (!new NivelAcesso().getAcesso("ViewListaAtendimento", "excluir", false)) { jBexcluir.setVisible(false); } } private void inicializaAtalhos() { KeyStroke keyStrokeJBnovo = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0); String actionNameJBnovo = "TECLA_F1"; InputMap inputMapJBnovo = jBnovo.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMapJBnovo.put(keyStrokeJBnovo, actionNameJBnovo); ActionMap actionMapJBMARCA = jBnovo.getActionMap(); actionMapJBMARCA.put(actionNameJBnovo, acaojBnovo); //Atalho excluir KeyStroke keyStrokeJBexcluir = KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0); String actionNameJBexcluir = "F4"; InputMap inputMapJBexcluir = jBexcluir.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMapJBexcluir.put(keyStrokeJBexcluir, actionNameJBexcluir); ActionMap actionMapJBexcluir = jBexcluir.getActionMap(); actionMapJBexcluir.put(actionNameJBexcluir, acaoJBexcluir); //Atalho atualizar KeyStroke keyStrokeJBatualizar = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0); String actionNameJBatualizar = "F5"; InputMap inputMapJBatualizar = jBpesquisa.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMapJBatualizar.put(keyStrokeJBatualizar, actionNameJBatualizar); ActionMap actionMapJBatualizar = jBpesquisa.getActionMap(); actionMapJBatualizar.put(actionNameJBatualizar, acaoJBpesquisa); //Atalho enter InputMap inputMapJBenter = this.jDconsulta.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMapJBenter.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "forward"); this.jDconsulta.getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMapJBenter); this.jDconsulta.getRootPane().getActionMap().put("forward", new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { filtraChamado(); } }); } //FUNCAO DA ACAO DO BOTAO JBnovo Action acaojBnovo = new AbstractAction() { //funcao da acao do botao @Override public void actionPerformed(ActionEvent e) { //simula o click no boto jBnovo.doClick(); } }; //FUNCAO de atalho excluir Action acaoJBexcluir = new AbstractAction() { //funcao da acao do botao @Override public void actionPerformed(ActionEvent e) { //simula o click no boto jBexcluir.doClick(); } }; //FUNCAO de atalho pesquisa Action acaoJBpesquisa = new AbstractAction() { //funcao da acao do botao @Override public void actionPerformed(ActionEvent e) { //simula o click no boto jBpesquisa.doClick(); } }; private void filtraChamado() { String text = jTparametro1.getText(); //if(text.length()>0){ text = verificaParametro(text, jCcondicao.getSelectedItem().toString()); if (jTatendimento.getColumnName(coluna).equals("OS")) { buscaAtendimento("idatendimento", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } if (jTatendimento.getColumnName(coluna).equals("CLIENTE")) { buscaAtendimento("razao", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } if (jTatendimento.getColumnName(coluna).equals("DATA")) { buscaAtendimento("dtabertura", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } if (jTatendimento.getColumnName(coluna).equals("TECNICO")) { buscaAtendimento("tecnico.nome", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } if (jTatendimento.getColumnName(coluna).equals("STATUS")) { buscaAtendimento("status", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } if (jTatendimento.getColumnName(coluna).equals("TIPO")) { buscaAtendimento("tipo", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } if (jTatendimento.getColumnName(coluna).equals("ABERTURA")) { buscaAtendimento("abertura.nome", text, new UsuarioLogadoBeans().getIdusuario(), new UsuarioLogadoBeans().getVchamados()); } // } } private String verificaParametro(String parametro1, String condicao) { if (condicao.equals("=")) { return "='" + parametro1 + "'"; } if (condicao.equals(">")) { return ">'" + parametro1 + "'"; } if (condicao.equals("<")) { return "<'" + parametro1 + "'"; } if (condicao.equals("!=")) { return "!='" + parametro1 + "'"; } if (condicao.equals("contem")) { return "like '%" + parametro1 + "%'"; } return ""; } private String verificaStatus() { List<String> lstatus = new ArrayList<>(); if (jCaberto.isSelected()) { lstatus.add("'ABERTO'"); } if (jCfechado.isSelected()) { lstatus.add("'FECHADO'"); } if (jCiniciado.isSelected()) { lstatus.add("'INICIADO'"); } if (jCpendente.isSelected()) { lstatus.add("'PENDENTE'"); } String[] status = (String[]) lstatus.toArray(new String[lstatus.size()]); return Arrays.toString(status).replace("[", "").replace("]", ""); } private void buscaAtendimentoAutomatica() { new Thread(new Runnable() { @Override public void run() { while (true) { try { Thread.sleep(5000); buscaAtendimento(getTipoSelected(), verificaStatus(), new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), getTipoData()); } catch (InterruptedException ex) { JOptionPane.showMessageDialog(null, "Erro ao Atualizar Lista de Atendimentos\n" + ex); } } } }).start(); buscaAtendimento(getTipoSelected(), verificaStatus(), new UsuarioLogadoBeans().getIdusuario(), jDinicial.getDate(), jDfinal.getDate(), getTipoData()); } private String getTipoData() { return "dt" + jCtpdata.getSelectedItem().toString(); } private void inicializaTabela() { if (jTatendimento.getColumnModel().getColumnCount() > 0) { jTatendimento.getColumnModel().getColumn(0).setMinWidth(70); jTatendimento.getColumnModel().getColumn(0).setMaxWidth(70); jTatendimento.getColumnModel().getColumn(1).setMinWidth(250); //jTatendimento.getColumnModel().getColumn(1).setMaxWidth(250); jTatendimento.getColumnModel().getColumn(2).setMinWidth(150); jTatendimento.getColumnModel().getColumn(2).setMaxWidth(150); jTatendimento.getColumnModel().getColumn(3).setMinWidth(150); jTatendimento.getColumnModel().getColumn(3).setMaxWidth(150); jTatendimento.getColumnModel().getColumn(4).setMinWidth(150); jTatendimento.getColumnModel().getColumn(4).setMaxWidth(150); jTatendimento.getColumnModel().getColumn(5).setMinWidth(100); jTatendimento.getColumnModel().getColumn(5).setMaxWidth(100); jTatendimento.getColumnModel().getColumn(6).setMinWidth(100); jTatendimento.getColumnModel().getColumn(6).setMaxWidth(100); } } public void showAguarde() { jDaguarde.setLocationRelativeTo(this.jPanel2); jDaguarde.setVisible(true); } public void closeAguarde() { jDaguarde.setVisible(false); } public void getReportChamado() { AtendimentoBeans at = clickAtendimento(); new Report().getReportChamado(at.getIDATENDIMENTO(), this); } public void trocaCor() { new Thread(new Runnable() { @Override public void run() { while (true) { TableCellRenderer renderer = new PintarLinhasTabelaAtend(true); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); jTatendimento.repaint(); try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(ViewListaAtendimento.class.getName()).log(Level.SEVERE, null, ex); } renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); jTatendimento.repaint(); try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(ViewListaAtendimento.class.getName()).log(Level.SEVERE, null, ex); } } } }).start(); } private boolean caparaArrayList(List<AtendimentoBeans> labt, List<AtendimentoBeans> lab) { if (labt != null) { if (lab != null) { if (labt.size() == lab.size()) { for (int i = 0; i < lab.size(); i++) { if (!labt.get(i).getIDATENDIMENTO().equals(lab.get(i).getIDATENDIMENTO())) { return false; } if (!labt.get(i).getIDPESSOA().equals(lab.get(i).getIDPESSOA())) { return false; } if (!labt.get(i).getDTABERTURA().equals(lab.get(i).getDTABERTURA())) { return false; } if (!labt.get(i).getIDTECNICO().equals(lab.get(i).getIDTECNICO())) { return false; } if (!labt.get(i).getIDABERTURA().equals(lab.get(i).getIDABERTURA())) { return false; } if (!labt.get(i).getSTATUS().equals(lab.get(i).getSTATUS())) { return false; } if (!labt.get(i).getTIPO().equals(lab.get(i).getTIPO())) { return false; } } return true; } return false; } return false; } return true; } private void consultaAutomatica() { if (constecnico == null) { constecnico = new Thread(new Runnable() { @Override public void run() { while (jCtecnico.isSelected()) { if (!verifcaJpanel()) { if (!constecnico.isInterrupted()) { constecnico.stop(); } //constecnico.stop();era oque estava ativaPpesquisa(); } Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -30); buscaAtendimento(); try { Thread.sleep(2000); } catch (InterruptedException ex) { constecnico.stop(); JOptionPane.showMessageDialog(null, "Erro ao Atualizar Chamado 1152" + ex); } } } }); constecnico.start(); } else if (constecnico.isAlive()) { if (!constecnico.isInterrupted()) { constecnico.stop(); } } else if (!constecnico.isAlive()) { constecnico = new Thread(new Runnable() { @Override public void run() { while (jCtecnico.isSelected()) { if (!verifcaJpanel()) { if (!constecnico.isInterrupted()) { constecnico.stop(); } //constecnico.stop(); era oque estava ativaPpesquisa(); } Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -30); buscaAtendimento(); try { Thread.sleep(2000); } catch (InterruptedException ex) { constecnico.stop(); JOptionPane.showMessageDialog(null, "Erro ao Atualizar Chamado 1175" + ex); } } } }); constecnico.start(); } } private boolean verifcaJpanel() { for (int i = 0; i < viewprincipal.jTaabas.getComponentCount() - 1; i++) { if (viewprincipal.jTaabas.getTitleAt(i).equals("Atendimento")) { return true; } } return false; } private void ativaPpesquisa() { this.jCtpdata.setEnabled(true); this.jDinicial.setEnabled(true); this.jDfinal.setEnabled(true); this.jCaberto.setEnabled(true); this.jCfechado.setEnabled(true); this.jCpendente.setEnabled(true); this.jCiniciado.setEnabled(true); } private void desativaPpesquisa() { this.jCtpdata.setEnabled(false); this.jDinicial.setEnabled(false); this.jDfinal.setEnabled(false); this.jCaberto.setEnabled(false); this.jCfechado.setEnabled(false); this.jCpendente.setEnabled(false); this.jCiniciado.setEnabled(false); } private String getTipoSelected() { switch (jCBTipo.getSelectedIndex()) { case 0: return "'INTERNO'"; case 1: return "'EXTERNO'"; case 2: return "'PLANTAO'"; case 3: return "'INTERNO','EXTERNO','PLANTAO'"; case 4: return "'INTERNO','EXTERNO'"; case 5: return "'INTERNO','PLANTAO'"; case 6: return "'EXTERNO','INTERNO'"; case 7: return "'EXTERNO','PLANTAO'"; } return null; } private void alterarConfig() { try { DBConfigBeans dbc = new DBConfigBeans(); DBConfigTempBeans cb = new DBConfigTempBeans(); cb.setDirdbt(dbc.getDirdb()); cb.setUsert(new Crypto().codifica(dbc.getUser())); cb.setPasswordt(new Crypto().codifica(dbc.getPassword())); cb.setLogint(dbc.getLogin()); cb.setSenhat(dbc.getSenha()); cb.setDirdbhostt(dbc.getDirdb()); cb.setPrimary1rt(dbc.getPrimary1r()); cb.setPrimary1gt(dbc.getPrimary1g()); cb.setPrimary1bt(dbc.getPrimary1b()); cb.setPrimary2rt(dbc.getPrimary2r()); cb.setPrimary2gt(dbc.getPrimary2g()); cb.setPrimary2bt(dbc.getPrimary2b()); cb.setPrimary3rt(dbc.getPrimary3r()); cb.setPrimary3gt(dbc.getPrimary3g()); cb.setPrimary3bt(dbc.getPrimary3b()); cb.setSecondary1rt(dbc.getSecondary1r()); cb.setSecondary1gt(dbc.getSecondary1g()); cb.setSecondary1bt(dbc.getSecondary1b()); cb.setSecondary2rt(dbc.getSecondary2r()); cb.setSecondary2gt(dbc.getSecondary2g()); cb.setSecondary2bt(dbc.getSecondary2b()); cb.setSecondary3rt(dbc.getSecondary3r()); cb.setSecondary3bt(dbc.getSecondary3g()); cb.setSecondary3gt(dbc.getSecondary3b()); cb.setWhitert(dbc.getWhiter()); cb.setWhitegt(dbc.getWhiteg()); cb.setWhitebt(dbc.getWhiteb()); cb.setBlackrt(dbc.getBlackr()); cb.setBlackgt(dbc.getBlackg()); cb.setBlackbt(dbc.getBlackb()); cb.setMenuopacityt(dbc.getMenuopacity()); cb.setFrameopacityt(dbc.getFrameopacity()); cb.setIndextipot(jCBTipo.getSelectedIndex()); cb.setCompanyt(dbc.getCompany()); new DBConfig().createTempConfig(cb); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "Erro ao Salvar\n" + ex); } } }