Coverage Report - net.sf.webphotos.gui.component.PainelPesquisa
 
Classes in this File Line Coverage Branch Coverage Complexity
PainelPesquisa
80%
42/52
N/A
1
 
 1  
 /**
 2  
  * Copyright 2008 WebPhotos
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package net.sf.webphotos.gui.component;
 17  
 
 18  
 /**
 19  
  * PainelPesquisa.java
 20  
  *
 21  
  * Created on 13 de Janeiro de 2006, 12:33
 22  
  */
 23  
 import java.awt.event.MouseListener;
 24  
 import java.io.Serializable;
 25  
 import javax.swing.JPanel;
 26  
 import net.sf.webphotos.action.AcaoPesquisa;
 27  
 
 28  
 /**
 29  
  * Desenvolve um painel para pesquisas. Através do construtor, trabalha os
 30  
  * eventos para obter o resultado das pesquisas.
 31  
  *
 32  
  * @author guilherme
 33  
  */
 34  
 public class PainelPesquisa extends JPanel implements Serializable {
 35  
     
 36  
     private AcaoPesquisa acaoPesquisa;
 37  
     
 38  
     /**
 39  
      * Construtor da classe. Chama o método initComponents(), responsável por
 40  
      * gerar o painel. Trata os eventos e as ações de pesquisa.
 41  
      */
 42  9
     public PainelPesquisa() {
 43  9
         initComponents();
 44  
 
 45  
         // ACAO PESQUISA
 46  
         // TODO: Reformular esse trecho (ver versão anterior)
 47  
         //acaoPesquisa = new AcaoPesquisa(lstCategoriasPesquisa, txtPesquisa, tbAlbuns);
 48  
         //registerResearchActionComponent(acaoPesquisa);
 49  
 
 50  9
     }
 51  
 
 52  
     private void registerResearchActionComponent(AcaoPesquisa acaoPesquisa) {
 53  0
         btPesquisar.addActionListener(acaoPesquisa);
 54  0
         txtPesquisa.registerKeyboardAction(acaoPesquisa,
 55  
                 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0),
 56  
                 javax.swing.JComponent.WHEN_FOCUSED);
 57  0
     }
 58  
 
 59  
     /**
 60  
      * This method is called from within the constructor to initialize the form.
 61  
      * WARNING: Do NOT modify this code. The content of this method is always
 62  
      * regenerated by the Form Editor.
 63  
      */
 64  
     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 65  
     private void initComponents() {
 66  
 
 67  9
         painelBusca = new javax.swing.JPanel();
 68  9
         lblPesquisar = new javax.swing.JLabel();
 69  9
         lstCategoriasPesquisa = new javax.swing.JComboBox();
 70  9
         lblPalavras = new javax.swing.JLabel();
 71  9
         txtPesquisa = new javax.swing.JTextField();
 72  9
         btPesquisar = new javax.swing.JButton();
 73  9
         painelSQL = new javax.swing.JPanel();
 74  9
         btFiltro = new javax.swing.JButton();
 75  
 
 76  9
         setMaximumSize(new java.awt.Dimension(65534, 35));
 77  9
         setMinimumSize(new java.awt.Dimension(780, 35));
 78  9
         setPreferredSize(new java.awt.Dimension(780, 35));
 79  9
         setLayout(new java.awt.BorderLayout());
 80  
 
 81  9
         painelBusca.setMaximumSize(new java.awt.Dimension(32767, 35));
 82  9
         painelBusca.setPreferredSize(new java.awt.Dimension(461, 35));
 83  9
         painelBusca.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
 84  
 
 85  9
         lblPesquisar.setText("Pesquisar em");
 86  9
         painelBusca.add(lblPesquisar);
 87  
 
 88  9
         lstCategoriasPesquisa.setName("lstCategoriasPesquisa"); // NOI18N
 89  9
         painelBusca.add(lstCategoriasPesquisa);
 90  
 
 91  9
         lblPalavras.setText("palavra(s)");
 92  9
         painelBusca.add(lblPalavras);
 93  
 
 94  9
         txtPesquisa.setMinimumSize(new java.awt.Dimension(192, 19));
 95  9
         txtPesquisa.setPreferredSize(new java.awt.Dimension(192, 19));
 96  9
         painelBusca.add(txtPesquisa);
 97  
 
 98  9
         btPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/zoom16.gif"))); // NOI18N
 99  9
         btPesquisar.setText("pesquisar");
 100  9
         painelBusca.add(btPesquisar);
 101  
 
 102  9
         add(painelBusca, java.awt.BorderLayout.CENTER);
 103  
 
 104  9
         painelSQL.setMaximumSize(new java.awt.Dimension(32767, 35));
 105  9
         painelSQL.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
 106  
 
 107  9
         btFiltro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/sql.gif"))); // NOI18N
 108  9
         painelSQL.add(btFiltro);
 109  
 
 110  9
         add(painelSQL, java.awt.BorderLayout.EAST);
 111  9
     }// </editor-fold>//GEN-END:initComponents
 112  
     // Variables declaration - do not modify//GEN-BEGIN:variables
 113  
     private javax.swing.JButton btFiltro;
 114  
     private javax.swing.JButton btPesquisar;
 115  
     private javax.swing.JLabel lblPalavras;
 116  
     private javax.swing.JLabel lblPesquisar;
 117  
     private javax.swing.JComboBox lstCategoriasPesquisa;
 118  
     private javax.swing.JPanel painelBusca;
 119  
     private javax.swing.JPanel painelSQL;
 120  
     private javax.swing.JTextField txtPesquisa;
 121  
     // End of variables declaration//GEN-END:variables
 122  
     // Bean Variables
 123  
     private javax.swing.ComboBoxModel categoriasPesquisaComboBoxModel;
 124  
 
 125  
     /**
 126  
      * Retorna a {@link javax.swing.ComboBoxModel ComboBoxModel}
 127  
      * categoriasPesquisaComboBoxModel.
 128  
      *
 129  
      * @return Retorna uma ComboBoxModel.
 130  
      */
 131  
     public javax.swing.ComboBoxModel getCategoriasPesquisaComboBoxModel() {
 132  0
         return categoriasPesquisaComboBoxModel;
 133  
     }
 134  
 
 135  
     /**
 136  
      * Sets a {@link javax.swing.ComboBoxModel ComboBoxModel}
 137  
      * categoriasPesquisaComboBoxModel.
 138  
      *
 139  
      * @param lstCategoriasPesquisaModel Modelo de lista de categorias para a
 140  
      * pesquisa.
 141  
      */
 142  
     public void setCategoriasPesquisaComboBoxModel(javax.swing.ComboBoxModel lstCategoriasPesquisaModel) {
 143  6
         this.categoriasPesquisaComboBoxModel = lstCategoriasPesquisaModel;
 144  6
         lstCategoriasPesquisa.setModel(this.categoriasPesquisaComboBoxModel);
 145  6
     }
 146  
 
 147  
     /**
 148  
      * @param popupAction the popupAction to add
 149  
      */
 150  
     public void addPopupMouseListener(MouseListener popupAction) {
 151  3
         btFiltro.addMouseListener(popupAction);
 152  3
     }
 153  
     
 154  
     /**
 155  
      * @param popupAction the popupAction to remove
 156  
      */
 157  
     public void removePopupMouseListener(MouseListener popupAction) {
 158  0
         btFiltro.removeMouseListener(popupAction);
 159  0
     }
 160  
 
 161  
     /**
 162  
      * @return the acaoPesquisa
 163  
      */
 164  
     public AcaoPesquisa getAcaoPesquisa() {
 165  0
         return acaoPesquisa;
 166  
     }
 167  
 
 168  
     /**
 169  
      * @param acaoPesquisa the acaoPesquisa to set
 170  
      */
 171  
     public synchronized void setAcaoPesquisa(AcaoPesquisa acaoPesquisa) {
 172  0
         this.acaoPesquisa = acaoPesquisa;
 173  0
         registerResearchActionComponent(this.acaoPesquisa);        
 174  0
     }
 175  
 }