2
Copyright 2010, 2012, 2014 Jose Robson Mariano Alves
4
This file is part of bgfinancas.
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
11
This package is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
23
import Biblioteca.Botoes;
24
import Biblioteca.Janela;
25
import Biblioteca.Janelinha;
26
import Biblioteca.Visual;
27
import java.sql.SQLException;
28
import javax.swing.table.DefaultTableModel;
30
public class ReceitasCategoriaPesquisar extends Janela {
32
private final String Acao;
33
private final ReceitasCategoria receitas_categoria;
35
public ReceitasCategoriaPesquisar(ReceitasCategoria receitasCategoria, String acao) {
37
Visual.Janela(this.getJanela());
38
BarraDeFerramentas.add(Botoes.Sair(this));
40
receitas_categoria = receitasCategoria;
41
resultado_pesquisa.setFont(FonteFinancas);
42
resultado_pesquisa.getTableHeader().setFont(FonteFinancas);
49
Banco.executeQuery("SELECT * FROM receitas_categorias WHERE nome LIKE '%"+nome.getText()+"%' ORDER BY nome ASC");
50
DefaultTableModel modelo = (DefaultTableModel)resultado_pesquisa.getModel();
52
while(Banco.getResultSet().next())
54
modelo.addRow(new Object[]{Banco.getResultSet().getString("id_categoria"),Banco.getResultSet().getString("nome")});
56
}catch(SQLException e)
58
Janelinha.Aviso(Lingua.getMensagem("atencao"),Lingua.getMensagem("excecao")+" "+e.getMessage());
63
public void Botoes(String acao)
65
if(acao.equals(Lingua.getMensagem("sair"))){
66
ReceitasCategoriaPesquisar.this.dispose();
71
/** This method is called from within the constructor to
72
* initialize the form.
73
* WARNING: Do NOT modify this code. The content of this method is
74
* always regenerated by the Form Editor.
76
@SuppressWarnings("unchecked")
77
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
78
private void initComponents() {
80
jScrollPane1 = new javax.swing.JScrollPane();
81
jTable1 = new javax.swing.JTable();
82
BarraDeFerramentas = new javax.swing.JToolBar();
83
jPanel1 = new javax.swing.JPanel();
84
jScrollPane2 = new javax.swing.JScrollPane();
85
resultado_pesquisa = new javax.swing.JTable();
86
CEP = new javax.swing.JLabel();
87
nome = new javax.swing.JTextField();
88
BFiltrar = new javax.swing.JButton();
90
jTable1.setModel(new javax.swing.table.DefaultTableModel(
92
{null, null, null, null},
93
{null, null, null, null},
94
{null, null, null, null},
95
{null, null, null, null}
98
"Title 1", "Title 2", "Title 3", "Title 4"
101
jScrollPane1.setViewportView(jTable1);
103
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
104
setTitle(Lingua.getMensagem("pesquisar"));
105
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
107
BarraDeFerramentas.setFloatable(false);
108
BarraDeFerramentas.setRollover(true);
110
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Lingua.getMensagem("receitas")+" > "+Lingua.getMensagem("categoria"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, FonteFinancas, new java.awt.Color(0, 102, 204)));
111
jPanel1.setForeground(new java.awt.Color(51, 94, 168));
113
resultado_pesquisa.setModel(new javax.swing.table.DefaultTableModel(
121
boolean[] canEdit = new boolean [] {
125
public boolean isCellEditable(int rowIndex, int columnIndex) {
126
return canEdit [columnIndex];
129
resultado_pesquisa.getTableHeader().setReorderingAllowed(false);
130
resultado_pesquisa.addMouseListener(new java.awt.event.MouseAdapter() {
131
public void mouseClicked(java.awt.event.MouseEvent evt) {
132
resultado_pesquisaMouseClicked(evt);
135
jScrollPane2.setViewportView(resultado_pesquisa);
136
if (resultado_pesquisa.getColumnModel().getColumnCount() > 0) {
137
resultado_pesquisa.getColumnModel().getColumn(0).setMaxWidth(75);
138
resultado_pesquisa.getColumnModel().getColumn(1).setResizable(false);
139
resultado_pesquisa.getColumnModel().getColumn(1).setHeaderValue(Lingua.getMensagem("nome"));
142
CEP.setFont(FonteFinancas);
143
CEP.setText(Lingua.getMensagem("nome")+":");
145
nome.setFont(FonteFinancas);
146
nome.addActionListener(new java.awt.event.ActionListener() {
147
public void actionPerformed(java.awt.event.ActionEvent evt) {
148
nomeActionPerformed(evt);
152
BFiltrar.setFont(FonteFinancas);
153
BFiltrar.setText(Lingua.getMensagem("pesquisar"));
154
BFiltrar.addActionListener(new java.awt.event.ActionListener() {
155
public void actionPerformed(java.awt.event.ActionEvent evt) {
156
BFiltrarActionPerformed(evt);
160
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
161
jPanel1.setLayout(jPanel1Layout);
162
jPanel1Layout.setHorizontalGroup(
163
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
164
.addGroup(jPanel1Layout.createSequentialGroup()
166
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 576, Short.MAX_VALUE)
168
.addGroup(jPanel1Layout.createSequentialGroup()
170
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
171
.addComponent(nome, javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
172
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
173
.addComponent(BFiltrar)))
176
jPanel1Layout.setVerticalGroup(
177
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
178
.addGroup(jPanel1Layout.createSequentialGroup()
180
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
182
.addComponent(BFiltrar)
183
.addComponent(nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
185
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
189
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
190
getContentPane().setLayout(layout);
191
layout.setHorizontalGroup(
192
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
193
.addComponent(BarraDeFerramentas, javax.swing.GroupLayout.DEFAULT_SIZE, 624, Short.MAX_VALUE)
194
.addGroup(layout.createSequentialGroup()
196
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
199
layout.setVerticalGroup(
200
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
201
.addGroup(layout.createSequentialGroup()
202
.addComponent(BarraDeFerramentas, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
203
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
204
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
208
setSize(new java.awt.Dimension(640, 480));
209
setLocationRelativeTo(null);
210
}// </editor-fold>//GEN-END:initComponents
212
private void nomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeActionPerformed
214
}//GEN-LAST:event_nomeActionPerformed
216
private void BFiltrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BFiltrarActionPerformed
218
}//GEN-LAST:event_BFiltrarActionPerformed
220
private void resultado_pesquisaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_resultado_pesquisaMouseClicked
221
String codSelecionado0;
222
String codSelecionado1;
223
codSelecionado0 = (String)resultado_pesquisa.getValueAt(resultado_pesquisa.getSelectedRow(), 0);
224
codSelecionado1 = (String)resultado_pesquisa.getValueAt(resultado_pesquisa.getSelectedRow(), 1);
225
if(Janelinha.Pergunta(codSelecionado1, Lingua.getMensagem("tem_certeza"))){
226
receitas_categoria.PreencherFormulario(Acao,codSelecionado0,codSelecionado1);
227
ReceitasCategoriaPesquisar.this.dispose();
229
}//GEN-LAST:event_resultado_pesquisaMouseClicked
231
// Variables declaration - do not modify//GEN-BEGIN:variables
232
private javax.swing.JButton BFiltrar;
233
private javax.swing.JToolBar BarraDeFerramentas;
234
private javax.swing.JLabel CEP;
235
private javax.swing.JPanel jPanel1;
236
private javax.swing.JScrollPane jScrollPane1;
237
private javax.swing.JScrollPane jScrollPane2;
238
private javax.swing.JTable jTable1;
239
private javax.swing.JTextField nome;
240
private javax.swing.JTable resultado_pesquisa;
241
// End of variables declaration//GEN-END:variables